Oddity in 'currentCard' function?

Bob Sneidar bobsneidar at iotecdigital.com
Mon Nov 13 12:07:22 EST 2023


I never create an object without immediately giving it a name. Problem solved. :-)

Bob S


On Oct 24, 2023, at 9:34 PM, Mark Waddingham via use-livecode <use-livecode at lists.runrev.com> wrote:

On 2023-10-24 18:00, Paul Dupuis via use-livecode wrote:
I think I found a oddity in the "currentCard" property.
The documentation states that the currentCard property return the short name of the current card of a stack:
for example: put the currentCard of stack "Untitled 1" into tCardName
You can then execute code such as: set the myProperty of cd tCardName of stack "Untitled 1" to tValue

...

But again, breaking that example above (set the myProperty of the currentCard of stack "Untitled 1" to tValue) into 2 lines:
put the currentCard of stack "Untitled 1" into tCardName
set the myProperty of cd tCardName of stack "Untitled 1" to tValue
FAILS if the card has no name.
Something just seems off here?

As Jacque said, if an object has an empty name then the short name returns `<chunk> id <id>` (i.e. an id chunk) - this is long standing behavior and one which I'm not sure is entirely helpful (it should perhaps just return empty!).



More information about the use-livecode mailing list