Return to same card in app

Getting into LiveCode for iOS? Ask your questions here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
Tester2
Posts: 102
Joined: Wed May 18, 2011 7:02 pm

Return to same card in app

Post by Tester2 »

I'm probably just overlooking it in the forums/manual, but what code do I need to enter (and where), to have my user return to the same card in the app once they leave? (ie: press Home button twice or click on link that exits app to Safari)

Thanks bunches!

-Tester2
Dixie
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1336
Joined: Sun Jul 12, 2009 10:53 am

Re: Return to same card in app

Post by Dixie »

Tester 2...

I have attached a stack that contains 3 cards... If you leave the stack say on card 2, when you open the stack again you will be taken to card 2 , or whichever card you chose to leave the stack.

Scripts are in the stack script...

hope it helps...

Dixie
Attachments
whichOne.livecode.zip
(1.87 KiB) Downloaded 361 times
Tester2
Posts: 102
Joined: Wed May 18, 2011 7:02 pm

Re: Return to same card in app

Post by Tester2 »

Dixie,

Thanks so much for the sample file! ;)

I'm currently dissecting it, and came across a question.

You use the following in the stack script:

put URL "file:trackCard" into whichCard
go card whichCard

Is "whichCard" a custom property or field...and how is it defined?

Thanks so much!

-Tester2
Jellicle
Posts: 453
Joined: Thu Feb 24, 2011 11:07 am

Re: Return to same card in app

Post by Jellicle »

It's simply a variable. You know about variables, don't you?
14" MacBook Pro
Former LiveCode developer.
Now recovering.
Dixie
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1336
Joined: Sun Jul 12, 2009 10:53 am

Re: Return to same card in app

Post by Dixie »

tester2..

Code: Select all

      if there is a file "trackCard" then
         put URL "file:trackCard" into whichCard
         go card whichCard
      end if
every time a user visits a card, the number of that card is written to the file 'trackCard'. (see the openCard handler). When the stack is restarted the number of the card that was last put into the file 'trackCard' is placed into a variable, which I called, whichCard...

Then the user is taken to that card with

Code: Select all

go card whichCard
be well,

Dixie
Tester2
Posts: 102
Joined: Wed May 18, 2011 7:02 pm

Re: Return to same card in app

Post by Tester2 »

Ahh...it makes sense now.

Is there a way that the file 'trackCard' gets reset?

Like, say I restart my phone...is there a way to tell this file to clear itself, so that the app opens as if it was the first time the user opened it?

Thanks.

-Tester2
Dixie
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1336
Joined: Sun Jul 12, 2009 10:53 am

Re: Return to same card in app

Post by Dixie »

Tester2...

There is no way to do this with liveCode as your 'app' lives in its own 'sandbox'...

Dixie
Post Reply