osmansirmali Posted May 27, 2008 Share Posted May 27, 2008 Hi We are using below code example for string value... global string temp = " " if((IsEmpty(temp)) ......... else ......... endif But I want use numeric value for same purpose... global temp = 0 if((??????(temp)) ........... else ........... endif If Temp = NaN Which can I use instead of IsEmpty() for Control of Temp Best regards. Osman Link to comment Share on other sites More sharing options...
AzeoTech Posted May 28, 2008 Share Posted May 28, 2008 Actually, I don't think IsEmpty() is what you want in either case. IsEmpty() is for determining if a value has been assigned to a variable yet or not. For an empty string you can do the simple comparison: global string temp = " " if (temp == "") but that won't pick up if you have a string with just spaces in it. In that case you want: global string temp = " " if (ltrim(temp)) == "") Basically "" is a valid string and so isempty() will always return false. If you had this: global string temp if (isempty(temp)) then isempty() would evaluate to true, at least the first time around. If you ran the sequence again after setting temp to some value it would return false. See the difference? As for numbers, its basically the same. IsEmpty() only works if the variable has never been assigned a value. If it is NaN(), you can do: global temp = NaN() if (temp == NaN()) Just remember that NaN() is a function that returns NaN, not a constant, so you need the (). Same goes for Pi() and most other numeric constants. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.