Strings vs Variables

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
Lykaestria
User
User
Posts: 76
Joined: Wed Sep 17, 2008 3:10 am
Location: New Zealand

Strings vs Variables

Post 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
User avatar
Hroudtwolf
Addict
Addict
Posts: 803
Joined: Sat Feb 12, 2005 3:35 am
Location: Germany(Hessen)
Contact:

Post 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
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Re: Strings vs Variables

Post 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.
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
User avatar
Hroudtwolf
Addict
Addict
Posts: 803
Joined: Sat Feb 12, 2005 3:35 am
Location: Germany(Hessen)
Contact:

Post by Hroudtwolf »

Also, you can have 2 x string variables with the same name:
It isn't the same name. ^^
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Post by PB »

Okay, I meant same prefix then. :)
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
Lykaestria
User
User
Posts: 76
Joined: Wed Sep 17, 2008 3:10 am
Location: New Zealand

Re: Strings vs Variables

Post 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.
Post Reply