Details inifilefunctions
The file "inifilefunctions.txt" should go in "C:\natspeak support", and is meant to exchange persistent information between a .ini file (a configuration file) and the Visual Basic application (NatSpeak macro)
The basics are taken from O'Reilly Appendix C (rpiAPI.bas) from the book "Win32 API Programming".
In a AdvancedScript macro these functions can be reached if the macro starts with a line:
'#Uses "C:\natspeak support\inifilefunctions.txt"
The .ini functions are assumed to be in this same directory, and a sample file is "taskposition.ini" which holds something like:
[taskpositions] mousex1=18 mousey1=98 mousexdiff=0 mouseydiff=36
That is: section "taskpositions" has four keys, with corresponding values.
function getDefaultInifileDir
This functions gets the directory where the functions are installed. This directory is hard coded, and can be changed by the user. So another directory can also be defined.
In this way the AdvancedScript macro can get the correct filename and section by for example:
Dim section As String Dim iniFile As String Dim defaultInt As Integer section = "taskpositions" defaultDir = getDefaultInifileDir() ' normally "C:\natspeak support", ' is in variable thisDir in inifilefunctions.txt iniFile = defaultDir & "\taskposition.ini" defaultInt = 12345
It can the put of get a integer value from this section by:
Reading:
Dim x1 as Integer x1 = INIGetInt(section, "mousex1", defaultInt, iniFile)
If x1 has the (normally very improbable) value of defaultInt, some message can be shown. (This comes from the macro task <1-20plus>.)
Writing:
This can be done for example by:
Dim p as POINT INISetInt(section, "mousex1", p.x, IniFile) INISetInt(section, "mousey1", p.y, IniFile)
In this example (from macro get task position <1-20plus>) p is a POINT structure which contains the current mouse position, with integer values p.x and p.y. Declarations like the example above.
The whole list of functions:
INIGetString INIWriteString INISetString (is identical to INIWriteString) INIGetLong INIGetBoolean INISetLong INISetBoolean
And also functions to maintain keys and sections (study the code for these):
INIDeleteSection INIDeleteKey INIEnumKeys INIEnumSections INIGetSection INIWriteSection
Default values
Note with all the Get functions a default value must be given! |