Note: This is an archived post that was originally sent to the Hollywood mailing list on Fri, 08 Feb 2008 14:20:53 -0000
Hello, I've a problem inspecting table's elements, I'm not able to check if they exists or not.
For example I have this table:
I can check if the table exists comparing the table against <nil>, for this purpose I have a simple function that do the work:
Code: Select all
Function IsNil(value)
If GetType(value) = #NIL Then Return(1) Else Return(0)
EndFunction
But if I want to check an element inside the table the procedure fails, so if I have:
Code: Select all
mytable = { name = "Fabio" }
NPrint(IsNil(mytable.name)) ; will print 0
NPrint(IsNil(mytable.surname)) ; will raise the error <table field "surname" not initialized!
I'm not able to solve this problem because I need to parse a table with various elements, if they exist I set them, if they not exist I have to get some standard values... in LUA every unset variables are <nil> so this check is very easy. Anyone knows how can I do this job?
Regards