Hi,
I would like to use an ini file to start multiple scripts running at the same time. I found a very useful document on your website that explained how to do it. However I keep getting an error message when running the script "opEq not allowed here"
//Wait for run flag
Let>inifile=Z:\TestFlag\Tests.ini
Readinifile>inifile,main,run,run
Repeat>run
ReadIniFile>inifile,main,run,run
Until>run=1
//Run the test
VBSTART
VBEND
DeleteFile>C:\Rec.txt
DeleteFile>C:\Timing.txt
Using the script debugger I can see the error occurs on the line "Until>run=1"
All help will be much appreciated
Error using ini file
Moderators: JRL, Dorian (MJT support)
-
- Newbie
- Posts: 15
- Joined: Wed Feb 15, 2006 2:25 pm
- Location: London
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
Hi,
Ouch! I see a typo in that document which is the reason for the error. The document uses the same name for the entry as for the variable to assign the value to. So the first time ReadIniFile is used, run gets set to 0. The second time ReadIniFile is called it tries to get the value of an entry called 0. So it returns blank. So then the Until line is invalid because it is trying to compare an integer to a null string.
The simple solution, which also avoids confusion when reading the script, is to modify it thus:
//Wait for run flag
Let>inifile=Z:\TestFlag\Tests.ini
Readinifile>inifile,main,run,runval
Repeat>runval
ReadIniFile>inifile,main,run,runval
Until>runval=1
E.g. the return and loop variable is now "runval" which avoids confusion with the literal value "run" which is the INI entry name.
The other solution, which experienced programmers might prefer, is to use VAREXPLICIT:
//Wait for run flag
Let>VAREXPLICIT=1
Let>inifile=Z:\TestFlag\Tests.ini
Readinifile>%inifile%,main,run,run
Repeat>%run%
ReadIniFile>%inifile%,main,run,run
Until>%run%=1
The second approach enforces a distinction between literals and variables.
I will modify the article you mention accordingly. As it stands the code will generate the error you report. Thanks for spotting this and bringing it to my attention.
Ouch! I see a typo in that document which is the reason for the error. The document uses the same name for the entry as for the variable to assign the value to. So the first time ReadIniFile is used, run gets set to 0. The second time ReadIniFile is called it tries to get the value of an entry called 0. So it returns blank. So then the Until line is invalid because it is trying to compare an integer to a null string.
The simple solution, which also avoids confusion when reading the script, is to modify it thus:
//Wait for run flag
Let>inifile=Z:\TestFlag\Tests.ini
Readinifile>inifile,main,run,runval
Repeat>runval
ReadIniFile>inifile,main,run,runval
Until>runval=1
E.g. the return and loop variable is now "runval" which avoids confusion with the literal value "run" which is the INI entry name.
The other solution, which experienced programmers might prefer, is to use VAREXPLICIT:
//Wait for run flag
Let>VAREXPLICIT=1
Let>inifile=Z:\TestFlag\Tests.ini
Readinifile>%inifile%,main,run,run
Repeat>%run%
ReadIniFile>%inifile%,main,run,run
Until>%run%=1
The second approach enforces a distinction between literals and variables.
I will modify the article you mention accordingly. As it stands the code will generate the error you report. Thanks for spotting this and bringing it to my attention.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
-
- Newbie
- Posts: 15
- Joined: Wed Feb 15, 2006 2:25 pm
- Location: London