Oddity in 'currentCard' function?

J. Landman Gay jacque at hyperactivesw.com
Tue Oct 24 15:21:43 EDT 2023


The behavior is consistent with all cards or controls that don't have a name. The "name" is the 
ID in that case. The best way around it is to:

   put the long id of <the object or card> into tID

That way you can refer to tID without worrying whether there's a literal name or not. So:

   put the long ID of the currentCard into tID
   set the myProperty of tID to tValue


On 10/24/23 12:00 PM, 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
> 
> 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?
> 
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode

-- 
Jacqueline Landman Gay         |     jacque at hyperactivesw.com
HyperActive Software           |     http://www.hyperactivesw.com




More information about the use-livecode mailing list