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

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, asayd

Post Reply
chris25
Posts: 354
Joined: Tue Oct 08, 2013 9:32 pm

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

Post by chris25 » Sun Oct 20, 2013 12:50 pm

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.

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7210
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

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

Post by jacque » Mon Oct 21, 2013 7:03 pm

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.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

chris25
Posts: 354
Joined: Tue Oct 08, 2013 9:32 pm

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

Post by chris25 » Mon Oct 21, 2013 7:17 pm

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...

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am
Location: Palo Alto

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

Post by Simon » Mon Oct 21, 2013 7:29 pm

Hi Chris,
Here is a great collection of all things liveCode:
http://livecodesupersite.com/tutorials.html

Don't know about a beginners pdf.

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

chris25
Posts: 354
Joined: Tue Oct 08, 2013 9:32 pm

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

Post by chris25 » Mon Oct 21, 2013 7:45 pm

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...

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7210
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

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

Post by jacque » Mon Oct 21, 2013 8:22 pm

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.)
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

chris25
Posts: 354
Joined: Tue Oct 08, 2013 9:32 pm

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

Post by chris25 » Mon Oct 21, 2013 9:01 pm

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.

chris25
Posts: 354
Joined: Tue Oct 08, 2013 9:32 pm

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

Post by chris25 » Thu Oct 24, 2013 5:13 pm

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

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7210
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

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

Post by jacque » Thu Oct 24, 2013 5:19 pm

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.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

chris25
Posts: 354
Joined: Tue Oct 08, 2013 9:32 pm

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

Post by chris25 » Thu Oct 24, 2013 6:24 pm

OH...kay. still getting used to this......thankyou.

SparkOut
Posts: 2834
Joined: Sun Sep 23, 2007 4:58 pm

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

Post by SparkOut » Thu Oct 24, 2013 7:04 pm

pssst Jacque... they are handler names you made in your example up near the top of the thread ;-)

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7210
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

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

Post by jacque » Thu Oct 24, 2013 11:27 pm

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!
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

chris25
Posts: 354
Joined: Tue Oct 08, 2013 9:32 pm

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

Post by chris25 » Fri Oct 25, 2013 9:30 am


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

Post Reply

Return to “LiveCode University”