Oddity in 'currentCard' function?

Paul Dupuis paul at researchware.com
Tue Oct 24 13:00:25 EDT 2023


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

However, if the card does not have a name set, then current card returns 
"card id <idnumber>", example: card id 1002 and the above 2 lines of 
code return a runtime error of 'can't find card'

put the currentCard of stack "Untitled 1" into tCardName
set the myProperty of cd tCardName of stack "Untitled 1" to tValue

WORKS for cards with a name
FAILS for cards without a name (where currentCard returns 'card id <number')

I think currentCard should just return 'id 1002' rather than 'card id 
1002' if a card has no name.

Trying to execute: set the myProperty of cd tCardName of stack "Untitled 
1" to tValue WHEN tCardName contain 'card id 1002' produces a run time error

But trying to execute: set the myProperty of cd id 1002 of stack 
"Untitled 1" to tValue works.

Oddly, set the myProperty of cd tCardName of stack "Untitled 1" to 
tValue FAILS if tCardName contains "id 10001" (and yes that card with 
that ID exists)

Oddly again, set the myProperty of the currentCard of stack "Untitled 1" 
to tValue DOES WORK whether they have a name or not

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?



More information about the use-livecode mailing list