• All, I am currently in the process of migrating domain registrations. During this time there may be some intermittent outages or slowdowns. Please contact staff if you have any questions.

Can someone explain to me how to use NULL()

PS_VITA

Active member
Hey guys,

this might be super basic question to some of you and I know in the manual it says Null is basically "return an empty value" but can someone elaborate on what that means and if possible provide a few useful examples of what you use it for?

Thanks
 
Hey guys,

this might be super basic question to some of you and I know in the manual it says Null is basically "return an empty value" but can someone elaborate on what that means and if possible provide a few useful examples of what you use it for?

Thanks


Null is Null. That's it. I'm not sure what I can do to explain further, but I'll try.

Technically it means you have an allocated memory space without any defined value in it. All variables initialize as NULL until you put something else in them. New coders often mistake it for 0, because testing for 0 and testing for NULL are both true, but they are not the same thing at all and knowing the difference is important.

NULL values are a necessary but dangerous part of coding, because they can lead to NULL pointer errors. For example, if you try to access object properties (like an entity property) but the object pointer is NULL, you are trying to address memory that doesn't exist (or worse, belongs to something else). Back in the 90's, this could lock up the entire machine. These days the OS just instakills an offending application and kicks you to desktop. OpenBOR Script generally prevents this by watching for rogue NULLs and shutting down gracefully with an error in the log.

One of the main uses in OpenBOR is deleting persistent variables. For example, when you assign NULL to a global variable (setglobalvar("<some name>", NULL())), OpenBOR clears it from memory entirely. This is all documented here, and I suggest you read through it.

DC
 
Last edited:
Back
Top Bottom