Page 1 of 1

Strings vs Variables

Posted: Sun Oct 19, 2008 3:47 am
by Lykaestria

Code: Select all

Text$="Hello"
Text=100
Debug Text$
Debug Text
output:

Hello
100


I love how strings and variables can share the same name... please keep it this way for always :D

Posted: Sun Oct 19, 2008 7:33 am
by Hroudtwolf
Hi,

The "$" symbol is a part of the identifier of the variable.
Due to this fact, "Text$" and "Text" aren't the same identifiers.
Same with pointers.

Best regards

Wolf

Re: Strings vs Variables

Posted: Sun Oct 19, 2008 8:52 am
by PB
@Lykaestria: Relax, it isn't going to change. What made you think so?

Also, you can have 2 x string variables with the same name:

Code: Select all

Text$="Hello"
Text.s="there"
Debug Text$
Debug Text
If you do this, you won't be able to use "Text" for a number though.

Posted: Sun Oct 19, 2008 9:34 am
by Hroudtwolf
Also, you can have 2 x string variables with the same name:
It isn't the same name. ^^

Posted: Sun Oct 19, 2008 9:38 am
by PB
Okay, I meant same prefix then. :)

Re: Strings vs Variables

Posted: Mon Oct 20, 2008 4:35 am
by Lykaestria
PB wrote:@Lykaestria: Relax, it isn't going to change. What made you think so?
I was just worried that .s might completely replace $ one day... I happen to like them both and how it's possible to group variables with the same name together, and how it's even possible to use BASIC command names as strings if you wanted to do so.