Custom property name of existing var, doesn't get set

If you find an issue in LiveCode but are having difficulty pinning down a reliable recipe or want to sanity-check your findings with others, this is the place.

Please have one thread per issue, and try to summarize the issue concisely in the thread title so others can find related issues here.

Moderator: Klaus

Post Reply
trevix
Posts: 1077
Joined: Sat Feb 24, 2007 11:25 pm
Contact:

Custom property name of existing var, doesn't get set

Post by trevix » Mon Apr 04, 2016 6:07 pm

Crate a stack with a button

Code: Select all

on MouseUp
    put empty into pDialogs
    set the pDialogs of this stack to "one"
end MouseUp
The custom property doesn't get set.
I understand that the pDialogs variable is replaced with empty, so I am actually setting a property with an empty name.
Even if I do this:

Code: Select all

on MouseUp
    put empty into pDialogs
    delete local pDialogs
    set the pDialogs of this stack to "one"
end MouseUp
The question is: How to I reset the variable name so that i can use it to set the name of a custom prop ?
Is this behavior correct?
Trevix
OSX 14.6.1 xCode 15 LC 10 RC1 iOS 15> Android 7>

[-hh]
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2262
Joined: Thu Feb 28, 2013 11:52 pm

Re: Custom property name of existing var, doesn't get set

Post by [-hh] » Mon Apr 04, 2016 11:52 pm

LC does exactly what you want, in both of your examples. You may put the property into a field to see that.

Although it is not seen in the property inspector. You could report this as bug?

But please don't destroy this *script beauty* with your bug report:

Code: Select all

on mouseUp
  set empty of this stack to "I am not empty."
  answer the empty of this stack
end mouseUp
shiftLock happens

trevix
Posts: 1077
Joined: Sat Feb 24, 2007 11:25 pm
Contact:

Re: Custom property name of existing var, doesn't get set

Post by trevix » Tue Apr 05, 2016 12:48 am

Even if it may seem like, I am not looking for needles.

I had a Splash stack that, on "SavingStandalone", was saving in itself a custom prop with data.
For some reason I spent two days debugging because the custom prop wasn't saved. Not in the property inspector, not to be used in the App

Finally I changed the name of the custom prop and voilà. It showed on the property inspector and it could be used by the standalone.
(I was looking for a list of LC reserved words, just in case, but i could not find them, not in LC or the Web.)

Today I discovered the culprit: I had a global with the same name (and with an array inside). So I was naming a custom prop with an array! (ok...I should declare)

These things drive me nut. (Running on empty: JB)
But anyway, beside the global error, how can one re-use a name (I would have thought that "delete local" could resolve, but apparently it just put empty into it. It is also still there on the list of vars of the script editor.
There should be a difference between removing from memory a var or just putting empty on it.
Trevix
OSX 14.6.1 xCode 15 LC 10 RC1 iOS 15> Android 7>

[-hh]
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2262
Joined: Thu Feb 28, 2013 11:52 pm

Re: Custom property name of existing var, doesn't get set

Post by [-hh] » Tue Apr 05, 2016 12:49 am

Hi trevix,

using your first example, in LC 8-dp16 the property is visible in the property inspector. It's key is empty, as you set it.

Thereafter, logically correct, the pDialogs of this stack reports empty (because it IS empty),
and ANY created variable, that is empty and used as property, reports "one", also logically correct.

That is, you detected a way to have a property with an empty key(name), what is different from the property "empty" (see my 'beauty-example' above).

To test this:

Code: Select all

on MouseDown
 put empty into pDialogs
 delete local pDialogs
 set the pDialogs of this stack to "one"
end MouseDown

on mouseUp
  put empty into abc
  answer the abc of this stack --> reports "one"
  -- answer the pDialogs of this stack --> reports empty
end mouseUp
Could we call this a bug? At least it is really good that we now know that, thanks.

Hermann
shiftLock happens

[-hh]
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2262
Joined: Thu Feb 28, 2013 11:52 pm

Re: Custom property name of existing var, doesn't get set

Post by [-hh] » Tue Apr 05, 2016 12:57 am

trevix wrote:There should be a difference between removing from memory a var or just putting empty on it.
Yes there is one and you used it (incompletely): "delete variable".
This would remove the global from memory:

Code: Select all

on MouseUp
    global pDialogs -- you first have to 'reference' it
    put empty into pDialogs
    delete global pDialogs
    set the pDialogs of this stack to "one"
end MouseUp
Edit. Doesn't work for local instead of global. You are right -- that's a bug.
Last edited by [-hh] on Tue Apr 05, 2016 1:09 am, edited 1 time in total.
shiftLock happens

trevix
Posts: 1077
Joined: Sat Feb 24, 2007 11:25 pm
Contact:

Re: Custom property name of existing var, doesn't get set

Post by trevix » Tue Apr 05, 2016 1:05 am

Forget the global.
Still, I don't see this behavior as correct:

Code: Select all

on mouseDown
    put empty into pDialogs
    delete variable pDialogs
    set the pDialogs of this stack to "two"
end mouseDown

on MouseUp
    put empty into abc
    answer the abc of this stack --report "two" but should report empty
end MouseUp
Trevix
OSX 14.6.1 xCode 15 LC 10 RC1 iOS 15> Android 7>

[-hh]
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2262
Joined: Thu Feb 28, 2013 11:52 pm

Re: Custom property name of existing var, doesn't get set

Post by [-hh] » Tue Apr 05, 2016 1:22 am

That's my point of view.
The script sets on mouseDown a property with an empty key and a value "two".
This is displayed "correctly" in the LC 8 property inspector.
Consequently you can ask for this property with *any* referenced variable that has value empty.

This should, as a contrast, return empty:

Code: Select all

on MouseUp
     answer the abc of this stack
end MouseUp
What you detected, the property with an empty key, will be accepted as bug (TMHO it's not a bug, but could be misleading).
Anyway, very interesting, you SHOULD report this. Will save others here debugging time!
shiftLock happens

trevix
Posts: 1077
Joined: Sat Feb 24, 2007 11:25 pm
Contact:

Re: Custom property name of existing var, doesn't get set

Post by trevix » Tue Apr 05, 2016 1:47 am

I will (God...is 2:45 am here in italy and I cannot fall sleep)
Thanks for your help
Trevix
OSX 14.6.1 xCode 15 LC 10 RC1 iOS 15> Android 7>

Post Reply