Display Card ID in a Field

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
tlottrike@gmail.com
Posts: 6
Joined: Sun Jul 15, 2018 9:30 pm
Location: Edinburgh, Scotland

Display Card ID in a Field

Post by tlottrike@gmail.com » Mon Sep 20, 2021 4:49 pm

Hi all

I would like a Field to display the Current Card ID in a stack with a number of Cards but I keep creating an error.

I've been trying variations of the following but no luck

Code: Select all

on opencard
   get the current card id
   put current card id me in Field "FieldCardId"
end opencard
Any suggestions on how I could achieve this?
TIA
Graeme

Mac iMac 2012
MacOS 10-15
Livecode 9_6_4

Klaus
Posts: 13806
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Display Card ID in a Field

Post by Klaus » Mon Sep 20, 2021 5:03 pm

Hi tlottrike@gmail.com,

just like native english! :-)

Code: Select all

on opencard
   put the ID of this card in Field "FieldCardId"
end opencard
Best

Klaus

tlottrike@gmail.com
Posts: 6
Joined: Sun Jul 15, 2018 9:30 pm
Location: Edinburgh, Scotland

Re: Display Card ID in a Field

Post by tlottrike@gmail.com » Mon Sep 20, 2021 5:16 pm

Thanks Klaus (apologies Klaus)

That worked but it insisted instead of "In" I used the word "into" plus I found if I put your script at the Stack Level it worked straight away going from one Card to the next whereas having it at the Card Level it worked but only after clicking through the cards.

Thanks again
Last edited by tlottrike@gmail.com on Mon Sep 20, 2021 10:34 pm, edited 1 time in total.
Graeme

Mac iMac 2012
MacOS 10-15
Livecode 9_6_4

Klaus
Posts: 13806
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Display Card ID in a Field

Post by Klaus » Mon Sep 20, 2021 5:28 pm

tlottrike@gmail.com wrote:
Mon Sep 20, 2021 5:16 pm
Thanks Karl
KARL? Come on, you can do better!
tlottrike@gmail.com wrote:
Mon Sep 20, 2021 5:16 pm
That worked but it insisted instead of "In" I used the word "into"...
Oh, yes, overlooked this one, sorry.
tlottrike@gmail.com wrote:
Mon Sep 20, 2021 5:16 pm
... plus I found if I put your script at the Stack Level it worked straight away going from one Card to the next whereas having it at the Card Level it worked but only after clicking through the cards.
Yes, if your cards do not have a "on opencard" handler of their own, the message OPENCARD will be passed and
finally LC finds an appropriate script in the stack script, so this will be executed on every card.
Make sure you have a field "FieldCardId" on every card!

But even it one or more cards have an own OPENCARD handler you can force the OPENCARD handler in the stack script
to be executed too by PASSing the message.

Card script of one of more cards:

Code: Select all

on opencard
  ## do this
  ## do thqt
  ## and that over there, too
  ## Here it comes:
  pass opencard
end opencard
Best Klaus (KLAUS, K L A U S!)

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9579
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Display Card ID in a Field

Post by dunbarx » Mon Sep 20, 2021 7:50 pm

Hi.

The beauty of LiveCode is that what you would describe in English is usually very close to a workable way for LC to understand.

Usually, close.

The danger of LiveCode is that what you would describe in English may not work at all. You must still abide by a fairly strict syntax.

Your thinking was basically sound. You just needed to say it correctly. When learning, use the dictionary all the time. You would have discovered that there is no native word "current" in the language. It does appear here and there in other contexts, but not the way you used it. Also, if you had looked up "me" you would have seen examples where me is used, though never quite the way you did.

All details, but all critical. It is just a matter of learning how to speak the language. Fortunately, that is easier than learning how to organize your thinking flow into something logical. You already seem to have that well in hand.

Craig

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”