How to test if a variable is an integer?
Posted: Sat Oct 12, 2024 11:02 pm
Question
Is there a command to detect if a variable is a number?
BASIC treats numbers in a string like numbers. I have an array of strings which contain both words and integers. Id like to do something like this
For i = 1 to 10
If ArrayOfValues$(i)=<an integer> then
x=ArrayOfValues(i)
print ArrayOfLabels(x)
Else
Print ArrayOfValues(i)
End if
Next i
Is there an elegant way of determining if ArrayOfValues(i) is an integer?
Is there a command to detect if a variable is a number?
BASIC treats numbers in a string like numbers. I have an array of strings which contain both words and integers. Id like to do something like this
For i = 1 to 10
If ArrayOfValues$(i)=<an integer> then
x=ArrayOfValues(i)
print ArrayOfLabels(x)
Else
Print ArrayOfValues(i)
End if
Next i
Is there an elegant way of determining if ArrayOfValues(i) is an integer?