#153121 - 2005-12-08 08:13 PM
Re: Just for the record
|
NTDOC
Administrator
   
Registered: 2000-07-28
Posts: 11634
Loc: Space
|
Hmmm I thought the new KiX versions would tell you right away what the issue is.
Using these values works well for me.
Code:
Dim $SO $SO=SetOption('Explicit','On') $SO=SetOption('NoVarsInStrings','On') $SO=SetOption('NoMacrosInStrings','On')
|
|
Top
|
|
|
|
#153123 - 2005-12-08 08:32 PM
Re: Just for the record
|
Shawn
Administrator
   
Registered: 1999-08-13
Posts: 8611
|
Quote:
The action of DIMing the variable makes its value NULL(Is that right?)
Thats right.
Quote:
If I pass a parameter like I did above, does the script consider it dimmed?
Yes and no. It considers it as GLOBAL, as if you had done this:
Global $somevariable
Quote:
If not how do I DIM it without losing its contents?
As far as I know you cant. Just assume command line $vars are Global.
|
|
Top
|
|
|
|
#153126 - 2005-12-08 08:39 PM
Re: Just for the record
|
Shawn
Administrator
   
Registered: 1999-08-13
Posts: 8611
|
Not to hammer this home any futher, but the following clearly demonstrates this behavior:
Code:
Break On
$= SetOption("Explicit", "On")
?"value=" $somevariable
Exit 0
We first set Explicit ON, which means this:
Quote:
When you enable the Explicit option, you must explicitly declare all variables using Dim, Global or ReDim statements. If you attempt to use an undeclared variable name, an error occurs. Use the Explicit option to avoid incorrectly typing the name of an existing variable.
Then if you run the script like this:
C:\> kix32 test.kix
You get this:
ERROR : undefined variable [somevariable]! Script: E:\t.KIX Line : 7
But then if you run the same script like this:
C:\> kix32 test.kix $somevariable=1
You get no syntax error. $somevariable passes the test as being declared (Global in this case).
-Shawn
|
|
Top
|
|
|
|
#153131 - 2005-12-12 10:27 AM
Re: Just for the record
|
Richard H.
Administrator
   
Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
|
Quote:
hmmm... glenn, doesn't your code actually force kixtart to end processing if not declared? you can't test $CL_ARG as explicit says you haven't declared it and bombs out.
Did you try it? I guess not 
I use the same trick.
IsDeclared() has special processing which means that the script does not abort if the variable is undeclared. Just as importantly, checking if the variable exists does not create it implicitly.
|
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 875 anonymous users online.
|
|
|