Take input from a field and assign it to a variable
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
Take input from a field and assign it to a variable
I know this should be easy. Dead easy. But apparently it isn't Head-Cold easy.
Upon the click of the first button:
I show a word in a field to the children.
The word disappears.
The next field shows up with a blinking cursor.
The children write the word they saw.
How to I assign that to a variable (in script for the field "answer") ?
"on return put it into tAnswer" didn't work
With thanks,
Bantymom
Upon the click of the first button:
I show a word in a field to the children.
The word disappears.
The next field shows up with a blinking cursor.
The children write the word they saw.
How to I assign that to a variable (in script for the field "answer") ?
"on return put it into tAnswer" didn't work
With thanks,
Bantymom
2nd-grade Teacher, Poultry Fancier, Scottish Country Dancer
and Perpetual Beginner
and Perpetual Beginner
Re: Take input from a field and assign it to a variable
Hi Bantymom,
you might also want to look up "enterinfield" in the dictionary
regards
Bernd
Code: Select all
on returninfield
put me into tAnswer
-- put the text of me into tAnswer -- alternatively
-- select empty -- if you want to deselect the field after a return
end returninfield
regards
Bernd
Re: Take input from a field and assign it to a variable
Thank you,
After writing my post, I did find "returninfield in the dictionary, but still couldn't get it to work, as I was trying everything other than "me," so I am very grateful for your reply.
However, I'm afraid I am still doing something wrong. The compiler says there are no errors, but I don't think the word is getting into the variable. I asked for it as an answer, and got a blank.
I looked at other examples in the tutorials, samples, and the user's guide and saw that "answer tVariable" should produce whatever is in the variable, and it worked when I tried those scripts, but I am getting a blank with this one, so it seems to me that neither "me" or "text of me" (I tried both) is getting into tAnswer.
I tried to include the stack in case it was needed, but I don't know how to do that.
After writing my post, I did find "returninfield in the dictionary, but still couldn't get it to work, as I was trying everything other than "me," so I am very grateful for your reply.
However, I'm afraid I am still doing something wrong. The compiler says there are no errors, but I don't think the word is getting into the variable. I asked for it as an answer, and got a blank.
Code: Select all
on returnInField
put the text of me into tAnswer
select empty
answer tAnswer
end returnInField
I tried to include the stack in case it was needed, but I don't know how to do that.
2nd-grade Teacher, Poultry Fancier, Scottish Country Dancer
and Perpetual Beginner
and Perpetual Beginner
Re: Take input from a field and assign it to a variable
Bantymom,
did you put the script into the field that the text is in? I tried your script and it showed tAnswer in the dialog box.
If you want to put the script lets say into the script of the card then you would say
The Target has the reference to the field (e.g. field "xyz"). This would work for many fields. The fields dont have any script.
If you want to upload a stack you have to zip (compress) it first. How you do that depends on your operating system.
regards
Bernd
did you put the script into the field that the text is in? I tried your script and it showed tAnswer in the dialog box.
If you want to put the script lets say into the script of the card then you would say
Code: Select all
on returnInField
put the target into tTarget
put the text of tTarget into tAnswer
select empty
answer tAnswer
end returnInField
If you want to upload a stack you have to zip (compress) it first. How you do that depends on your operating system.
regards
Bernd
Re: Take input from a field and assign it to a variable
I thought I was working on the script for the field. Looking at the scrip editor, it says field "answer." Now, this is my very very first attempt at Rev Media, so I must be missing something very obvious, so while I could just plug in the new script you gave me, I think I really need to know where I went wrong, and thus improve my understanding.
I have zipped the file and have attached it, if you have the time to give it a look-see.
It is possible that the picture under everything isn't there, because I don't know how to import it properly yet, but that can wait. Just know that there is supposed to be a picture in one of those image boxes under it all. From the ground up, it goes:
Image
button "cover"
field "word"
field "answer"
With thanks,
Banty
I have zipped the file and have attached it, if you have the time to give it a look-see.
It is possible that the picture under everything isn't there, because I don't know how to import it properly yet, but that can wait. Just know that there is supposed to be a picture in one of those image boxes under it all. From the ground up, it goes:
Image
button "cover"
field "word"
field "answer"
With thanks,
Banty
- Attachments
-
- WordGameTester.rev.zip
- (1.38 KiB) Downloaded 318 times
2nd-grade Teacher, Poultry Fancier, Scottish Country Dancer
and Perpetual Beginner
and Perpetual Beginner
Re: Take input from a field and assign it to a variable
Hello (and greetings) Bantymom,
I think I may have tracked down the difficulty, and it’s quite interesting. In your button “Reset Test” you have the script... by which you mean to clear out the fields “answer” and “word” so you can start the sequence of events afresh. The problem is the word “null”- it has a specific meaning in Revolution, and is different from “empty”. I tried:
... which works correctly.
From what I can gather reading the Dictionary about “null” it stands for a constant that you can’t actually type on the keyboard. The button “Reset Test” puts the null character into field “answer”, then when you click on button “Cover”, its script is:... the “click” puts the insertion point (the flashing cursor) after the “null” character, so say if you typed “hello” what is actually in the field is “[null character]hello” rather than just “hello”. To be honest, I haven’t used or encountered “null” before, but given the context of wanting to clear something (in this case fields “answer” and “word”) of any contents, “empty” is the way to do it. I hope that is of some use.
Regards,
Michael
I think I may have tracked down the difficulty, and it’s quite interesting. In your button “Reset Test” you have the script
Code: Select all
on mouseUp:
put null into field "answer"
hide field "answer"
put null into field "word"
hide field "word"
on mouseUp
Code: Select all
on mouseUp
put empty into field "answer"
hide field "answer"
put empty into field "word"
hide field "word"
on mouseUp
From what I can gather reading the Dictionary about “null” it stands for a constant that you can’t actually type on the keyboard. The button “Reset Test” puts the null character into field “answer”, then when you click on button “Cover”, its script is:
Code: Select all
on mouseUp
put "testing" into tWord
put tWord into field "word"
show field "word"
wait 2 seconds
hide field "word"
show field "answer"
click at the loc of field "answer"
end mouseUp
Regards,
Michael
Re: Take input from a field and assign it to a variable
Michael,
Thank you for the welcome and the help! You did such a nice thorough job of hunting down my problem. And it was very interesting to learn how "null" works. Of course, that was exactly the problem.
When I had begun, I hadn't yet found the dictionary, and so was guessing at what words would work for basic things. In trying to empty those fields, I was trying any number of ideas that seemed logical to me to empty it, including "empty field" *chuckles* (so you see I was on the right track), but when taking things out of the field didn't work, I started trying to put "nothing" into the field. Right idea, wrong word choice. Null just came to mind first, and since it worked, I never gave it a second thought. Once I found the dictionary, I started looking things up, but didn't think to go back to check "null," as it was working, though working too well it seems! So, I've fixed it and am ready to go on to the if-then parts.
Another question:
While reading around other questions in the forum (to try to keep asking redundant questions to a minimum), I came across this:
on keyUp theKey
if theKey is m then...
and:
on keyup tKey
if tKey = "K" then
It looks to me that "theKey" and especially "tKey" are variables, and that "put me into tKey" wasn't necessary in that instance. Curious, I tried a similar thing:
on returnInField tField
put field "answer" into tAnswer
select empty
answer "tField is " & tField & "and tAnswer is " & tAnswer
end returnInField
I got nothing for tField, and I am wondering why ("tField is and tAnswer is yes" is what was returned)
I thought that perhaps instead of putting in the student answer, it might put in the name of the field as it put the name of the key into tKey, but instead it returned nothing at all for tField, and I am wondering why.
These questions might seem silly, but the answers will improve my understanding of workings of RevMedia's mind. I do much better when I understand why something works instead of just memorizing the algorithms.
Another thought: In trying to streamline my stack, I am thinking of going to only one field, having the stack put in the word, then emptying the field after 2 seconds, making it available for the answer after that. It might seem unnecessary, as it is only one more field, but as there will eventually be 16-20 pieces to the puzzle, it means 16-20 fewer fields on each card. Does anyone have any thoughts or warnings about this before I go that route?
Thank you for the welcome and the help! You did such a nice thorough job of hunting down my problem. And it was very interesting to learn how "null" works. Of course, that was exactly the problem.
When I had begun, I hadn't yet found the dictionary, and so was guessing at what words would work for basic things. In trying to empty those fields, I was trying any number of ideas that seemed logical to me to empty it, including "empty field" *chuckles* (so you see I was on the right track), but when taking things out of the field didn't work, I started trying to put "nothing" into the field. Right idea, wrong word choice. Null just came to mind first, and since it worked, I never gave it a second thought. Once I found the dictionary, I started looking things up, but didn't think to go back to check "null," as it was working, though working too well it seems! So, I've fixed it and am ready to go on to the if-then parts.
Another question:
While reading around other questions in the forum (to try to keep asking redundant questions to a minimum), I came across this:
on keyUp theKey
if theKey is m then...
and:
on keyup tKey
if tKey = "K" then
It looks to me that "theKey" and especially "tKey" are variables, and that "put me into tKey" wasn't necessary in that instance. Curious, I tried a similar thing:
on returnInField tField
put field "answer" into tAnswer
select empty
answer "tField is " & tField & "and tAnswer is " & tAnswer
end returnInField
I got nothing for tField, and I am wondering why ("tField is and tAnswer is yes" is what was returned)
I thought that perhaps instead of putting in the student answer, it might put in the name of the field as it put the name of the key into tKey, but instead it returned nothing at all for tField, and I am wondering why.
These questions might seem silly, but the answers will improve my understanding of workings of RevMedia's mind. I do much better when I understand why something works instead of just memorizing the algorithms.
Another thought: In trying to streamline my stack, I am thinking of going to only one field, having the stack put in the word, then emptying the field after 2 seconds, making it available for the answer after that. It might seem unnecessary, as it is only one more field, but as there will eventually be 16-20 pieces to the puzzle, it means 16-20 fewer fields on each card. Does anyone have any thoughts or warnings about this before I go that route?
2nd-grade Teacher, Poultry Fancier, Scottish Country Dancer
and Perpetual Beginner
and Perpetual Beginner
Re: Take input from a field and assign it to a variable
Bantymom,
The answer is fairly simple. An arbitrary key triggers the keyUp message, but when the keyUp handler runs, it isn't clear which key triggered the message, unless an additional parameter is passed. Only the return key can trigger the returnInField message, which means that an additional parameter to indicate the key is unnecessary. This way of thinking should answer almost all your questions in this category.
Now, how do you find out which object received the message first? As a rule, the object that received the message first is passed along the entire message hierarchy in a special property called target. In every handler, you can always use the target to determine which object received the message first. For example, whenever you type return, every returnInField handler will allow you to retrieve the target.
In these examples, the target may refer to the same object. The handler at card level could be triggered by any editable field, which means that it could make sense to check which object received the message first. In this case, I do this by checking the short name of the target.
Best regards,
Mark
The answer is fairly simple. An arbitrary key triggers the keyUp message, but when the keyUp handler runs, it isn't clear which key triggered the message, unless an additional parameter is passed. Only the return key can trigger the returnInField message, which means that an additional parameter to indicate the key is unnecessary. This way of thinking should answer almost all your questions in this category.
Now, how do you find out which object received the message first? As a rule, the object that received the message first is passed along the entire message hierarchy in a special property called target. In every handler, you can always use the target to determine which object received the message first. For example, whenever you type return, every returnInField handler will allow you to retrieve the target.
Code: Select all
-- field
on returnInField
-- the following line is always true
put ( the name of me is the name of the target)
pass returnInField
end returnInField
-- card
on returnInField
if short name of the target is "Last Field" then
send "mouseUp" to btn "Save"
else pass returnInField
end returnInField
Best regards,
Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
Re: Take input from a field and assign it to a variable
BantyMom,
BUT back to your question: you can not use this notation since returnInField does not pass a parameter. You have to put the text of the field into the variable. The dictionary lists the terms and what parameter come with them if any.
You might want to have a look at those:
In the Help Menu the second item is "Resource Center" have a look at those examples.
also
http://lessons.runrev.com/
A lot of examples.
They help to get aquainted with RevTalk.
regards
Bernd
theKey or tKey are in fact variables. But they are filled by the message KeyUp which has a parameter that is sent along which the coder puts into this variable. You can name the variable whatever you want as long as it is not a reserved word used by Rev. It helps to prepend varables with a letter that indicates what type of varible it is. "t" is often used to designate a local varible. "s" to mark a script local variable, that is a variable that any handler in a script can access and that is persistent until you close the stack or recompile the script. This type of variable is very convenient and I use it instead of the global variables as in Hypercard. Global variables are often prepended, you guessed it, by a "g". I find global variables are difficult to maintain since any script and any open stack can put something into it. So at times if you tend to use the same name for global variables this can get confusing.It looks to me that "theKey" and especially "tKey" are variables, and that "put me into tKey" wasn't necessary in that instance. So, in my situation, can I write it in a similar way?
BUT back to your question: you can not use this notation since returnInField does not pass a parameter. You have to put the text of the field into the variable. The dictionary lists the terms and what parameter come with them if any.
You might want to have a look at those:
In the Help Menu the second item is "Resource Center" have a look at those examples.
also
http://lessons.runrev.com/
A lot of examples.
They help to get aquainted with RevTalk.
regards
Bernd
Re: Take input from a field and assign it to a variable
Thank you all.
The simple answer made perfect sense, and I am also going to investigate stack variables. Yes, I did read that part earlier in the tutorial/lesson/or-whatever-it-was on keeping things neat and tidy by putting t, l, g, and now s in front of my variables. I still don't completely get the differences between all of them, but no need to answer me there. It's a matter of using them for me. I can read and understand what I am reading, but until I use something and screw it up, I don't really understand it.
I apologize for asking so many questions that seem to be answered in the many resources that are provided. I did begin by trying to go through them in order, though going from writing a stack saying "Hello World" to getting and filtering files was a little overwhelming for me. I have found links to other lists of lessons and resources and am slowly working my way through them one at a time, trying to discover which apply to my project. I do go to the dictionary and resource center first every time I hit a snag, I then come here and search for terms I think apply to my problem. Sometimes I just can't find the answer.
I wish to thank you for your patience. I feel rather guilty asking for help. I will try harder.
The simple answer made perfect sense, and I am also going to investigate stack variables. Yes, I did read that part earlier in the tutorial/lesson/or-whatever-it-was on keeping things neat and tidy by putting t, l, g, and now s in front of my variables. I still don't completely get the differences between all of them, but no need to answer me there. It's a matter of using them for me. I can read and understand what I am reading, but until I use something and screw it up, I don't really understand it.
I apologize for asking so many questions that seem to be answered in the many resources that are provided. I did begin by trying to go through them in order, though going from writing a stack saying "Hello World" to getting and filtering files was a little overwhelming for me. I have found links to other lists of lessons and resources and am slowly working my way through them one at a time, trying to discover which apply to my project. I do go to the dictionary and resource center first every time I hit a snag, I then come here and search for terms I think apply to my problem. Sometimes I just can't find the answer.
I wish to thank you for your patience. I feel rather guilty asking for help. I will try harder.
2nd-grade Teacher, Poultry Fancier, Scottish Country Dancer
and Perpetual Beginner
and Perpetual Beginner
Re: Take input from a field and assign it to a variable
BantyMom,
Keep on asking even seemingly simple questions if you dont find an answer in the docs/lessons/tutorials. It was just that I wanted to mention them in case you did not find them. It took me quite a while to notice them.
It would be a shame if you would get stuck because of not asking, apparently you are up to something in providing these tools to your pupils.
kind regards
Bernd
No need to apologize. Everybody in this forum remembers, or should at least so, how it was when they started.I wish to thank you for your patience. I feel rather guilty asking for help. I will try harder.
Keep on asking even seemingly simple questions if you dont find an answer in the docs/lessons/tutorials. It was just that I wanted to mention them in case you did not find them. It took me quite a while to notice them.
It would be a shame if you would get stuck because of not asking, apparently you are up to something in providing these tools to your pupils.
kind regards
Bernd
Re: Take input from a field and assign it to a variable
Thanks
*feels better*
I am making this for my students, and for one in particular who, though already 7 years old, is working at a Kindergarten level and gets frustrated when working with the group. I want him to have something he can actually do for some of the time on the computer, that is engaging, and will help him feel more successful and build his confidence.
Yes, and I'm already stuck again, with a "show button" thing that won't show. (I've already posted it along with the stack)
*feels better*
I am making this for my students, and for one in particular who, though already 7 years old, is working at a Kindergarten level and gets frustrated when working with the group. I want him to have something he can actually do for some of the time on the computer, that is engaging, and will help him feel more successful and build his confidence.
Yes, and I'm already stuck again, with a "show button" thing that won't show. (I've already posted it along with the stack)
2nd-grade Teacher, Poultry Fancier, Scottish Country Dancer
and Perpetual Beginner
and Perpetual Beginner
Re: Take input from a field and assign it to a variable
Hi,
disabled students. If you want, i could help you to create this
stack, while you learn to be proficient in the revTalk language.
First, describe completely, from top to down, how this stack should work.
a) stack appareance (fixed size, resizable, full screen, kiosk mode?)
b) user interaction or user input (via keyboard or mouse, or both?)
c) user input will require a timer? (time limit to provide answers?)
d) feedback messages (visual, text or sounds?)
e) save output (automatically or user should save their sessions?)
f) Does your stack requires that users restore their sessions?
(restart where they left off the previous day)
Experienced developers could add many details that i left off
or do not remember in this moment.
Please, do not think that these are questions difficult to answer.
In fact, it's as simple as imagining that you are sitting in a chair behind your
students and you explain us (in detail) how they use the stack that you created
and how the stack respond to each of their keyboard or mouse clicks.
Have a nice day!
Al
Long time ago, i helped another teacher to create a stack for hisBantymom wrote: I am making this for my students, and for one in particular who, though already 7 years old, is working at a Kindergarten level and gets frustrated when working with the group. I want him to have something he can actually do for some of the time on the computer, that is engaging, and will help him feel more successful and build his confidence.
disabled students. If you want, i could help you to create this
stack, while you learn to be proficient in the revTalk language.
First, describe completely, from top to down, how this stack should work.
a) stack appareance (fixed size, resizable, full screen, kiosk mode?)
b) user interaction or user input (via keyboard or mouse, or both?)
c) user input will require a timer? (time limit to provide answers?)
d) feedback messages (visual, text or sounds?)
e) save output (automatically or user should save their sessions?)
f) Does your stack requires that users restore their sessions?
(restart where they left off the previous day)
Experienced developers could add many details that i left off
or do not remember in this moment.
Please, do not think that these are questions difficult to answer.
In fact, it's as simple as imagining that you are sitting in a chair behind your
students and you explain us (in detail) how they use the stack that you created
and how the stack respond to each of their keyboard or mouse clicks.

Have a nice day!

Al
Re: Take input from a field and assign it to a variable
Dear Al,
Thank you very much for your offer of help! I didn't mean to ignore your reply, but I have been very ill with stomach problems since last Thursday. I have never been so sick to my stomach in my life. Things finally let up on Sunday night when I finally got some sleep and I spent Monday and today recuperating and rehydrating.
I would appreciate your assistance, but think that perhaps here would not be the best place to answer those questions in detail, as it might be very long. Is there an email address you would feel comfortable sharing with me? Or, I can just answer them here, if no one else minds.
I don't think I would have any trouble answering those questions at all, except that I don't know what kiosk mode is. I will go look that one up.
Edit: It looks like a Kiosk application in intended to keep the users from messing with it and so turns off the menu bar and the browser bits? If so, yes, I've got kids who can't remember to bring their homework or write their own name, but who seem to have no trouble in getting out of the applications they start on and into everything else possible.
Cheers,
Bantymom
Thank you very much for your offer of help! I didn't mean to ignore your reply, but I have been very ill with stomach problems since last Thursday. I have never been so sick to my stomach in my life. Things finally let up on Sunday night when I finally got some sleep and I spent Monday and today recuperating and rehydrating.
I would appreciate your assistance, but think that perhaps here would not be the best place to answer those questions in detail, as it might be very long. Is there an email address you would feel comfortable sharing with me? Or, I can just answer them here, if no one else minds.
I don't think I would have any trouble answering those questions at all, except that I don't know what kiosk mode is. I will go look that one up.
Edit: It looks like a Kiosk application in intended to keep the users from messing with it and so turns off the menu bar and the browser bits? If so, yes, I've got kids who can't remember to bring their homework or write their own name, but who seem to have no trouble in getting out of the applications they start on and into everything else possible.
Cheers,
Bantymom
2nd-grade Teacher, Poultry Fancier, Scottish Country Dancer
and Perpetual Beginner
and Perpetual Beginner
Re: Take input from a field and assign it to a variable
Hi Bantymom,
Your stack would benefit of a public discussion.
"In multitude of counsellors there is safety"
Create a new message with the title of your stack
and attach a zipped copy of it, like you have
done in other threads.
After you have completed the basic functionality
working as expected, then you could add other
features that enhance the look and function.
By the way, In which Operating System will run your stack?
Mac OS X , Windows or Linux?
Have a nice day!
Al
Your stack would benefit of a public discussion.
"In multitude of counsellors there is safety"

Create a new message with the title of your stack
and attach a zipped copy of it, like you have
done in other threads.
After you have completed the basic functionality
working as expected, then you could add other
features that enhance the look and function.
By the way, In which Operating System will run your stack?
Mac OS X , Windows or Linux?
Have a nice day!
Al