Force Card to reload every time it will be opened

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
Bosstone
Posts: 9
Joined: Wed Jan 08, 2020 9:55 pm

Force Card to reload every time it will be opened

Post by Bosstone » Mon Jan 13, 2020 12:21 pm

Hi,

I am working with Navigation Bar in my APP. How can I reload the card "Home" every time this card will be opened from stack?

I tried with on openstack and on opencard, but it will not reload

Reason for this: I want to show random exhibitors to the users...

Thank you very much,

Stefan

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

Re: Force Card to reload every time it will be opened

Post by Klaus » Mon Jan 13, 2020 12:32 pm

Hi Stefan,

when you navigate to a card its "pre-/opencard" messages are triggered!
What did you script so far and where did you put the script(s)?


Best

Klaus

Bosstone
Posts: 9
Joined: Wed Jan 08, 2020 9:55 pm

Re: Force Card to reload every time it will be opened

Post by Bosstone » Tue Jan 14, 2020 8:44 pm

Hi Klaus,

sorry, I am afraid, but I don't get you. I have put the script

Code: Select all

on opencard
   send "loadPreferences" to this stack in 10
end opencard

command loadPreferences
   put readPreferencesToXMLTree() into tTree
   if tTree is empty then
      exit loadPreferences
   end if 
   
end loadPreferences

private function readPreferencesToXMLTree
   
   put random(4) + 1 into rNumber
   
   put url("URLTO/getexhibdata.php?messe=" & rNumber) into tXML
   put revXMLCreateTree(tXML, false, true, false) into tXMLTreeID
   put revXMLRootNode(tXMLTreeID) into tRoot -- "messen"
   put revXMLFirstChild(tXMLTreeID,tRoot) into tResponse -- "messe"
   repeat while "xmlerr" is not in tResponse
      put revXMLNodeContents(tXMLTreeID, tResponse & "/id") into tID
      put revXMLNodeContents(tXMLTreeID, tResponse & "/messe_1") into aRecords[tID]["messe_1"]
      put revXMLNodeContents(tXMLTreeID, tResponse & "/vimeo") into aRecords[tID]["vimeo"]
      put revXMLNextSibling(tXMLTreeID,tResponse) into tResponse
      if tResponse is empty then
         exit repeat
      end if
   end repeat
   put aRecords[tID]["vimeo"] into tVideoURL
   set the url of widget "Browser" to tVideoURL
   put aRecords[tID]["messe_1"] into field "Field"
   
end readPreferencesToXMLTree
to my widget "Browser". I tried first on the stack itself, but got an error message as "Field" could not be found on the other cards...

All the best,

Stefan

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

Re: Force Card to reload every time it will be opened

Post by Klaus » Tue Jan 14, 2020 9:01 pm

Does that help:

Code: Select all

...
put aRecords[tID]["messe_1"] into field "Field" OF CARD "the one with the field" ## OF STACK "If in another stack"
## :-)
...

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”