#64403 - 2002-04-10 02:54 AM
HEADSUP: Intended behavior? "$=" creates a variable
|
Shawn
Administrator
   
Registered: 1999-08-13
Posts: 8611
|
Folks,
This has been posted on the board already (Brian), but I think Ruud's comments at the end of this thread are worthy of re-reading:
Intended behavior? "$=" creates a variable
This will have a negative impact on folks that have (incorrectly) encoded single $ sign hidden-share strings, eg:
This syntax works today:
use m: "\\server\share$"
but it's incorrect and it won't work in the next release! Just a headsup !
-Shawn [ 10 April 2002, 02:56: Message edited by: Shawn ]
|
|
Top
|
|
|
|
#64405 - 2002-04-10 03:17 AM
Re: HEADSUP: Intended behavior? "$=" creates a variable
|
Shawn
Administrator
   
Registered: 1999-08-13
Posts: 8611
|
My "Chicken Little Theory" ?!?!?!? (heheh)(rofl)
No, I was just meaning that when one upgrades to the next version, and realizes that they aren't getting any hidden share maps - this will probably be the cause. Check your scripts before you upgrade kinda thingy.
chicken little theory eh ?
-Shawn
|
|
Top
|
|
|
|
#64410 - 2002-04-10 07:15 AM
Re: HEADSUP: Intended behavior? "$=" creates a variable
|
MCA
KiX Supporter
   
Registered: 2000-04-28
Posts: 5152
Loc: Netherlands, EU
|
Dear Shawn,
You are right. Manytimes we see all kind of code which aren't strictly confirm Ruud's documentation. it - may introduce unknown errors. - may return all kind of compatibilities problems during upgrading to new release. Some examples of not strictly code
- SetOption(DisableDebugging,off)
instead of SetOption("DisableDebugging","off") - Shell 'cmd /c setup.exe '
instead of Shell '%comspec% /c setup.exe - ? "Info: @userid - @wksta - $message"
instead of ? "Info: "+@userid+" - "+@wksta+" - "+$message
With the tools "kixref" and "kixstrip" we try to verify the correctness of scripts. In some situations these tools are more correct than kixtart (f.e. WHILE/LOOP endless loop situation by missing LOOP statement). In some situations Ruud can't cover "bad" code. Normally it may not work, but it did. A nice example in the past was the way "how DIM command in Kixtart 3.6x releases was working". Ruud introduces REDIM as workaround. greetings.
|
|
Top
|
|
|
|
#64414 - 2002-04-11 12:38 AM
Re: HEADSUP: Intended behavior? "$=" creates a variable
|
Richard H.
Administrator
   
Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
|
The use of variables and macros within a quoted string is deprecated but supported. In other words it is bad programming practice and might not work at some future time, but it works now.
The only variables that you can't use in a quoted string are arrays and objects if I recall correctly.
I think the idea is that parsing strings for variables is expensive in terms of CPU, so Ruud was keen to drop it.
The problem is that it would break just about every script in live use
From the latest kix2001.doc manual: quote: A string expression can contain up to 32,000 characters. Any macros, or references to environment strings within a string (e.g.: “String with the macro @USERID in it.”) are resolved before the string is evaluated. For compatibility reasons, references to variables inside strings (e.g.: “String with a $Var in it.”) are also resolved before the string is displayed. The only exceptions to this rule are arrays and object references, which can not be used inside strings. To use arrays or object references in combination with strings, you have to use concatenation.
|
|
Top
|
|
|
|
#64419 - 2002-04-10 02:21 PM
Re: HEADSUP: Intended behavior? "$=" creates a variable
|
Richard H.
Administrator
   
Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
|
Going a bit OT here, but if $string is undefined
code:
$snippet = substr("$string",1,5)
Will return "$stri", probably not what you are after.
A better way of handling it is probably:
code:
$snippet = substr("" + $string,1,5)
|
|
Top
|
|
|
|
#64421 - 2002-04-10 02:26 PM
Re: HEADSUP: Intended behavior? "$=" creates a variable
|
Shawn
Administrator
   
Registered: 1999-08-13
Posts: 8611
|
Richard, sorry, I was referring to it bombing under Kixtart 3.63 and below. Its an old habit I picked-up from long ago you know how these things tend to stick with us.
Hey Lonk, another great point. Numeric and string conversions, yeah:
$number = 0 + $string
$string = "" + $number
heheh
-Shawn [ 10 April 2002, 14:28: Message edited by: Shawn ]
|
|
Top
|
|
|
|
#64422 - 2002-04-11 09:39 AM
Re: HEADSUP: Intended behavior? "$=" creates a variable
|
cj
MM club member
   
Registered: 2000-04-06
Posts: 1102
Loc: Brisbane, Australia
|
I actually consider "" to be a semi-function. It is a function in that it returns the contents as a string. that is
$string="$anything"
$string will be of type String and $anything can be of any time. So, "" converts variables to strings, just like a function. But it doubles as a command that sends data to std out too.
so, it is a semi-function (the only one) in my user manual
my AUD0.02
cj
|
|
Top
|
|
|
|
Moderator: Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart
|
0 registered
and 657 anonymous users online.
|
|
|