Right answers in Field
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
Right answers in Field
Hi everyone,
I'm new both to Revolution and the forums. I find this program amazingly powerful, but a lot of scripting is necessary for almost every task, and I'm not an expert at it (=hopeless).
I'm trying to develop an application in which my undergraduate students need to press a button in order to hear a word spelt in Spanish (this is easy), and then type it in a text field. How can I script this to show their answers are correct?
I've been using Mediachance's Multimedia Builder so far, and scripting this was quite simple and straightforward, but I have to admit that I'm completely lost as regards revStudio.
Thanks in advance.
I'm new both to Revolution and the forums. I find this program amazingly powerful, but a lot of scripting is necessary for almost every task, and I'm not an expert at it (=hopeless).
I'm trying to develop an application in which my undergraduate students need to press a button in order to hear a word spelt in Spanish (this is easy), and then type it in a text field. How can I script this to show their answers are correct?
I've been using Mediachance's Multimedia Builder so far, and scripting this was quite simple and straightforward, but I have to admit that I'm completely lost as regards revStudio.
Thanks in advance.
-
- Posts: 90
- Joined: Mon Jan 18, 2010 10:53 am
Re: Right answers in Field
All these people here are fantastic, I bet your script shows up real fast. In the meantime I'm new to programming myself, but try looking at three commands in the dictionary- "if" , "then", "else" for starters till they chime in.
Re: Right answers in Field
Hi gcamina,
Welcome
You can use this script to compare two string. It check the accents of each letter
All the best
Jean-Marc
Welcome
You can use this script to compare two string. It check the accents of each letter
Code: Select all
on VerifAnswer
put fld "TheQuestion" into text1
put fld "TheAnswer" into text2
if CompareText(text1,text2) = empty then
FaitJuste
else
FaitFaux
end if
end VerifAnswer
on FaitJuste
Answer "Your answer is true" --or what do you want
end FaitJuste
on FaitJuste
beep
Answer "Your answer is false" --or what do you want
end FaitJuste
function CompareText pText1,pText2
put empty into rCompareText
put the num of chars of pText1 into nbC1
put the num of chars of pText2 into nbC2
if nbC1 <> nbC2 then
put "PasMemeNombre" into rCompareText
else
--•• check the accents of letters by the chartonum function (t)
repeat with i = 1 to nbc1
put chartonum(char i of pText1) into CTN1 --•• the num ASCII of letter i of pText1
put chartonum(char i of pText2) into CTN2 --•• the num ASCII of letter i of pText2
if CTN1 <> CTN2 then
put i into rCompareText
end if
end repeat
end if
return rCompareText
end CompareText
Jean-Marc
https://alternatic.ch
Re: Right answers in Field
Hola gcamina,
for the start you could use this simple script.
Script of the button that checks the users input:
You get the picture
Best from germany
Klaus
for the start you could use this simple script.
Script of the button that checks the users input:
Code: Select all
on mouseup
put fld "user answer" into tAnswer
## Presumed you have stored the answer in another field:
put fld "the correct answer" into tCorrectAnswer
## Now a "quick and dirty" comparison :-)
if tAnswer = tCorrectAnswer then
## answer "This is correct."
else
## answer "Nada! Try again!"
end if
end mouseup

Best from germany
Klaus
Re: Right answers in Field
Wow! Quick answers and both look very interesting!
Jean-Marc, Klaus, thanks for your time. I'm enjoying the not very good weather in County Cork (Ireland) at the moment, but on Monday I'm heading back home and will check your code in my project.
I'll probably have plenty more questions in the near future. I hope I can still count on you. I'm really amazed at how many things you can do with revStudio.
Regards,
Gonzalo
Jean-Marc, Klaus, thanks for your time. I'm enjoying the not very good weather in County Cork (Ireland) at the moment, but on Monday I'm heading back home and will check your code in my project.
I'll probably have plenty more questions in the near future. I hope I can still count on you. I'm really amazed at how many things you can do with revStudio.
Regards,
Gonzalo
Re: Right answers in Field
Mikeinhawaii, you're absolutely right.
It's a good idea, but I'd also like to see those commands in context within a few sample projects. Those lists do not say much to absolute beginners.
Regards
Gonzalo
It's a good idea, but I'd also like to see those commands in context within a few sample projects. Those lists do not say much to absolute beginners.
Regards
Gonzalo
Re: Right answers in Field
Hi Gonzalo,
First, i'm sorry for my poor english
You can see more exemples on revOnLine
Good luck
Jean-Marc
First, i'm sorry for my poor english
You can see more exemples on revOnLine
Good luck
Jean-Marc
https://alternatic.ch
Re: Right answers in Field
Hi, I'm back in cold and rainy Northern Ireland. Nothing like an unwelcoming return home to eagerly try out your solutions for my query. Klaus's works fine, but there must be something wrong with Jean-Marc's (or with me), because it simply doesn't. I've spotted a typo in the code. Where Jean-Marc uses his second "on FaitJuste" I suppose he really means "on FaitFaux". Anyway, it doesn't work even with this thing corrected for some reason that escapes my understanding (very little understanding, that may be the problem).
By the way, Jean-Marc, your written English is good enough and easily understandable (I'd like to say the same thing about some of my native speakers at university), so no worries about that and thank you again for your help.
I think I'm gonna buy the full version of revStudio, because I loooove this program. I hope I can be of some help to others in the future. Until then, I'll need all the examples and advice in this world.
Gonzalo
By the way, Jean-Marc, your written English is good enough and easily understandable (I'd like to say the same thing about some of my native speakers at university), so no worries about that and thank you again for your help.
I think I'm gonna buy the full version of revStudio, because I loooove this program. I hope I can be of some help to others in the future. Until then, I'll need all the examples and advice in this world.
Gonzalo
Re: Right answers in Field
Gonzalo,
Here's Jean-Marc's code again. This version works fine for me (although I don't understand why one would do it this way: it seems a bit complex for this simple task).
Best regards,
Mark
Here's Jean-Marc's code again. This version works fine for me (although I don't understand why one would do it this way: it seems a bit complex for this simple task).
Code: Select all
on mouseUp
VerifAnswer
end mouseUp
on VerifAnswer
put fld "TheQuestion" into text1
put fld "TheAnswer" into text2
if CompareText(text1,text2) = empty then
FaitJuste
else
FaitFaux
end if
end VerifAnswer
on FaitJuste
Answer "Your answer is true" --or what do you want
end FaitJuste
on FaitFaux
beep
Answer "Your answer is false" --or what do you want
end FaitFaux
function CompareText pText1,pText2
put empty into rCompareText
put the num of chars of pText1 into nbC1
put the num of chars of pText2 into nbC2
if nbC1 <> nbC2 then
put "PasMemeNombre" into rCompareText
else
--•• check the accents of letters by the chartonum function (t)
repeat with i = 1 to nbc1
put chartonum(char i of pText1) into CTN1 --•• the num ASCII of letter i of pText1
put chartonum(char i of pText2) into CTN2 --•• the num ASCII of letter i of pText2
if CTN1 <> CTN2 then
put i into rCompareText
end if
end repeat
end if
return rCompareText
end CompareText
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: Right answers in Field
Mark,
Thanks for your revision of Jean-Marc's code. I agree it's somewhat complex, so in the end I applied Klaus's solution and it worked fine, methinks.
For starters I've made up two exercises for my beginners in Spanish, in which (a) they click on buttons and hear the different letters of the alphabet, see how they're pronounced with pop-up labels, and then (b) they listen to 10 words spelt in Spanish (slowly, of course, I'm too nice to them), while they try to put down what they hear, and finally they can check their answers with "?" buttons, where I've used Klaus's wisdom. The result is incredibly good for a total beginner like me.
Pity I have to actually work, because I could spend days "researching" on this program
. It's highly addictive. I'll be around with more questions, I'm afraid.
Regards
Thanks for your revision of Jean-Marc's code. I agree it's somewhat complex, so in the end I applied Klaus's solution and it worked fine, methinks.
For starters I've made up two exercises for my beginners in Spanish, in which (a) they click on buttons and hear the different letters of the alphabet, see how they're pronounced with pop-up labels, and then (b) they listen to 10 words spelt in Spanish (slowly, of course, I'm too nice to them), while they try to put down what they hear, and finally they can check their answers with "?" buttons, where I've used Klaus's wisdom. The result is incredibly good for a total beginner like me.
Pity I have to actually work, because I could spend days "researching" on this program

Regards
Re: Right answers in Field
Hi All,
The comparetext function is for letters with accent.
Depend what you want. In revtalk "ñ" = "n" or "é" = "e"
Best
Jean-Marc
The comparetext function is for letters with accent.
Depend what you want. In revtalk "ñ" = "n" or "é" = "e"
Best
Jean-Marc
https://alternatic.ch
Re: Right answers in Field
Hi Jean-Marc,
I'll definitely use your CompareText function as well, thanks. As you know, "ñ" and accented letters are something you cannot do without in Spanish.
Regards,
Gonzalo
I'll definitely use your CompareText function as well, thanks. As you know, "ñ" and accented letters are something you cannot do without in Spanish.
Regards,
Gonzalo
Re: Right answers in Field
Hi,
In RunRev 4.0, I enter
and get "false".
Marc's compareText function only returns the number of the last unequal characters. Not only does this function seem unnecessary to me, it also could be written much more efficiently. If you want to know the last characters that are different:
Best,
Mark
In RunRev 4.0, I enter
Code: Select all
put "eeñ"="een"
Marc's compareText function only returns the number of the last unequal characters. Not only does this function seem unnecessary to me, it also could be written much more efficiently. If you want to know the last characters that are different:
Code: Select all
function compareText theData1,theData2
repeat with x = max(length(theData1),length(theData2)) down to 1
if char x of theData1 is not char x of theData2 then return x
end repeat
return 0
end compareText
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: Right answers in Field
OUPS !
I'm sorry, Mark is right
but
if the casesensitive = false
"f" = "F" return true
Best
Jean-Marc
I'm sorry, Mark is right
but
if the casesensitive = false
"f" = "F" return true
Best
Jean-Marc
https://alternatic.ch