Page 1 of 1

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

Posted: Fri Jul 18, 2003 9:24 pm
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...

Posted: Fri Jul 18, 2003 9:51 pm
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.

Posted: Sat Jul 19, 2003 12:32 am
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

thanks Alcoholic and Nuggets...

Posted: Sat Jul 19, 2003 1:28 am
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

Posted: Sat Jul 19, 2003 1:49 am
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

nuggets...

Posted: Sat Jul 19, 2003 12:50 pm
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