Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » zMUD General Discussion
nutsnbolts
Apprentice


Joined: 01 May 2002
Posts: 188
Location: USA

PostPosted: Sun Mar 05, 2006 7:30 pm   

%null question and better understanding.
 
Excuse this question but I'm trying to get a better understanding on the %null. Can someone give a more layman example as to when I would use this.

I have read the manual about %null and even looked at scripts created that is posted here but I still don't understand it.

Thanks.
_________________
Thank you for everything, it's always appreciated.
Reply with quote
Vorax
Apprentice


Joined: 29 Jun 2001
Posts: 198
Location: USA

PostPosted: Sun Mar 05, 2006 8:32 pm   
 
You can use %null to check to see if a variable has a value or is empty(aka: null). If you have an alias that can be set to use various parameters you can use %null to check them.
#ALIAS checknull {#SAY %if(%-1=%null,No parameters, %if(%2=%null, No second parameter))}

useage:
checknull test
result:
No second parameter
checknull
result:
No parameters

If a variable has a value of "0" it will not match %null. %null = ""
Say you have a variable @test with a value of 0
#VAR test {0}
#IF (@test) {#SAY true} {#SAY false}
This will return false since @test is 0
#IF (@test=%null) {#SAY true} {#SAY false}
This will return false since @test has a value and is not null.
#VAR test {}
#IF (@test) {#SAY true} {#SAY false}
This returns false since @test has no value to evaluate to true.
#IF (@test=%null) {#SAY true} {#SAY false}
This one returns true since @test has no value and is equal to null.
Reply with quote
nutsnbolts
Apprentice


Joined: 01 May 2002
Posts: 188
Location: USA

PostPosted: Sun Mar 05, 2006 9:26 pm   
 
Thanks you for the response. I think I get it now.

Basically NULL is anything that has literally nothing in the "field".

Zero doesn't necessarily mean that it's null.
_________________
Thank you for everything, it's always appreciated.
Reply with quote
Carabas
GURU


Joined: 28 Sep 2000
Posts: 434
Location: USA

PostPosted: Tue Mar 07, 2006 7:26 pm   
 
To further expand upon Vorax' explanation here are a couple more uses that immediately come to mind.

#VAR friends %null

#IF %null(@friends) {ECHO friends has no value} {#ECHO the value of friends is @friends}

It is my opinion that those examples are much cleaner looking than

#VAR friends ""

#IF (@friends=%null) {ECHO friends has no value} {#ECHO the value of friends is @friends}

But fortunately for us, zscript is very forgiving and does not impose one man's opinion or style on everyone.
_________________
Carabas
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » zMUD General Discussion All times are GMT
Page 1 of 1

 
Jump to:  
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 vote in polls in this forum

© 2009 Zugg Software. Hosted by Wolfpaw.net