Page 1 of 1

user selects but selection is stored in memory.....

Posted: Sun Oct 20, 2013 12:50 pm
by chris25
user selects but selection is stored in memory..... Yes I know this seems advanced for me, but having designed a very simple little app that has no purpose other than to teach Me, I need to know just one thing: The user will click on a button, but the information associated with this button/choice needs to be stored temporarily while the user is taken to another button and has to make another choice again, then the two pieces of information/choices will lead the user to the desired outcome?

Please just tell me where I can read/watch/learn about the principles behind this type of scripting/action. I simply do not know the correct/accurate preambles to type into a search box ( in other words I have no idea what words to use to ask my own question)

Thankyou guys.

Re: user selects but selection is stored in memory.....

Posted: Mon Oct 21, 2013 7:03 pm
by jacque
This is typically done with a "script local variable." That's a variable that is declared at the top of an entire script, rather than inside a handler. When you declare a variable that way, every handler in the script can use its value. Other scripts can't, which is why it's said to be "local" to that particular script. See "local" in the dictionary.

You do it this way:

Code: Select all

local sMyAnswer

on storeValue -- first handler in the script
  put "this is a test" into sMyAnswer
end storeValue

on getValue -- second handler
  put sMyAnswer -- puts "this is a test" into the message box
end getValue
You can't put these handlers into either of your button scripts because the two buttons need to share the variable and they each have different scripts, so instead your mouseUp button handlers need to call these handlers from another script. In this case that third script should probably go in the card that has the two buttons. The script of the first button would be:

Code: Select all

on mouseUp
  storeValue
end mouseUp
And the second button:

Code: Select all

on mouseUp
  getValue
end mouseUp
You'll need to tinker with these handlers to avoid the hard-coded "this is a test" and use whatever value you want instead.

Re: user selects but selection is stored in memory.....

Posted: Mon Oct 21, 2013 7:17 pm
by chris25
Hallo Jacque, thankyou for this, it gives me plenty to work on. By the way, you don't know where I can find the link to that beginner's PDF? I have searched at least 8 different links and pages to find it, I can not remember where I originally downloaded it from, actually found it on scribd would you believe, but you have to pay after clicking their 'download for free' button...Mmm...

Re: user selects but selection is stored in memory.....

Posted: Mon Oct 21, 2013 7:29 pm
by Simon
Hi Chris,
Here is a great collection of all things liveCode:
http://livecodesupersite.com/tutorials.html

Don't know about a beginners pdf.

Simon

Re: user selects but selection is stored in memory.....

Posted: Mon Oct 21, 2013 7:45 pm
by chris25
Hi Simon, would you believe it, not 10 minutes ago I found this very site as I was tinkering around for the PDF, must be somewhere...

Re: user selects but selection is stored in memory.....

Posted: Mon Oct 21, 2013 8:22 pm
by jacque
chris25 wrote:Hallo Jacque, thankyou for this, it gives me plenty to work on. By the way, you don't know where I can find the link to that beginner's PDF?
I'm not sure what PDF you mean. Do you mean the User Guide? That's in the Resources stack (the icon is in the toolbar.)

Re: user selects but selection is stored in memory.....

Posted: Mon Oct 21, 2013 9:01 pm
by chris25
Hi, just found it. It was in the resource centre as you said. But in the user guide section, bottom right corner, says launch PDF. Finally.

Re: user selects but selection is stored in memory.....

Posted: Thu Oct 24, 2013 5:13 pm
by chris25
Ok, I am having trouble finding Keywords. I was looking for "storevalue and "getvalue". I looked in the keyword list on revdocs / runrev, not there. I looked in the beginners pdf, not there, I looked on tutorials and typed in the words, they did not appear. They are not in the dictionary in LC IDE; So Maybe someone could be kind enough to point me to a dictionary of keywords please?

Thanks
Chris

Re: user selects but selection is stored in memory.....

Posted: Thu Oct 24, 2013 5:19 pm
by jacque
Neither of those words are keywords, which is why you can't find them. They must be variables the author set up in a handler.

When searching for keywords, you only need to look in the dictionary. If it isn't there, it's a user-defined variable.

Re: user selects but selection is stored in memory.....

Posted: Thu Oct 24, 2013 6:24 pm
by chris25
OH...kay. still getting used to this......thankyou.

Re: user selects but selection is stored in memory.....

Posted: Thu Oct 24, 2013 7:04 pm
by SparkOut
pssst Jacque... they are handler names you made in your example up near the top of the thread ;-)

Re: user selects but selection is stored in memory.....

Posted: Thu Oct 24, 2013 11:27 pm
by jacque
SparkOut wrote:pssst Jacque... they are handler names you made in your example up near the top of the thread ;-)
LOL! But...but...that was THREE days ago!

Re: user selects but selection is stored in memory.....

Posted: Fri Oct 25, 2013 9:30 am
by chris25

:lol: ....I don't want to know....