Go To or Open Card Not Working

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
townsend
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 430
Joined: Sun Feb 13, 2011 8:43 pm

Go To or Open Card Not Working

Post by townsend » Thu Dec 12, 2013 8:09 pm

I'm having a problem getting my app to open with the last used card.
I've been saving the last card ID with "the short ID of this card" fine.
I can retrieve the saved value fine. But I'm having trouble opening that card.

Here's the code. With the Wait statement, the correct card is opened. But not before the first card in the stack is momentarily flashed. As soon as I remove the Wait statement, the Go To Card statement no longer works. I've tried Open Card but that doesn't make a difference.

Code: Select all

on openstack
     wait 0.5 second
     go to card number 6255
end openstack

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10052
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: Go To or Open Card Not Working

Post by FourthWorld » Thu Dec 12, 2013 8:27 pm

The "number" of a card refers to its order position within the stack, where the first card is 1, the second is 2, etc. So to reach "card number 6255" you'd have to have 6,255 cards in your stack - which I hope you don't. :)

To address a card by ID, let LC know your intentions by using the "id" keyword: "go card id 6255"
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

townsend
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 430
Joined: Sun Feb 13, 2011 8:43 pm

Re: Go To or Open Card Not Working

Post by townsend » Thu Dec 12, 2013 8:42 pm

Thanks for the quick reply Richard!

I changed the reference to "number" to "id".
It still didn't work. Then I changed the "Go To" to "Open"
And now it works fine. So I guess you shouldn't use "Go To" unless the card is already open.
What about using Open, even if the Card is open. I do that all the time.
Should I be checking to see if the card is open before using using the Open statement?

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10052
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: Go To or Open Card Not Working

Post by FourthWorld » Thu Dec 12, 2013 8:51 pm

I know from experience that "go cd id <number>" will work - provided it is indeed the ID number of a card that exists in the current stack. You may want to check that ID number.

Or better yet, if you name your cards you can simply use "go cd <cardName>", and then you'll have references that are easy to remember when coding.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

townsend
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 430
Joined: Sun Feb 13, 2011 8:43 pm

Re: Go To or Open Card Not Working

Post by townsend » Thu Dec 12, 2013 8:58 pm

Thanks for your help Richard-- a little mix up there.
It's working fine now.

Post Reply