PenUltima Online

It is currently Fri Sep 05, 2008 12:08 pm

All times are UTC - 8 hours




Post new topic This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 
Author Message
 Post subject: Difference between "0" and null
PostPosted: Sat Mar 11, 2006 8:03 pm 
Offline

Joined: Tue Feb 07, 2006 3:32 pm
Posts: 97
Location: Pittsburgh, Pennsylvania
Simply enough, the ability for eScript to tell the difference between the number "0" and a variable that is "null" or "nothing".

_________________
Image
Image <-- 50% off setup fees! Use PromoCode "NIGHTSCAPE"


Top
 Profile  
 
 Post subject:
PostPosted: Sat Mar 11, 2006 10:01 pm 
Offline
POL Developer
User avatar

Joined: Wed Jan 25, 2006 2:30 am
Posts: 405
Location: San Diego, California
Uhm these things already exist

( !value ) - works for all of the above

( value != 0 ) // Integer 0
( value != error ) // Error
( value != "" ) // empty string

_________________
-Austin


Top
 Profile  
 
 Post subject:
PostPosted: Sun Mar 12, 2006 1:09 pm 
The typical way I test where I need to differentiate between a 0 value and an error or null is this:

Code:
If (!value && value != 0)
'only runs on error
elseif (value == 0)
  'only runs if value is explicitly 0
else
  'etc
endif


You could also:

Code:
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


Top
  
 
 Post subject:
PostPosted: Wed Mar 15, 2006 2:04 am 
Offline

Joined: Fri Feb 03, 2006 6:32 am
Posts: 104
Location: Austria
forgot one option....
Code:
if(value+1)
//...then it's not error :P
endif


works too hehe. But I'd commonly not use it, it's not really nice-to-read code *g*


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 

All times are UTC - 8 hours


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
Style based on FI Subice by phpBBservice.nl