PDA

View Full Version : Odd read .INI behavior


gdanko
05-28-2003, 05:12 PM
Why does this work ONLY if the value in the .INI file is an integer versus a string???

Application.Macros(vbldTemporary).Add "FOO","[%READ_INI(C:\deploy.ini,Batch1,Server0)%]"

--------------------Starting Build: 'Deploy.bld'--------------------
Building project step 'Temp'...
Server0 = WWW6
Build successfully completed.

--------------------Starting Build: 'Deploy.bld'--------------------
Building project step 'Hostname Array'...
Building project step 'Show servername'...
The value of FOO is
Build successfully completed.

--------------------Starting Build: 'Deploy.bld'--------------------
Building project step 'Temp'...
Server0 = 150
Build successfully completed.

--------------------Starting Build: 'Deploy.bld'--------------------
Building project step 'Hostname Array'...
Building project step 'Show servername'...
The value of FOO is 150
Build successfully completed.

Is there some reason for this behavior?

pjaquiery
05-28-2003, 05:25 PM
The attached seems to work. It's not obvious to me what is different though.

gdanko
05-28-2003, 05:34 PM
Okay try this. I assigned my variables using VBS.

pjaquiery
05-28-2003, 05:48 PM
Ok, the attached works for me including the VB script assignment version. Just using the Set Variable step is probably more straight forward though.

gdanko
05-28-2003, 05:49 PM
I wonder why it doesn't work for me.
What version are you using? I am using 5.

pjaquiery
05-28-2003, 05:57 PM
Version 5.

I added default values to the READ_INI macro parameter list.

I also removed the [] from the READ_INI strings, but that just removes [] from around the result string and doesn't otherwise affect the behaviour.

kinook
05-28-2003, 06:03 PM
Two things:

1) Remove the brackets [ ] from your Run Script step. Brackets are used in fields to denote script code. So, first any macros are expanded, then anything between brackets is evaluated as a script expression, and finally the whole string is run through the script engine. The 2nd phase is what's causing you trouble and is unnecessary.

2) There is no reference to a macro in the last step you added, my guess is you want %FOO% there.

gdanko
05-28-2003, 06:05 PM
How odd. I recreated just the read .ini steps in a new project, got it to work. Pasted them in my existing project and it works now, too.

Any way to do this...?

Let's say I have a counter (%COUNTER%) .. it counts 1 - 5.. Can I try do something like this?

%READ_INI(C:\deploy.ini,Batch1,Server%COUNTER%)%

gdanko
05-28-2003, 06:08 PM
I answered my own question. It works! :D

pjaquiery
05-28-2003, 06:10 PM
I was sorely puzzled by the [] and thought that the result would be as kinook described. However the result that I got when playing with it was that the [] were simply inserted into the string that was put in Foo.

However when Foo was expanded later the string was parsed as script and resulted in an error. The implication is that quoted text is not seen by the script engine.