LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!
I can confirm that in 10.0 (dp1) on Mac it works as expected, no need to declare the variable.
(Although I've never before used "delete variable", only "delete local" and "delete global". But all of them work for me when testing.)
You don't have Strict Compilation Mode on, by any chance?
SWEdeAndy wrote: Thu Feb 03, 2022 7:22 pm
I can confirm that in 10.0 (dp1) on Mac it works as expected, no need to declare the variable.
(Although I've never before used "delete variable", only "delete local" and "delete global". But all of them work for me when testing.)
You don't have Strict Compilation Mode on, by any chance?
No I checked this before making the post.
@Craig: The purpose is to clean the array of all keys and underlying data.
e.g. 'delete variable aBCD["Test"]' needs to delete all all keys and data below ["Test"].
or 'delete variable aBCD' needs to clear the complete array 'aBCD' of data.
I have been working with the stack I am building with numerous array's and it always works except when I do not declare the array as Global or Local.
Just stumbled upon this issue this week. Also tested this in version Livecode 9.6.5 . Same issue.
Sorry, I see now that this happens on Mac too. When I tested before, I actually put something into the variable first.
The error note seems logical to me though: Variables do not need to be explicitly declared, but you can't delete them until they actually exist. And they don't exist until you refer to them in some way, thereby implicitly declaring them.
on mouseUp
put 1 into aBCD ## No declaring, but here it pops into existence
delete variable aBCD
end mouseUp
But in a real case, you wouldn't start a handler off by deleting a non-existent variable anyway. So, how is this actually causing an error in your code?
SWEdeAndy wrote: Fri Feb 04, 2022 10:51 am
Variables do not need to be explicitly declared, but you can't delete them until they actually exist. And they don't exist until you refer to them in some way, thereby implicitly declaring them.
Thanks Andy,
That explains it. I wanted to make sure an array was empty before going into a repeat until routine. However before that routine the array was not used yet.
Thanks for the clarification and example .
Appreciate it!