Page tree
Skip to end of metadata
Go to start of metadata

Custom configs can be used to store user-specific data, which can be retrieved even after VBS2 has been closed and restarted.

Saving to a file

; get handle to new file
_file = newconfig

; write a value to the file
_file addvalue ["MyValue",2]

; write a class to the file
_class = _file addclass "MyClass"

; write a value to the class
_class addvalue ["AnotherValue",4]

; save the file
_file saveconfig "MyFile.txt"

The above code would create [vbs user directory]\users\[username]\config\MyFile.txt, and MyFile.txt would contain:

MyValue=2.000000;
class MyClass
{
   AnotherValue=4.000000;
};

Reading a file

; get handle to existing file
_file = loadconfig "MyFile.txt"

; read a value
_myvalue = _file getvalue "MyValue" 

; open a class
_class = _file openclass "MyClass"

; read a value in the class
_anothervalue = _class getvalue "AnotherValue"

Configs - Custom Commands