Page 1 of 1

is there a way to check if layer has userdata?

Posted: Sun Jun 07, 2015 12:15 pm
by Bugala
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.

Re: is there a way to check if layer has userdata?

Posted: Tue Jun 09, 2015 12:31 am
by airsoftsoftwair
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?

Posted: Tue Jun 09, 2015 6:37 pm
by Bugala
Ah, didnt think that getlasterror.

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
...
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.

Re: is there a way to check if layer has userdata?

Posted: Wed Jun 10, 2015 8:47 pm
by airsoftsoftwair
HaveObjectData() is now implemented.

Re: is there a way to check if layer has userdata?

Posted: Thu Jun 11, 2015 12:48 am
by Bugala
Thanks. That was fast!