1
Scripting / Check if a slot exists?
« on: January 30, 2019, 06:52:27 AM »
This is probably a silly question, but I haven't been able to divine an answer through the Squirrel reference docs or googling.
I'm used to Javascript (Actionscript, really), where I could test for the existence of an object property something like this:
If I try something similar with Squirrel (in my layouts), I get an error because the slot doesn't exist. Currently, I have a rat's next of try..catch statements to determine whether a slot exists, but it's messy (even though it works). Is there a cleaner way to handle checking whether a slot exists?
I'm used to Javascript (Actionscript, really), where I could test for the existence of an object property something like this:
Code: [Select]
if (obj.prop) {
// Property exists: do stuff:
}
else {
// Property DOES NOT exist: do something else:
}
If I try something similar with Squirrel (in my layouts), I get an error because the slot doesn't exist. Currently, I have a rat's next of try..catch statements to determine whether a slot exists, but it's messy (even though it works). Is there a cleaner way to handle checking whether a slot exists?