Petr Schreiber
22-08-2015, 12:49
In case you need to work with environment variables, you might be interested in module named enVar.
It is provided with full source code, unit tests and binaries here:
https://github.com/petrSchreiber/thinBasic_enVar
How to use
Get the DLL from latest release (https://github.com/petrSchreiber/thinBasic_enVar/releases/latest).
(https://github.com/petrSchreiber/thinBasic_enVar/releases/tag/1.9.16.0Copy)Copy the DLL to your thinBasic/Mod directory, you should be able to reference it then like:
Uses "EnVar"
Example of the syntax:
' -- Sets value of MyVariable to MyValue
enVar_Set "MyVariable", "MyValue"
' -- Retrieves the value of given variable
String s = enVar_Get "MyVariable"
' -- Returns comma separated list of environment variables
String s = enVar_List
' -- Returns list of environment variables, separated by user specified string
String s = enVar_List(";")
' -- Erases the specified variable
enVar_Remove "MyVariable"
' -- Returns non-zero value in case the variable does exist
enVar_Exists "MyVariable"
' -- Set a variable with comma separated values
envVar_Set "MyCars", "Tesla Model S,Ferrari 512GT"
Long nCars = envVar_GetItemCount "MyCars" ' -- Presumes comma, returns 2
nCars = envVar_GetItemCount "MyCars", "," ' -- Separator specified explicitly, returns 2
String firstCar = envVar_GetItem "MyCars", ",", 1 ' -- Returns "Tesla Model S"
String secondCar = envVar_GetItem "MyCars", ",", 2 ' -- Returns "Ferrari 512GT"
Let me know if you need anything to be added.
Petr
It is provided with full source code, unit tests and binaries here:
https://github.com/petrSchreiber/thinBasic_enVar
How to use
Get the DLL from latest release (https://github.com/petrSchreiber/thinBasic_enVar/releases/latest).
(https://github.com/petrSchreiber/thinBasic_enVar/releases/tag/1.9.16.0Copy)Copy the DLL to your thinBasic/Mod directory, you should be able to reference it then like:
Uses "EnVar"
Example of the syntax:
' -- Sets value of MyVariable to MyValue
enVar_Set "MyVariable", "MyValue"
' -- Retrieves the value of given variable
String s = enVar_Get "MyVariable"
' -- Returns comma separated list of environment variables
String s = enVar_List
' -- Returns list of environment variables, separated by user specified string
String s = enVar_List(";")
' -- Erases the specified variable
enVar_Remove "MyVariable"
' -- Returns non-zero value in case the variable does exist
enVar_Exists "MyVariable"
' -- Set a variable with comma separated values
envVar_Set "MyCars", "Tesla Model S,Ferrari 512GT"
Long nCars = envVar_GetItemCount "MyCars" ' -- Presumes comma, returns 2
nCars = envVar_GetItemCount "MyCars", "," ' -- Separator specified explicitly, returns 2
String firstCar = envVar_GetItem "MyCars", ",", 1 ' -- Returns "Tesla Model S"
String secondCar = envVar_GetItem "MyCars", ",", 2 ' -- Returns "Ferrari 512GT"
Let me know if you need anything to be added.
Petr