How to check if variable is Integer

topic: 

FoxPro doesn't provide a direct way to check if variable is integer or how many digits it has after decimal point but it can be accomplished using PADL() function.

$SAMPLECODE$

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
lnValue = 1.000
* Is Variable integer?
? NOT ( SET("Point") $ PADL(lnValue,20) )

&& Is whole number?
? (lnValue % 1) = 0

* How many digits after decimal point?
? -AT(SET("Point"), PADL(m.lnNumber,20)) % 20

Comments