What distinguishes name$ from name.s ?

Just starting out? Need help? Post your questions and find answers here.
^OO^
User
User
Posts: 27
Joined: Mon Apr 28, 2003 5:58 am
Location: United Kingdom
Contact:

What distinguishes name$ from name.s ?

Post by ^OO^ »

Hi ^_^

I noticed that somebody had a problem resulting from a confusion of name.s with name$
They both seem to do the same thing in the same way - store a string.
So, why are there two forms of the same thing?
What distinguishes one from the other (apart from the name) ?
This might be important, after all ...

^@@^
freak
PureBasic Team
PureBasic Team
Posts: 5948
Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany

Post by freak »

The .s thing was there first. The $ was implemented because it is more
'basic' style. .s fits more with PB's type declaration, so I think it's good to
have them both.

If you use $, you always have to append the $ to the variable, which is
why I prefer the .s thing, because it saves me some typing :)
However some people prefer $ because this way they always see, which
one is a string variable and which is not.

Internally, they are both the same, you just can't mix them. Once you
define a string with $, you ALWAYS need to append it.

Timo
quidquid Latine dictum sit altum videtur
^OO^
User
User
Posts: 27
Joined: Mon Apr 28, 2003 5:58 am
Location: United Kingdom
Contact:

Post by ^OO^ »

Thanks, Freak.
So once you have defined say, num.l, you can go on using num ?

Code: Select all

Global floating.f, longnum.l, byte.b, name.s

; so I can use ...

  floating=14.0093
  longnum=39578566376
  bite=251
  name="Baron Frankenstein"

; for the rest of the program?
Cool
Fred
Administrator
Administrator
Posts: 18351
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Post by Fred »

Yes.
GPI
PureBasic Expert
PureBasic Expert
Posts: 1394
Joined: Fri Apr 25, 2003 6:41 pm

Post by GPI »

btw.

Code: Select all

  name.s="hallo"
  name$="Bye"
  debug name
  debug name$
this work:

Code: Select all

  name$="Hallo"
  name=10
this not:

Code: Select all

  name.s="hallo"
  name=10
GPI
^OO^
User
User
Posts: 27
Joined: Mon Apr 28, 2003 5:58 am
Location: United Kingdom
Contact:

Post by ^OO^ »

Hi GPI

About ...

name.s="hallo"
name=10

was name originally name$ or name.s ?
GPI
PureBasic Expert
PureBasic Expert
Posts: 1394
Joined: Fri Apr 25, 2003 6:41 pm

Post by GPI »

only this:
(see all example as new source-codes!)

Code: Select all

  name.s="hallo" 
  name=10 
What i want to say:
Name$
is not
Name.S / Name.W / Name.B / Name.l

There are two diffrent variables!
^OO^
User
User
Posts: 27
Joined: Mon Apr 28, 2003 5:58 am
Location: United Kingdom
Contact:

Post by ^OO^ »

OK
Post Reply