Author Topic: Run card open script just once  (Read 2841 times)

Chandra

  • Newbie
  • *
  • Posts: 4
Run card open script just once
« on: October 01, 2011, 06:00:57 AM »
Hello
In my app on the home card there is some code to setup the card's controls and they need to run only ONCE. I cannot see a way to get them to run just once as they are executed every time my app returns back to the home card from another card. There must be some way to do this?
Chandra 

Malkom

  • Administrator
  • Sr. Member
  • *****
  • Posts: 287
Re: Run card open script just once
« Reply #1 on: October 01, 2011, 07:20:03 AM »
Hi Chandra

The MainCode - Startup section can help with this problem as code placed there is run before the Home Card starts. In  the Startup section place this code:-

Code: [Select]
@ declare flag and put 0 into it
Global homecardRan
Reset homecardRan



Your Home Card's open script can then check if this flag has been set to 1, if it is still 0 then it can execute the code. In your Home Card place this:-

Code: [Select]
Global homecardRan

if homecardRan=0 then
   @ execute your code


   @ set flag to 1
   Set homecardRan
endif

Malkom




I am sorry but I do not have time to answer questions by PM or email.
If you post your questions in this forum then it might help others.

 

anything