Page 1 of 1 1
Topic Options
#72002 - 2002-12-05 04:46 PM Can anybody explain this behavior?
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
code:
; running under KiXtart 4.12

;dim $bSilent
;$bSilent=1

if not isdeclared($bSilent)
dim $bSilent
$bSilent=1
? '$$bSilent = '+$bSilent
endif
? '$$bSilent = '+$bSilent

When running this code the first line is printer correctly but the second line tells me tyhat $bSilent is empty. Uncommenting the top two lines will result in a correct output.
_________________________
There are two types of vessels, submarines and targets.

Top
#72003 - 2002-12-05 04:48 PM Re: Can anybody explain this behavior?
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
RTFM [Wink]

it's your dimming, read about variable scopes.
expected behaviour.
_________________________
!

download KiXnet

Top
#72004 - 2002-12-05 04:52 PM Re: Can anybody explain this behavior?
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
Damn, you're right. However, that raises a question. How am I supposed to DIM a variable that could potentially be passed through the commandline but is optional if I am using Explicit=on ? The only way I see is to make it a global variable.
_________________________
There are two types of vessels, submarines and targets.

Top
#72005 - 2002-12-05 05:08 PM Re: Can anybody explain this behavior?
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
doesn't redim preserve fit?

I mean, at the top level...
_________________________
!

download KiXnet

Top
#72006 - 2002-12-05 05:10 PM Re: Can anybody explain this behavior?
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
Nope, have to use GLOBAL if DIMming within the IF-ENDIF, though I just don't like it this way. An IF shouldn't have it's own scope.
_________________________
There are two types of vessels, submarines and targets.

Top
#72007 - 2002-12-05 05:11 PM Re: Can anybody explain this behavior?
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
and, as a sidenote, I use always with commandline vars:
$possiblyPassedVar=""+$possiblyPassedVar

which makes it declared.
not sure kix2001 anymore needs that but with 3.6x script crashed if that wasn't taken care of.

then again, if explicit on, why can't you set it after initial var declare like the above?
_________________________
!

download KiXnet

Top
#72008 - 2002-12-05 05:13 PM Re: Can anybody explain this behavior?
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
Could do this I guess:

code:
if vartype($parm) = 0 ; not passed on cmdline ?
$=execute("dim $$parm")
$parm=5
endif



[ 05. December 2002, 17:15: Message edited by: Shawn ]

Top
#72009 - 2002-12-05 05:15 PM Re: Can anybody explain this behavior?
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
The problem is that the script will accept an optional command line parameter like this:
code:
wkix32.exe shutdown.kix $sComputer='workstation'

The script is supposed to use the workstation name if no parameter is passed into the script. Thus, I'm using IsDeclared to see whether a parameter has been passed into the script. If not, then GLOBAL $sComputer and set it to the workstation name.

[ 05. December 2002, 17:19: Message edited by: sealeopard ]
_________________________
There are two types of vessels, submarines and targets.

Top
#72010 - 2002-12-05 05:15 PM Re: Can anybody explain this behavior?
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
own scope...
I too think it's pretty confusing.
I think we could have separate dim for local:
local (clever eh?)

global - whole process wide
dim - current sub script wide
local - local for current structure

well, I think this same way as kix now has is the most "good" as it's normal behavior in programming languages.
_________________________
!

download KiXnet

Top
#72011 - 2002-12-05 05:17 PM Re: Can anybody explain this behavior?
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
I'm coming 1 post late.
anyway, if you call your script with or without the parameter, you can do:
code:
$sComputer=''+$sComputer
if $sComputer
"was passed"
else
"wasn't passed"
endif

this way it's always global.

{edit}
someone forgot code tags [Roll Eyes]

[ 05. December 2002, 17:19: Message edited by: Lonkero ]
_________________________
!

download KiXnet

Top
#72012 - 2002-12-05 05:18 PM Re: Can anybody explain this behavior?
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
Best solutions Jens ... stop being so hard on yourself [Wink] [Wink] [Wink]
Top
#72013 - 2002-12-05 05:20 PM Re: Can anybody explain this behavior?
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
ah - looks like the westher in jyväskylä is a bit more seasonal ... same here: Toronto is at 30 °F / -1 °C

-Shawn

Top
#72014 - 2002-12-05 05:21 PM Re: Can anybody explain this behavior?
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
It's the German inside me [Wink] We tend to overengineer.
_________________________
There are two types of vessels, submarines and targets.

Top
#72015 - 2002-12-05 05:34 PM Re: Can anybody explain this behavior?
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
das good - itz stoppen zee scriptz fraum floppen
Top
#72016 - 2002-12-05 09:40 PM Re: Can anybody explain this behavior?
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
mmm, current: -19.7 °C

jens, found a "way" you prefer?
_________________________
!

download KiXnet

Top
#72017 - 2002-12-05 10:12 PM Re: Can anybody explain this behavior?
Jochen Administrator Offline
KiX Supporter
*****

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

And that all while it'S that f***ing freakn' Cold up there

RESPECT !
_________________________



Top
#72018 - 2002-12-05 10:14 PM Re: Can anybody explain this behavior?
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
I am currently using the GLOBAL version since I am not willing to give up Explicit=ON.

However, I am now fighting with remote registry writing through WMI. It needs to be done in about 30 minutes and I can write to the remote system [Mad]
_________________________
There are two types of vessels, submarines and targets.

Top
#72019 - 2002-12-05 10:14 PM Re: Can anybody explain this behavior?
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
dear,
we think the cold and the dark are the reasons for this count [Wink]
_________________________
!

download KiXnet

Top
#72020 - 2002-12-05 10:16 PM Re: Can anybody explain this behavior?
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
well, think global in pure explicit in current kix-version is the correct way...
even logically.
_________________________
!

download KiXnet

Top
#72021 - 2002-12-05 10:20 PM Re: Can anybody explain this behavior?
Jochen Administrator Offline
KiX Supporter
*****

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

what helds you from writing to remote by using KiX intrinsic ??
_________________________



Top
Page 1 of 1 1


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

Who's Online
0 registered and 507 anonymous users online.
Newest Members
Sir_Barrington, batdk82, StuTheCoder, M_Moore, BeeEm
17886 Registered Users

Generated in 0.072 seconds in which 0.024 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