PenUltima Online Forum Index Official Core: 096.7
Official Core: 097 2008-02-26
Donate towards the POL web hosting bill!
 POL Home   FAQ   Search    Memberlist   Usergroups    Register    Profile   Log in to check your private messages   Log in
Difference between "0" and null

 
Post new topic   This topic is locked: you cannot edit posts or make replies.    PenUltima Online Forum Index -> Feature Suggestions
Display posts from previous:   

Author Message
Danielle



Joined: 07 Feb 2006
Posts: 97
Location: Pittsburgh, Pennsylvania

PostPosted: Sun Mar 12, 2006 12:03 am    Post subject: Difference between "0" and null Reply with quote

Simply enough, the ability for eScript to tell the difference between the number "0" and a variable that is "null" or "nothing".

Author Message
Austin
POL Developer


Joined: 30 Jan 2006
Posts: 355
Location: San Diego, California

PostPosted: Sun Mar 12, 2006 2:01 am    Post subject: Reply with quote

Uhm these things already exist

( !value ) - works for all of the above

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

Author Message
Marilla



Joined: 02 Feb 2006
Posts: 329

PostPosted: Sun Mar 12, 2006 5:09 pm    Post subject: Reply with quote

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

Author Message
Firedancer



Joined: 03 Feb 2006
Posts: 104
Location: Austria

PostPosted: Wed Mar 15, 2006 6:04 am    Post subject: Reply with quote

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*

Post new topic   This topic is locked: you cannot edit posts or make replies.    PenUltima Online Forum Index -> Feature Suggestions All times are GMT - 4 Hours
Page 1 of 1

 




Powered by phpBB © 2001, 2005 phpBB Group :: Theme & Graphics by GHS & Scott E. Royalty