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!
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
mrcoollion
- Posts: 738
- Joined: Thu Sep 11, 2014 1:49 pm
Post
by mrcoollion » Thu Feb 03, 2022 6:29 pm
I get an error in the IDE on the following statement of which i am sure it is ok. Used it many times in other places in my stack.
or
Deleting characters with 'delete char ...' works fine.
Working with LC 10.0 (dp1) in Windows 10.
Could this be a bug in the development IDE?
Regards,
Paul
-
mrcoollion
- Posts: 738
- Joined: Thu Sep 11, 2014 1:49 pm
Post
by mrcoollion » Thu Feb 03, 2022 7:13 pm
Additional to my initial post.
If I declare the array e.g. as a local variable then it works.
Has this been changed lately?
Code: Select all
local aBCD
on mouseup
delete variable aBCD["test"]
end mouseup
regards,
Paul
-
SWEdeAndy
- VIP Livecode Opensource Backer

- Posts: 324
- Joined: Sat Aug 16, 2008 9:48 am
-
Contact:
Post
by SWEdeAndy » 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?
-
dunbarx
- VIP Livecode Opensource Backer

- Posts: 10317
- Joined: Wed May 06, 2009 2:28 pm
Post
by dunbarx » Thu Feb 03, 2022 7:38 pm
When you "delete variable" you only clear the contents of that variable, You do not, er, delete it. Does that matter?
Craig
-
mrcoollion
- Posts: 738
- Joined: Thu Sep 11, 2014 1:49 pm
Post
by mrcoollion » Fri Feb 04, 2022 10:33 am
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.
-
Attachments
-

-
SWEdeAndy
- VIP Livecode Opensource Backer

- Posts: 324
- Joined: Sat Aug 16, 2008 9:48 am
-
Contact:
Post
by SWEdeAndy » Fri Feb 04, 2022 10:51 am
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.
So this works:
Code: Select all
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?
-
mrcoollion
- Posts: 738
- Joined: Thu Sep 11, 2014 1:49 pm
Post
by mrcoollion » Fri Feb 04, 2022 4:01 pm
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!
Regards,
Paul
-
andresdt
- Posts: 156
- Joined: Fri Aug 16, 2019 7:51 pm
-
Contact:
Post
by andresdt » Fri Feb 04, 2022 4:12 pm
I wanted to make sure an array was empty before going into a repeat until routine.
You can do this in other way, for example
Code: Select all
if tVariableArray is an array then put empty into tVariableArray
it was good to learn that you shouldn't call the delete variable without having the variable initialized somehow.
Thanks @Andy