Difference between "0" and null
Moderator: POL Developer
-
- Grandmaster Poster
- Posts: 104
- Joined: Tue Feb 07, 2006 3:32 pm
- Location: Pittsburgh, Pennsylvania
Difference between "0" and null
Simply enough, the ability for eScript to tell the difference between the number "0" and a variable that is "null" or "nothing".
The typical way I test where I need to differentiate between a 0 value and an error or null is this:
You could also:
Code: Select all
If (!value && value != 0)
'only runs on error
elseif (value == 0)
'only runs if value is explicitly 0
else
'etc
endif
Code: Select all
If (value == error)
'catches ALL errors, no matter the type
print(cstr(error));
elseif (!value)
'since error is trapped above, this would run on 0
else
'etc
endif
-
- Grandmaster Poster
- Posts: 104
- Joined: Fri Feb 03, 2006 6:32 am
- Location: Austria
- Contact:
forgot one option....
works too hehe. But I'd commonly not use it, it's not really nice-to-read code *g*
Code: Select all
if(value+1)
//...then it's not error :P
endif