Some of my layers have userdata, some dont. And they both are using function in which if there is userdata, i need to access it, but problem is, how can i check if there is userdata without crashing the program?
For now when i use GetObjectData, it crashes if there isnt userdata.
Also, I was looking for GetAttribute, "Interval"s have option to query userdata, but "Layer"s dont.
is there a way to check if layer has userdata?
- airsoftsoftwair
- Posts: 5446
- Joined: Fri Feb 12, 2010 2:33 pm
- Location: Germany
- Contact:
Re: is there a way to check if layer has userdata?
I hope you mean that Hollywood exits cleanly, displaying an error message by "crash".... otherwise file a bug report You can manually handle this error by turning off the automatic error handler using ExitOnError() and then use GetLastError() to check if everything worked or not. Then turn on the automatic error handler again. I agree it would be nicer to have a function like HaveObjectData() already inbuilt... I'll see if I can add this.
Re: is there a way to check if layer has userdata?
Ah, didnt think that getlasterror.
I did that exitonerror(fail) thing for that part, but with idea of:
But as a future feature request, it could be handy having that "HaveObjectData" or perhaps "ObjectDataExists"?
especially now that i came to conclusion that carrying out some data in layers themselves is actually pretty handy way of keeping track of things. I think I am going to be using that more in future too.
I did that exitonerror(fail) thing for that part, but with idea of:
Code: Select all
t_userdata = {}
exitonerror(false)
t_userdata = GetObjectData(...)
exitonerror(true)
if listitems(t_userdata) > 0
...
especially now that i came to conclusion that carrying out some data in layers themselves is actually pretty handy way of keeping track of things. I think I am going to be using that more in future too.
- airsoftsoftwair
- Posts: 5446
- Joined: Fri Feb 12, 2010 2:33 pm
- Location: Germany
- Contact:
Re: is there a way to check if layer has userdata?
HaveObjectData() is now implemented.
Re: is there a way to check if layer has userdata?
Thanks. That was fast!