Using a INI file for If statement results

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
gchichester
Pro Scripter
Posts: 132
Joined: Mon Dec 22, 2008 4:56 pm
Location: St Augustine FL

Using a INI file for If statement results

Post by gchichester » Fri Sep 24, 2010 7:58 pm

Is it feasible to use a ini file to maintain a list of If statements results, like the following

[code]
If>{(%ShpName% = "JONES") AND (%SLCode% = "OOLU")}
SetDialogProperty>BolDialog,SrvContract,Text,AE095045
EndIf

If>{(%ShpName% = "DIVER") AND (%SLCode% = "APLU")}
SetDialogProperty>BolDialog,SrvContract,Text,EXPIRED
EndIf

If>{(%ShpName% = "DIVER") AND (%SLCode% = "HLCU")}
SetDialogProperty>BolDialog,SrvContract,Text,S9NSE129
EndIf

If>{(%ShpName% = "DIVER") AND (%SLCode% = "HJSC")}
SetDialogProperty>BolDialog,SrvContract,Text,EXPIRED
EndIf

If>{(%ShpName% = "DIVER") AND (%SLCode% = "MAEU")}
SetDialogProperty>BolDialog,SrvContract,Text,EXPIRED

[/code]
Or is there a better option, I have about 80 to maintain and it getting a little laborious

Thanks for any and all suggestions
Gil

sarver311
Pro Scripter
Posts: 84
Joined: Tue Jun 17, 2008 6:37 pm

Post by sarver311 » Fri Sep 24, 2010 9:57 pm

Gil,

I don't have to many suggestions cause I'm not entirely sure what you are trying to do. Here is an example of logging results to an ini file depending on whether it was a true result or false result to your if statement. Can you expand a bit on what you are trying to do with the inifile?

Not sure if this is what you are looking for but here it is.

Code: Select all


//Creating ini named results.ini in my documents folder in case it doesn't exist
IfFileExists>%userdocuments_dir%\results.ini
  //do nothing
else
  writeln>%userdocuments_dir%\results.ini,success,[results]
endif

//if the query is true it puts AE095045 under the section "results" with an entry named query2result, otherwise it puts the value queryisfalse there.
If>{(%ShpName% = "JONES") AND (%SLCode% = "OOLU")}
  SetDialogProperty>BolDialog,SrvContract,Text,AE095045
  EditIniFile>%userdocuments_dir%\results.ini,results,query1result,AE095045
else
  EditIniFile>%userdocuments_dir%\results.ini,results,query1result,QueryisFalse
EndIf

//if the query is true it puts Expired under the section "results" with an entry named query2result, otherwise it puts the value queryisfalse there.
If>{(%ShpName% = "DIVER") AND (%SLCode% = "APLU")}
  SetDialogProperty>BolDialog,SrvContract,Text,EXPIRED
  EditIniFile>%userdocuments_dir%\results.iniresults,query2result,EXPIRED
else
  EditIniFile>%userdocuments_dir%\results.ini,results,query2result,QueryisFalse
EndIf


adroege
Automation Wizard
Posts: 438
Joined: Tue Dec 07, 2004 7:39 pm

Post by adroege » Fri Sep 24, 2010 10:27 pm

I think this is what you are looking for:

Code: Select all


//Set Dialog Properties from a comma delimited file

Let>comma=,

Let>k=0
Label>Start
   Let>k=k+1
   ReadLn>c:\Properties.txt,k,strLine
   If>strLine=##EOF##,end
   Separate>strLine,comma,Property
   If>{(%ShpName% = %Property_1%) AND (%SLCode% = %Property_2%)}
      SetDialogProperty>BolDialog,SrvContract,Text,%Property_3%
   EndIf
   Goto>Start
Label>end


Create a text file called Properties.txt
and put the following lines in it:
------------------------------
JONES,OOLU,AE095045
DIVER,APLU,EXPIRED
DIVER,HLCU,S9NSE129
DIVER,HJSC,EXPIRED
DIVER,MAEU,EXPIRED
------------------------------

sarver311
Pro Scripter
Posts: 84
Joined: Tue Jun 17, 2008 6:37 pm

Post by sarver311 » Fri Sep 24, 2010 10:29 pm

AHH!! that makes way more sense then my proposal. Thanks Adroege :)

gchichester
Pro Scripter
Posts: 132
Joined: Mon Dec 22, 2008 4:56 pm
Location: St Augustine FL

Using a INI file for If statement results

Post by gchichester » Sat Sep 25, 2010 12:14 am

Yes that's exactly what I was looking for. It will be much easier to maintain.
Thanks Adroege for taking the time to share your knowledge

Gil

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