No Explaned Between Dim and Data type

Gifmaster

Member
Licensed User
Longtime User
I Looked in the Help and Read what was Under
Dim and Data Type What i could not find was How to
Declare a Text Var like in the True Basic Standards.
to declare a Text Var you would put the $ along side the Var
{a$="hello"} this would set the Var A as a Text Var
the A value with no $ would be by default a Numeric Val.
How do you declare a text Var in Basic4ppc?
and not sure about the word "String" in data type
but do you declare a string verse a Text Var?
in Basic Standards a String would be 1 or more Text strung
in a Value. Example B$="wdretc" <-- that would be considered a
String. and how do you declare a string in basic4?

Gifmaster
 

klaus

Expert
Licensed User
Longtime User
You don't need to declare the variable type in B4PPC.
All variables are Variant varables and can store any type of number or string.
I wouldn't use the $ suffix for string variables or the % suffix for integer variables any more because they have been abandoned in the more recent basics since there exist long variable names.

In a few special cases a type declaration in arrays is needed with external libraries.

Best regards.
 

Gifmaster

Member
Licensed User
Longtime User
Thanks Klaus for your replay on Declaring a Text Var.
Does That apply with Text strings as well?
Im not understanding the word "string" under data type.

thx
Gifmaster
 

taximania

Well-Known Member
Licensed User
Longtime User
By text variable, do you mean a Char ?
there all the same.
A="Cat" string
B="D" Char

msgbox(A & B) Note the '&'
would show CatD
But msgbox(A + B) Note the '+'
would throw an error. You cant add strings, but can '&' join them.


A=123 number
B="123" a number in a string

msgbox(A & B) Note the '&'
would show 123123

But msgbox(A + B) Note the '+'
would show 246 because you CAN add numeric values in strings to numbers etc

I hope I understood your question correctly and my reply helps.
 

klaus

Expert
Licensed User
Longtime User
What you call a Text variable is a string variable.
If you look at the help file under Data Types you don't see 'Text' as a data type.
You see also a 'Char' type which is a character variable meaning a single character, rarely used. From the character point of view a string can be considered as an array of Char variables (like in the Pascal language).

The other aspects using numbers and strings have been explained by taximania.

Best regards.
 

Gifmaster

Member
Licensed User
Longtime User
taximania You Must NOT be that Old

taximania the way you asked about Text Var you
must not have programed with dos basic in the
80's. as in the Basic Standards Then you had to declare
a Text Var like this A$="Letters" to define it as Text you
had to use the $ to declare it other wise the Letter A defaulted
to a numeric Value A=1 =numeric A$="LetterText"
You were allowed to use both at the same time.
A$="Hello":A="10"
for I=1to4
Print A$;A
next I
end
would give you
Hello10
Hello10
Hello10
Hello10
Things have changed per Compiler as the programmer of the
Compilers define the way you write the code. calling it programming in
basic is some what true but its more like Custom basic as the standards
set forth in 1980 were changed to fit the needs of today's Programming.
Take 2 Compilers of today's era and compare the key words and such
both will not be the same but they claim using their compilers you
are programming in basic yet you would still have to learn each
as they are not using any standard. learning one does not fit all,.
basic4ppc - liberty Basic - NS Basic - Xbasic - and so on.
Microsoft started the changing with Qbasic then Visual Basic and
every one followed doing it. you still have to learn each.
But in 1980 there was a standard
and all were the same Zbasic -- silver basic - MS Dos basic..
learned one of those you could carry over your code to each other.

Gifmaster
 

taximania

Well-Known Member
Licensed User
Longtime User
I used Dos, Commodore Pet, Dragon32, Sinclair, BBC and lots of other variants of
'Beginners All-purpose Symbolic Instruction Code' back in the 80's :)

I'm older than you thought :D

A=2010
A$="Merry christmas and all the best in "

Print A$;A :icon_clap:
 
Top