Post by lal7777 on Jan 28, 2011 0:05:13 GMT -5
While reading the Programmers Guide, which is included in almost every version of Basic4GL. I found a sentence which is misleading. As the Programmers Guide puts it:
"str$
Str$(x) converts an integer value x into a string representation of x.
For example, Str$(-13.4) returns "-13.4"."
By what this says only integer values can be converted into strings. This would mean that the example that is provided is contradictory to what is said. Only Integers can be converted, yet something with a decimal is not an integer (unless the definition of an integer has changed since I last looked), and apparently is able to be converted! However when I tested it with the non-integer -13.4, it provided me with the non-integer string "-13.4" as a string. This brought forth another test in which I used a variable as a double and converted it to a string. The result was an integer. Very confused now, I ran it a couple more times.
Lastly the definition of STR$() does do as it says and converts integers into strings, however that doesn't explain what it does do to with actual non-integer numbers that are put into it.
My suggestion is that somebody please make the Basic4GL v 2.85 HTML more specific or change the function to match the definition STR$() (or failing that at least explain what's going on when the non-integers are typed in and converted).
Thank You for actually reading the minor complaint/suggestion above,
LAL7777
Code used for tests by Basic4GL using Windows 7 on Compaq laptop:
result "-13.4"
result: "-13"
result: "-13" 'which is what it should be
"str$
Str$(x) converts an integer value x into a string representation of x.
For example, Str$(-13.4) returns "-13.4"."
By what this says only integer values can be converted into strings. This would mean that the example that is provided is contradictory to what is said. Only Integers can be converted, yet something with a decimal is not an integer (unless the definition of an integer has changed since I last looked), and apparently is able to be converted! However when I tested it with the non-integer -13.4, it provided me with the non-integer string "-13.4" as a string. This brought forth another test in which I used a variable as a double and converted it to a string. The result was an integer. Very confused now, I ran it a couple more times.
Lastly the definition of STR$() does do as it says and converts integers into strings, however that doesn't explain what it does do to with actual non-integer numbers that are put into it.
My suggestion is that somebody please make the Basic4GL v 2.85 HTML more specific or change the function to match the definition STR$() (or failing that at least explain what's going on when the non-integers are typed in and converted).
Thank You for actually reading the minor complaint/suggestion above,
LAL7777
Code used for tests by Basic4GL using Windows 7 on Compaq laptop:
printr str$("-13.4")
sleep(1000)
end
result "-13.4"
dim x as double
x = -13.4
printr str$(x)
sleep((1000)
end
result: "-13"
dim x as integer
x = -13.4
printr str$(x)
sleep(1000)
end
result: "-13" 'which is what it should be