Page 1 of 1 1
Topic Options
#130744 - 2004-12-07 11:20 AM Variables lose value after IF or CASE statement
bcambre Offline
Fresh Scripter

Registered: 2004-12-07
Posts: 14
Hi, I'm new to Kix and have the following problem. If I declare a variable, and ? it to the screen directly afterwards, there is no problem with the value of the variable. But... when I make an IF of CASE statement in the following lines and try to read or display the same variable, nothing is in it anymore. Is this normal ?
It doesn't matter if I DIM() the variables or not.

regards,
bcambre
_________________________
bram

Top
#130745 - 2004-12-07 11:39 AM Re: Variables lose value after IF or CASE statement
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
No, it is not normal ... please show us some of your code
_________________________



Top
#130746 - 2004-12-07 11:40 AM Re: Variables lose value after IF or CASE statement
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
No, it is not normal

Post the code that does not work, and we will explain what is happening.

Top
#130747 - 2004-12-07 12:10 PM Re: Variables lose value after IF or CASE statement
bcambre Offline
Fresh Scripter

Registered: 2004-12-07
Posts: 14
SetOption('NoVarsInStrings','ON')
SetOption('Explicit','ON')
; Set user's default floor. This is set in an NDS group.
IF EXIST ("C:\WINNT\NOV\VAR3.W01") $DefaultLocation="W01" ENDIF
IF EXIST ("C:\WINNT\NOV\VAR3.W02") $DefaultLocation="W02" ENDIF
IF EXIST ("C:\WINNT\NOV\VAR3.W03") $DefaultLocation="W03" ENDIF
IF EXIST ("C:\WINNT\NOV\VAR3.W04") $DefaultLocation="W04" ENDIF
IF EXIST ("C:\WINNT\NOV\VAR3.W05") $DefaultLocation="W05" ENDIF
IF EXIST ("C:\WINNT\NOV\VAR3.W06") $DefaultLocation="W06" ENDIF
IF EXIST ("C:\WINNT\NOV\VAR3.W07") $DefaultLocation="W07" ENDIF
IF EXIST ("C:\WINNT\NOV\VAR3.W08") $DefaultLocation="W08" ENDIF
IF EXIST ("C:\WINNT\NOV\VAR3.L02") $DefaultLocation="L02" ENDIF
? "Check 1 for Defaultlocation " + $Defaultlocation

; Set users's current floor. This is done through checking of the IP subnet.

$ip3 = LTRIM(SUBSTR(@IPADDRESS0, 9, 3))
IF $ip3="121"
$Location="Lalaing building" + $Location
$Array="02_L HP4050 BW Computer Service", "02_L HP4500 Colour Computer Ser" ENDIF
IF $ip3="122"
$Location="Floor #2 + $Location
$Array="" ENDIF
IF $ip3="123"
$Location="Floor #3" + $Location
$Array="" ENDIF
IF $ip3="124"
$Location="Floor #4" + $Location
$Array="" ENDIF
IF $ip3="125"
$Location="Floor #5" + $Location
$Array="" ENDIF
IF $ip3="126"
$Location="Floor #6" + $Location
$Array="" ENDIF
IF $ip3="127"
$Location="Floor #7" + $Location
$Array="" ENDIF
IF $ip3="128"
$Location="Floor #8" + $Location
$Array="" ENDIF

? "Check 2 for Defaultlocation " +$DefaultLocation
? "LOCATION : " + $Location
For Each $Element In $Array
SHELL 'c:\winnt\system32\iprntcmd.exe "ipp://BR_CLUSTER_NDPS_VOL/ipp/$Element" /ADD'
Next
Only the first check (? "Check 1 for Defaultlocation ") gets printed on the screen the "Check 2" doesnt.
The "LOCATION" does not get printed, even though the $ip3 is correct

I know I can use the SELECT...CASE statement as well, but that does not work either.

bram
_________________________
bram

Top
#130748 - 2004-12-07 12:16 PM Re: Variables lose value after IF or CASE statement
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
You miss one closing quote ("), this messes up the logic...

Quote:

$Location="Floor #2 + $Location




should be:

Code:
$Location="Floor #2" + $Location





_________________________



Top
#130749 - 2004-12-07 12:18 PM Re: Variables lose value after IF or CASE statement
MCA Offline
KiX Supporter
*****

Registered: 2000-04-28
Posts: 5152
Loc: Netherlands, EU
Dear,

We run our tool kixstrip and see that your script contains
an error.
Our call was: kixstrip input.kix output.kix /block_check /show_error
Code:

SetOption('NoVarsInStrings','ON')
SetOption('Explicit','ON')
; Set user's default floor. This is set in an NDS group.
IF EXIST ("C:\WINNT\NOV\VAR3.W01") $DefaultLocation="W01"
ENDIF
IF EXIST ("C:\WINNT\NOV\VAR3.W02") $DefaultLocation="W02"
ENDIF
IF EXIST ("C:\WINNT\NOV\VAR3.W03") $DefaultLocation="W03"
ENDIF
IF EXIST ("C:\WINNT\NOV\VAR3.W04") $DefaultLocation="W04"
ENDIF
IF EXIST ("C:\WINNT\NOV\VAR3.W05") $DefaultLocation="W05"
ENDIF
IF EXIST ("C:\WINNT\NOV\VAR3.W06") $DefaultLocation="W06"
ENDIF
IF EXIST ("C:\WINNT\NOV\VAR3.W07") $DefaultLocation="W07"
ENDIF
IF EXIST ("C:\WINNT\NOV\VAR3.W08") $DefaultLocation="W08"
ENDIF
IF EXIST ("C:\WINNT\NOV\VAR3.L02") $DefaultLocation="L02"
ENDIF
? "Check 1 for Defaultlocation " + $defaultlocation

; Set users's current floor. This is done through checking of the IP subnet.

$ip3 = LTRIM(SUBSTR(@ipaddress0, 9, 3))
IF $ip3="121"
$location="Lalaing building" + $location
$array="02_L HP4050 BW Computer Service", "02_L HP4500 Colour Computer Ser"
ENDIF
IF $ip3="122"
$location="Floor #2 + $Location
; -------> Warning KIXSTRIP: 22 line incomplete "double quotation".
; -------> Warning KIXSTRIP: 22 line incompleted.
$array=""
ENDIF
IF $ip3="123"
$location="Floor #3" + $location
$array=""
ENDIF
IF $ip3="124"
$location="Floor #4" + $location
$array=""
ENDIF
IF $ip3="125"
$location="Floor #5" + $location
$array=""
ENDIF
IF $ip3="126"
$location="Floor #6" + $location
$array=""
ENDIF
IF $ip3="127"
$location="Floor #7" + $location
$array=""
ENDIF
IF $ip3="128"
$location="Floor #8" + $location
$array=""
ENDIF

? "Check 2 for Defaultlocation " +$defaultlocation
? "LOCATION : " + $location
FOR EACH $element IN $array
SHELL 'c:\winnt\system32\iprntcmd.exe "ipp://BR_CLUSTER_NDPS_VOL/ipp/$Element" /ADD'
NEXT


;($begin)
;
; kixstrip 4.03e - kixtart 4.22
;
; tue 07-dec-2004 12:10:28
;
;Warning KIXSTRIP: 1 line is incompleted.
;Warning KIXSTRIP: some lines contains errors or possible errors.
; 1 line incomplete "double quotation".
; 1 line incompleted.
;Informative KIXSTRIP: 18 block_structures found.
;Informative KIXSTRIP: no UDF's found.
;Informative KIXSTRIP: no labels found.
;Summary KIXSTRIP: BREAK CALL DEBUG DISPLAY ENDFUNCTION EXECUTE EXIT FUNCTION GET GETS GOSUB GOTO OLExxx PLAY QUIT RETURN RUN SHELL SLEEP THEN USE
;Informative KIXSTRIP: 1 SHELL
;
;($end)
;($begin)
;
;Warning KIXSTRIP: 22 line incomplete "double quotation".
;Warning KIXSTRIP: 22 line incompleted.
;
;($end)


greetings.

btw: kixstrip can be found on our site.

_________________________
email scripting@wanadoo.nl homepage scripting@wanadoo.nl | Links | Summary of Site Site KiXforms FAQ kixtart.org library collection mirror MCA | FAQ & UDF help file UDF kixtart.org library collection mirror MCA | mirror USA | mirror europe UDF scriptlogic library collection UDFs | mirror MCA

Top
#130750 - 2004-12-07 12:28 PM Re: Variables lose value after IF or CASE statement
bcambre Offline
Fresh Scripter

Registered: 2004-12-07
Posts: 14
That did it ! can you believe i've been breaking my head two days over this one !! Must get that script check tool
thanks,
_________________________
bram

Top
#130751 - 2004-12-07 12:57 PM Re: Variables lose value after IF or CASE statement
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
Ja!

This and additionally an editor that supports syntax highlighting, which enabled me to spot that almost immediately...
_________________________



Top
#130752 - 2004-12-07 12:58 PM Re: Variables lose value after IF or CASE statement
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
Also have a look at one of the editors which support syntax (keyword) highlighting.

These make common errors like missing quotes obvious as you are typing - saves a lot of head scratching!

Top
#130753 - 2004-12-07 01:00 PM Re: Variables lose value after IF or CASE statement
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
exactly
_________________________



Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 2220 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.07 seconds in which 0.033 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org