Quote:A lot of programs I have seen use the "default" A-Z command. What does this do.
I know the previous 3 responses answered the question. Let me try to be more clear.
When a computer uses a variable, that variable must have a type. Data needs type information because it is really just some binary data that we want to assign human-type meaning to. Therefore the binary data is treated differently depending on if it represents a string, an integer, or and floating point numbers.
In QB, All variables have one of the 3 basic data types. For very simple programs, sometimes the programmer doesn't know, or care what the type is. For example if you said:
a = 11
b = a + 2
and I ask you, "what is the type of a and b?", you might very well answer, "Duh...they're numbers, stupid". However, what I'm really asking is "are they integers, or floating point numbers?", which is a valid question.
suppose instead of the preceeding, I had written, instead
a = 11
b = a / 2
now, the type is very important. If b is an floating point number, it will hold the value of 5.5 if b is an integer, it will hold = 5.5, but if it is an integer, then b = 5.
so...in QB there are two basic ways to control the type of a variable. Read this carefully.
1) You can give all instances of the variable a suffex that indicates it's type.
2) You can use a DEFtype statement to set the default type to the type of your choosing.
The suffex rout works well, and it makes the type clear when reading code...howver, it is tedious to always type the suffexes.
the DEFtype rout is more convenient when coding, but it's harder to debug, because it means a variable's type is not obvious.
The suffex list is as follows:
a! floating point (single presision)
a# floating point (double precision)
a% integer(16-bit)
a& integer(32-bit)
a$ text character string
if you want to use DEFtype you do it like so:
DEFINT a-z 'makes all variables 16-bit integers unless a suffex is given
DEFINT a-m 'makes all variable beginning with the letters "a"-"m" integers unless a suffex is given
DEFSNG n-z 'makes all variables starting with "n"-"z" floating point unless a suffex is given.
I hope this helps