ReadIniFile not work?

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
Ghost24de
Newbie
Posts: 13
Joined: Thu Aug 15, 2013 11:24 am

ReadIniFile not work?

Post by Ghost24de » Wed Nov 27, 2013 10:22 pm

Hello,
i have a ini file and in this file i have some declarations and the compl. number of the different tasks!
Here in this file i have 4

the prog... read the ini file and the compl. nr of declarations. then it begin at the last... her nr 4 and there it read the
bregnextrundate and bregnextruntime
after the nr 4 it read the nr 3 then 2 and so on

I have the Problem, it read the nr 4 (first one) then it read
bregnextrundate and bregnextruntime thats ok, but at the next stepp (read nr 3) it doesent read bregnextrundate and bregnextruntime and so on ... the same on nr 2 and nr 1 and if it beginns from the start again (count down to 0 it begin again on 4) it is the same on the task 4 task 3 and so on....
so... it read only one time at the start from the prog the value and not again.
But why? what have i do wrong?
Sry about my bad english!


here the ini file:
*********************************
//*** Variablen declaration ***
//Dynamicvariable

[task_all]
breganzahl=4


[1]
bregnextrundate=27.11.2013
bregnextruntime=22:43:00
breguser=1
bregpass=2
bregmail=3
bregbirth=
bregprovider=
bregstate=
[2]
bregnextrundate=27.11.2013
bregnextruntime=22:45:00
breguser=4
bregpass=5
bregmail=6
bregbirth=
bregprovider=
bregstate=
[3]
bregnextrundate=27.11.2013
bregnextruntime=21:11:00
breguser=7
bregpass=8
bregmail=9
bregbirth=
bregprovider=
bregstate=
[4]
bregnextrundate=28.11.2013
bregnextruntime=22:46:00
breguser=a
bregpass=b
bregmail=c
bregbirth=
bregprovider=
bregstate=
************************

here is the prog:
************************

//***Umgebung Festlegen***
Let>RP_WINDOWMODE=1
Let>RP_DISPLAYERROR=0
Let>IGNOREERRORS=1
Let>RP_ADMIN=1


//***Install Ordner ermitteln***
//****************************************************************************
//Folgende Zeilen sind nur bei Entwicklung ausgeschaltet, müssen für inst. wieder eingeschaltet werden
//RegistryReadKey>HKEY_CURRENT_USER,Software\PSNET,Installation,strFolderName

//****************************************************************************
//Nächste Zeile legt den install ordner für die Entwicklungsphase fest
Let>strFolderName=D:\Temp
//****************************************************************************
Label>Start


//***Aktive Anzahl der Tasks aus File laden***
ReadIniFile>%strFolderName%\PSNET\Sheet\bregruntime.ini,task_all,breganzahl,bregtaskall
Let>a=%bregtaskall%

Label>bregTaskcheck
IF>a>0
//***Werte aus ini File lesen für entsprechende Task Nr***
ReadIniFile>%strFolderName%\PSNET\Sheet\bregruntime.ini,%a%,bregnextrundate,bregnextrundate
ReadIniFile>%strFolderName%\PSNET\Sheet\bregruntime.ini,%a%,bregnextruntime,bregnextruntime

//***Aktuelles Datum ermitteln***
GetDate>current_date

//***Aktuelle Uhrzeit ermitteln***
Gettime>current_time

If>%current_date%=%bregnextrundate%

If>%current_time%=%bregnextruntime%

Message>Date and time arrived from Task %a%

Endif

Endif

Let>a=a-1

//CPU entlasten im nächsten Schritt
wait>0.0005
ELSE
Goto>Start
ENDIF
Goto>bregTaskcheck

Exit
************************

User avatar
Marcus Tettmar
Site Admin
Posts: 7391
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Thu Nov 28, 2013 9:09 am

bregnextrundate is a variable. The first time around it is set to: 28.11.2013

So next time you read in the INI file your ReadIniFile command is looking for an entry called "28.11.2013" because you have specified bregnextrundate for the entry name.

Basically you are using the same name for a literal as a variable. So either you need to use a different naming convention for the variable, OR tell ReadIniFile you mean a literal, not the variable.

So you can simply change lines 24 and 25 to:

Code: Select all

ReadIniFile>%SCRIPT_DIR%\8073.ini,%a%,{"bregnextrundate"},bregnextrundate
ReadIniFile>%SCRIPT_DIR%\8073.ini,%a%,{"bregnextruntime"},bregnextruntime
This tells ReadIniFile you want to read the "bregnextrundate". The way you have it at the moment it will try and find an entry named the same as the VALUE of bregnextrundate.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

Post Reply
cron
Sign up to our newsletter for free automation tips, tricks & discounts