Exactly what is "NIL" as used in the scripting lan

Post your scripting questions / solutions here

Moderator: Moderators

Post Reply
grb
Warrant Officer
Posts: 136
Joined: Fri Jun 06, 2003 12:22 am
Location: USA Philadelphia

Exactly what is "NIL" as used in the scripting lan

Post by grb »

Hi all,
Can anyone provide a technical answer to what "NIL" is and how to use it in the scripting language?
For instance in m5l2b.scr I see the following:

if( level.drive == NIL || level.drive.size == 0)
{
level.drive[0] = dfr_drive_01h_2
...blah......blah....

if (level.prev_drive != NIL)

Obviously it means something different then NULL, where NULL is treated like "\0" as is standard usuage in C-Language. So:

if ($(self.basename) != NULL)
self.basename remove
self remove
Where if the basename is still in existence, then remove it.
NIL means something different, and I have not found an explaination for what it stands for in any of the Script documents or ClassLevel Doc supplied by MOHRadiant etc..

thanks...
grb
User avatar
Alcoholic
General
Posts: 1470
Joined: Sat May 17, 2003 5:57 am
Location: California
Contact:

Post by Alcoholic »

i think it means something like "it doesnt exist" or something like that. for example, lots of error messages say stuff like "blah applied to NIL". i think you can use both but i dont know ask jv+map.
nuggets
General
Posts: 1006
Joined: Fri Feb 28, 2003 2:57 am
Location: U-england-K (england in the UK) :P
Contact:

Post by nuggets »

if a variable hasn't been defined, it'll have NIL as it's outcome

i.e.

main:
level.test1 = 0
end

so if you type
if (level.test1 == 0)
//it'll be true

//but
if level.test2 == 0)
//it'll be false, becuase level.text2 will = NIL
hope this helps, prob not cos it's all foreign 2 me :-/
grb
Warrant Officer
Posts: 136
Joined: Fri Jun 06, 2003 12:22 am
Location: USA Philadelphia

thanks Alcoholic and Nuggets...

Post by grb »

Your answers sound reasonable and are probably correct. NIL in the English language does mean.... Nothing or does not exits. Just wanted
to make sure.
And I can see where it could have an application within the scripting language, where a thread might be called and within it contain various logic that test to see if a variable was created or not AT THAT POINT in time and then apply the resultant decision to continue or set it to something or whatever.

Thanks guys.
cheers
grb
nuggets
General
Posts: 1006
Joined: Fri Feb 28, 2003 2:57 am
Location: U-england-K (england in the UK) :P
Contact:

Post by nuggets »

yes :P

although... not using if ($something.seomthing == NIL)
will not crash ur script, it's just a way of making sure it gets used if nothing has been defined in it
hope this helps, prob not cos it's all foreign 2 me :-/
grb
Warrant Officer
Posts: 136
Joined: Fri Jun 06, 2003 12:22 am
Location: USA Philadelphia

nuggets...

Post by grb »

That is what the NULL test is supposed to be for, or at least that is the way
I enterprete it....guess I simply should make a bunch of test cases up.
In some language systems one tests for NULL on a variable to see if it
exists but never was set to anything. NIL, as you two had indicated in your original statements indicates that the variable does not exists.
To test to see if the variable is not set to something (not defined as I believe your wording indicates) one would test for NULL.
Thanks for the feedback.
cheers all
grb
Post Reply