#82014 - 2003-02-20 04:51 AM
Re: Using $ inside quotes
|
Les
KiX Master
Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
|
OK, so I took some heat for saying that using $ as a var is not considered good practice. Sure, you can use it with impunity and better your golf score, but beware that if someone adopts your code and adds it to theirs, things can go amuck. Let's not forget that the topic is about $ in quotes more than it is about using $ as a var.
I'd like to commend Ruud for saying that "Vars inside strings are evil" because they are! I only wish he would have taken it a step further and made the default SetOption('NoVarsInStrings','on') but since he didn't, everyone should set it in their script. Ruud did change KiX from 4.10 on to no longer resolve '$' as a var when used inside strings but code often has a way of ending up in previous versions.
Now to add to the confusion. So, we read that vars in strings are evil, and that we should code like this: code:
Use 'H:' '\\Server\Users\'+@UserID+'$$'
But if we set SetOption('NoVarsInStrings','on') this would result in a doubling of the $$: quote: \\Server\Users\UserID$$
The manual does tell us that if we set SetOption('NoVarsInStrings','on'), that "if this option is enabled, any '$' character in a string will be left as-is". [ 20. February 2003, 05:18: Message edited by: LLigetfa ]
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.
|
Top
|
|
|
|
Moderator: Jochen, Radimus, Glenn Barnas, Allen, Arend_, ShaneEP, Mart
|
0 registered
and 686 anonymous users online.
|
|
|