StringVar.s contra StringVar$
StringVar.s contra StringVar$
I know StringVar.s and StringVar$ are two different things - but what makes them different?
What's the deeper sense of having two different types for string variables and when to use which one?
Kind regards,
Micha B.
What's the deeper sense of having two different types for string variables and when to use which one?
Kind regards,
Micha B.
Re: StringVar.s contra StringVar$
In the background, these strings are from exactly the same type, performance etc.
But keep in mind that the $ is part of the variable name. So you can declare StringVar$ and StringVar.s as separate variables (but it is not recommended).
I think, the declaration with the $ is just a leftover from the good old Basic era, similar to Dim instead of NewArray for example.
I prefer to use only StringVar.s
But keep in mind that the $ is part of the variable name. So you can declare StringVar$ and StringVar.s as separate variables (but it is not recommended).
I think, the declaration with the $ is just a leftover from the good old Basic era, similar to Dim instead of NewArray for example.
I prefer to use only StringVar.s
PB 6.01 ― Win 10, 21H2 ― Ryzen 9 3900X, 32 GB ― NVIDIA GeForce RTX 3080 ― Vivaldi 6.0 ― www.unionbytes.de
Lizard - Script language for symbolic calculations and more ― Typeface - Sprite-based font include/module
Lizard - Script language for symbolic calculations and more ― Typeface - Sprite-based font include/module
Re: StringVar.s contra StringVar$
They are the same data type but two different variables.
I prefer to use StringVar$ because when I look at the source then I can spot strings easily, I never use .s if I can avoid it.
Sometimes I have to use StringVar.String when I want to pass a input-output string to a procedure and that to me is horrible enough to look at.
I prefer to use StringVar$ because when I look at the source then I can spot strings easily, I never use .s if I can avoid it.
Sometimes I have to use StringVar.String when I want to pass a input-output string to a procedure and that to me is horrible enough to look at.
"Have you tried turning it off and on again ?"
-
- Addict
- Posts: 4791
- Joined: Thu Jun 07, 2007 3:25 pm
- Location: Berlin, Germany
Re: StringVar.s contra StringVar$
Some people prefer the toilet paper to hang down the front, others prefer it to hang down the back. 

Re: StringVar.s contra StringVar$
Comparing parts of purebasic with toilet paper? You should prepare yourself for a shitstorm.Little John wrote: Sat Jul 01, 2023 12:02 pm Some people prefer the toilet paper to hang down the front, others prefer it to hang down the back.![]()

I use both variants without any pattern.

Good morning, that's a nice tnetennba!
PureBasic 6.21/Windows 11 x64/Ryzen 7900X/32GB RAM/3TB SSD
Synology DS1821+/DX517, 130.9TB+50.8TB+2TB SSD
PureBasic 6.21/Windows 11 x64/Ryzen 7900X/32GB RAM/3TB SSD
Synology DS1821+/DX517, 130.9TB+50.8TB+2TB SSD
Re: StringVar.s contra StringVar$
If you use $ at the end, you can avoid the word String in front to see that it is a string
Less typing, easier to read.

Less typing, easier to read.
Re: StringVar.s contra StringVar$
Religious wars started for a lot less.
I would prepare my flag with a $ on top of it but someone could misunderstand it.
I would prepare my flag with a $ on top of it but someone could misunderstand it.
"Have you tried turning it off and on again ?"
Re: StringVar.s contra StringVar$
But you need .s in a structure if you use it for ExtractJsonStructure() because $ does not fit the name of the json key.
Else, .s and $ are usable vice versa.
Else, .s and $ are usable vice versa.
Re: StringVar.s contra StringVar$
.s is stylistically more consistant therefore $ should be rejected.
Re: StringVar.s contra StringVar$
I agree with luis
When I receive an error message Number expected instead of a string I catch where the error exist directly
But still no harm to have both
When I receive an error message Number expected instead of a string I catch where the error exist directly
But still no harm to have both
Egypt my love
Re: StringVar.s contra StringVar$
But you have to press the shift key to get a "$".infratec wrote: Sat Jul 01, 2023 12:50 pm If you use $ at the end, you can avoid the word String in front to see that it is a string![]()
Less typing, easier to read.

It is best not to mix
A dynamic string variable is a pointer to the characters of string
When a string is changed, the pointer can change, for example, if the memory space for the new string is too small.
To pass a string ByRef to a function, one must pass the pointer to the pointer of the string (Stupid text!).
Code: Select all
Global fixedString.s{16}
Global fixedString${16}
Global dynamicString.s
Global dynamicString$
Global structString.String
fixedString = "Hello "
fixedString$ = "World!"
dynamicString = fixedString + fixedString$
dynamicString$ = UCase(dynamicString)
Debug dynamicString
Debug dynamicString$
structString\s = dynamicString$
Procedure fcStringByRef(*refStr.String)
*refStr\s = "*** " + *refStr\s + " ***"
EndProcedure
fcStringByRef(@structString)
Debug structString\s
Since number variables have a fixed size, this can pass the pointer to the number
Code: Select all
Global varInteger.i
Procedure add(*var.Integer, value = 1)
*var\i + value
EndProcedure
varInteger = 10
Debug varInteger
add(@varInteger, 10)
Debug varInteger
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
Re: StringVar.s contra StringVar$
I use $ for protected/local scope & .s for global scope.
HP Z800 Workstation
CPU : Dual Xeon 5690 3.46GHz
RAM : 96GB RAM ( 8GB x 12 )
PSU : 1100W
GPU : NVIDIA RTX 3050 8GB
STORAGE : 9TB
(4) 2TB Seagate IronWolf Pro HDD
(1) 1TB Samsung 870 EVO SSD
CPU : Dual Xeon 5690 3.46GHz
RAM : 96GB RAM ( 8GB x 12 )
PSU : 1100W
GPU : NVIDIA RTX 3050 8GB
STORAGE : 9TB
(4) 2TB Seagate IronWolf Pro HDD
(1) 1TB Samsung 870 EVO SSD
Re: StringVar.s contra StringVar$
I alway just thought someone's having a bad day no need to swear$ @#$##
I prefer .s
I prefer .s
Re: StringVar.s contra StringVar$
Whoa! A single character tells me string data type or not. What's not to like?
Next you .s people will demand we drop the * from all our *Pointers?!?
Never!
Next you .s people will demand we drop the * from all our *Pointers?!?
Never!

The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum
Re: StringVar.s contra StringVar$
people have to use pointers 1st!skywalk wrote: Sat Jul 01, 2023 10:02 pm Whoa! A single character tells me string data type or not. What's not to like?
Next you .s people will demand we drop the * from all our *Pointers?!?
Never!![]()

I'd prefer *foo.i or *str.s