Page 1 of 1 1
Topic Options
#98589 - 2003-02-19 05:33 PM New FAQ Topic: Using $ inside quotes
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
I posted a new FAQ on the use of $ inside quotes.

If someone would like to expand upon the topic with perhaps what happens when Execute() is added to the mix, I would be grateful.

Any other words of enlightenment?

Topic: Using $ inside quotes
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#98590 - 2003-02-19 07:36 PM Re: New FAQ Topic: Using $ inside quotes
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
That'd be me then ... as I was formerly known as the execute()-tioner [Big Grin]

If time allows I volunteer
_________________________



Top
#98591 - 2003-02-19 07:42 PM Re: New FAQ Topic: Using $ inside quotes
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
uh-ah, I think this topic is good one...

not sure of the comment of not being good practise gets my hair up.
and the length of the hair is not so small.

anyway, it is mostly used as "null" operand to direct "noise" to.
but I use it in many places as the main var.

not good practise goes into the way that it's not "hungarian notation" etc.

dollar sign anyway shouldn't be used in strings like manual states...

so I don't see a reason of it not being a good practise other than some newbies getting confused
_________________________
!

download KiXnet

Top
#98592 - 2003-02-19 10:17 PM Re: New FAQ Topic: Using $ inside quotes
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Jooel,
That is it exactly, "some newbies getting confused". They, in the grand KixTart tradition, copy code they don't fully understand and paste it into their 1000 line logon script which too is full of code they don't understand (invariably copied) and the $ blows it out of the water.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#98593 - 2003-02-19 10:40 PM Re: New FAQ Topic: Using $ inside quotes
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
lol, quess that is the reason my logonscript in it's full complexity is just about 100 lines [Razz]
_________________________
!

download KiXnet

Top
#98594 - 2003-02-20 04:25 AM Re: New FAQ Topic: Using $ inside quotes
Kdyer Offline
KiX Supporter
*****

Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
I know there have been a number of arguments for using $= or $RC=.. If you reuse the Variable, I could understand assigning a variable. Whereas, if you are doing testing, what is the harm in using a simple $= to debug the results?

It maybe considered poor practice to assign a "nul" variable, but can also be quite helpful. I can see the argument as it being a "double-edged" sword when trying to trim things down.

On a side note: I have been already swayed to use single quotes (thanks Les) and to trim down spaces and length of variables (thanks Jooel)..

Cheers!

Kent

[ 20. February 2003, 04:26: Message edited by: kdyer ]
_________________________
Utilize these resources:
UDFs (Full List)
KiXtart FAQ & How to's

Top
#98595 - 2003-02-20 05:21 AM Re: New FAQ Topic: Using $ inside quotes
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
OK, I call uncle!
This was not meant to be so much about using $ as a var but rather about using $ inside quotes. Read the topic title people. Also, re-read the FAQ as I have added to it.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#98596 - 2003-02-20 06:07 AM Re: New FAQ Topic: Using $ inside quotes
Kdyer Offline
KiX Supporter
*****

Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
Ahh..

I see.. Good information.

Thanks,

Kent
_________________________
Utilize these resources:
UDFs (Full List)
KiXtart FAQ & How to's

Top
#98597 - 2003-02-20 02:49 PM Re: New FAQ Topic: Using $ inside quotes
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
Ok, I got 5 minutes of spare time and started a test session with vars inside execute() - strings.

Actually did run immediately into (imho) unsolvable trouble with NoVarsInStrings Option on

(The code was half stolen from one of Richards replies here : Combine Variables)

grrrr ... HTML is disabled [Mad]

code:
break on

dim $c, $out
;$ = setoption("NoVarsInStrings","on")
$n = 1
$c = 1
$s1 = "string " + $n
$s2 = "string 2"
$s3 = "string 3"
$out = ""

while execute("exit vartype($$s" + $c + ")")
$ = execute("$$out = $$s" + $c)
$out ?
$c = $c + 1
loop

get $

Challenge : Try to get this to run if you uncomment the setoption() .. line [Eek!] [Eek!] [Eek!]

J.

[ 20. February 2003, 14:51: Message edited by: jpols ]
_________________________



Top
#98598 - 2003-02-20 03:19 PM Re: New FAQ Topic: Using $ inside quotes
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
J,
How about not doubling $$ if NoVarsInStrings is on.
code:
break on

dim $c, $out
$ = setoption("NoVarsInStrings","on")
$n = 1
$c = 1
$s1 = "string " + $n
$s2 = "string 2"
$s3 = "string 3"
$out = ""

while execute("exit vartype($s" + $c + ")")
$ = execute("$out = $s" + $c)
$out ?
$c = $c + 1
loop

get $

_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#98599 - 2003-02-20 03:41 PM Re: New FAQ Topic: Using $ inside quotes
Jochen Administrator Offline
KiX Supporter
*****

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

I should have known [Embarrassed]

Ok ... forgive my ignorance as I never even thought of using Novarsinstrings [Roll Eyes]

Will go and hide behind the next rock drinking my 9th coffee now
_________________________



Top
#98600 - 2003-02-20 04:03 PM Re: New FAQ Topic: Using $ inside quotes
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
well, back at les.
this is not even kixtart in the way you meant:
"\\Server\Users\" + @UserID + $

you are querying the stuff inside $ var.
if you have vars in strings, it would be:
"\\Server\Users\@UserID$"

or:
"\\Server\Users\@UserID$$"

I don't see any place of confusion here.
except with the old kix versions which you refer to.
_________________________
!

download KiXnet

Top
#98601 - 2003-02-21 02:20 AM Re: New FAQ Topic: Using $ inside quotes
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Jooel,
If you re-read the FAQ you will see that elaborated on the original "prior to 4.10 version".

But when it comes to Execute(), I thought I would have gotten some more interesting responses.

Here are a couple of old threads I dug up.

http://www.kixtart.org/board/ultimatebb.php?ubb=get_topic;f=1;t=005321#000009

http://www.kixtart.org/board/ultimatebb.php?ubb=get_topic;f=1;t=005239#000001

Now to put that in FAQ-style terms...
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#98602 - 2003-02-21 02:28 AM Re: New FAQ Topic: Using $ inside quotes
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
uuh!

yeah, the execute!
(gladly newbies don't use it)

it really is gotcha.

{edit}
mark of 7 for archiving. real 7M by board is this
{/edit}

[ 21. February 2003, 05:57: Message edited by: Lonkero ]
_________________________
!

download KiXnet

Top
Page 1 of 1 1


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

Who's Online
0 registered and 843 anonymous users online.
Newest Members
batdk82, StuTheCoder, M_Moore, BeeEm, min_seow
17885 Registered Users

Generated in 0.134 seconds in which 0.1 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