How to see if a TYPE object exists?
Blitz3D Forums/Blitz3D Programming/How to see if a TYPE object exists?
| ||
How would I go about to check if there any TYPES beyond the current type I am processing? For example: object.type = first type How can I see if there is a type after this? If I assumed (wrongly) there is another and tried to process anything I'd get an error because there is no other objects after the FIRST. type.type = after type <--- this would give an error if there is nothing after So is there a way to check so I don't get nasty errors? :) |
| ||
I think the way I often do it is For object.type = Each type numofobjects=numofobjects+1 Next Off the top of my head, that would be the easiest way to go through the whole type, then you could use that in another for loop to use first then after. If that will not work, ill look into another way, it will help me as much as it will help you i suppose... |
| ||
|
| ||
Just use the Null command. It will tell you if the instance you are looking at does not exist.Type test Field x End Type Local t.test = New Test t = After t If t = Null Print "There is nothing here" Else Print "This should never happen" EndIf EDIT: Ninja'd by Yue. |
| ||
t.type = after t shouldn't cause an error - it should only error if you try to do something else with t without first checking via the null object as Yue explained. |