Page 1 of 1 1
Topic Options
#45449 - 2003-09-16 01:49 PM Bug or Feature
creutz Offline
Fresh Scripter

Registered: 2000-06-14
Posts: 32
Loc: Helsinki, Finland
[Moderator (Sealeopard): Moved topic from 'Scripts' to 'Starters' forum due to lack of script in body]

$X = "qwery"

? '$X'
gives qwerty
? '$X_'
gives $X_
? '$X'+'_'
gives qwerty_

why does the second example not print the variables content

tia Creutz

ps more of a question,
not a problem anymore as I solved the situation as in example 3

[ 17. September 2003, 20:43: Message edited by: sealeopard ]

Top
#45450 - 2003-09-16 02:01 PM Re: Bug or Feature
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
Try:
$x='qwerty'
$z='12345'

? '$x$z'

The issue is the way that KiXtart parses the string and interpolates variable names within the string.

In your example $X_ is interpreted as the name of the variable which is currently empty. When the variable is empty the text of the veriable name is printed as text.

A best practice is to not include variable names within strings.

[ 16. September 2003, 14:35: Message edited by: Howard Bullock ]
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#45451 - 2003-09-16 02:09 PM Re: Bug or Feature
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4673
Loc: The Netherlands
[Confused] [Confused]

No problems here.
You filled $X with qwery so why should it display qwerty if you put qwery in it. Must be some other typo or something.

$X = "qwery"
? '$X'
gives qwery

? '$X_'
gives $X_

? '$X'+'_'
gives qwery_

The second example printing nothing.....like Howard said.
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#45452 - 2003-09-16 02:23 PM Re: Bug or Feature
creutz Offline
Fresh Scripter

Registered: 2000-06-14
Posts: 32
Loc: Helsinki, Finland
actually I did
$X='qwerty'
and
? '$X_' did not work
but
? '$X.' works, I get qwerty.

it is only the underscore just after a variable
that does not work - strange is it not

Creutz

ps I will try to use concatenation better in the future

Top
#45453 - 2003-09-16 02:24 PM Re: Bug or Feature
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
No it is not strange. It is expected behaviour.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#45454 - 2003-09-16 02:29 PM Re: Bug or Feature
creutz Offline
Fresh Scripter

Registered: 2000-06-14
Posts: 32
Loc: Helsinki, Finland
Please explain to me,
why a underscore after a variable is NO NO
but an other charater like space or period OK,
I dont see the consistency.

Is underscore some special character that I dont know of?

? Creutz

[ 16. September 2003, 14:30: Message edited by: creutz ]

Top
#45455 - 2003-09-16 02:38 PM Re: Bug or Feature
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
I already explained it. [Confused] [Confused]

The underscore is not a special function character like space or period and is interpretted as part of the variable name. Why is that difficult to comprehend?
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#45456 - 2003-09-16 02:40 PM Re: Bug or Feature
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
...oh, and while your at it, stop using vars in strings. It is considered to be in poor form.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#45457 - 2003-09-16 02:42 PM Re: Bug or Feature
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
...and the code you posted does not qualify to be in the "Scripts" forum. This is more of a "Starters" question.

Maybe a mod should move 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
#45458 - 2003-09-16 02:44 PM Re: Bug or Feature
creutz Offline
Fresh Scripter

Registered: 2000-06-14
Posts: 32
Loc: Helsinki, Finland
at last I got [Big Grin]

underscore is as much a character as a, b, c, ...
but space, period and such are separators

thanks for the explains

Creutz

Top
#45459 - 2003-09-16 02:48 PM Re: Bug or Feature
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4673
Loc: The Netherlands
creutz :

FYI.
Special characters are -, +, =, *, / because they are ussed for (among other stuff) calculations.

Example:
code:
$a = 2
$b = 3
$c = $a+$b
?$c

$c in this example would become 5.
Same can be done with -, +, etc..
Underscore will be seen as part of the variable name.

And maybe a mod should move it to starters indeed.

[ 16. September 2003, 14:49: Message edited by: R2D2 ]
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#45460 - 2003-09-17 02:51 AM Re: Bug or Feature
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
hmm...
there shouldn't actually be any special characters in strings except white-space.
_________________________
!

download KiXnet

Top
#45461 - 2003-09-17 02:56 AM Re: Bug or Feature
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
The term 'special characters' actually may be a little "strong". when parsing a string that may contain variables, some character just aren't considered to be part of a variable name. Like the "$" which is the start of a variable and not a character anywhere else in the variable name. So in this case, is "$" a special character? I do not think it really matters especially if one starts to follow the "no vars in strings" best practice.

[ 17. September 2003, 02:59: Message edited by: Howard Bullock ]
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#45462 - 2003-09-17 08:42 PM Re: Bug or Feature
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
See also the KiXtart Manual for info on variables and see the SETOPTION() command.
_________________________
There are two types of vessels, submarines and targets.

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
1 registered (Allen) and 363 anonymous users online.
Newest Members
Sir_Barrington, batdk82, StuTheCoder, M_Moore, BeeEm
17886 Registered Users

Generated in 0.034 seconds in which 0.013 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