Page 1 of 1

Replacing a number with an asterisk.

Posted: Mon Feb 25, 2008 9:55 pm
by gillilandd
I am authoring a program for my students and want to have them stop, show me their work, and I type in a code (0051) before they can proceed on.
Here is what I have:

on mouseUp
ask "Now that you have your stamp, have your teacher type in the code to continue."
put it into rightcode
if rightcode is "0051" then go next
if rightcode is not "0051" then answer "No - you cannot proceed on until you type in the correct code!"
end mouseUp


The script is easy but I don't want the code appearing on screen - instead I want to replace each number with an asterisk so the students cannot see what I am typing.
I've searched the forum and cannot find anything that will help me do this. Anyone have any suggestions?
Thanks,
Doug Gilliland

Posted: Mon Feb 25, 2008 10:17 pm
by BvG
The simplest way is:

Code: Select all

ask password "enter the secret number"
if it <> "" and it = "0051" then
  --do your thing here
end if
More complex is using the keydown message because you need to make it all yourself.

Posted: Mon Feb 25, 2008 10:24 pm
by Klaus
Hi gillilandd,

try this:

Code: Select all

on mouseUp 
  ask password CLEAR "Now that you have your stamp, have your teacher type in the code to continue." 
  ## Needs to be CLEAR or you cannot check it afterwards, see the docs!
  put it into rightcode 
  if rightcode = "0051" then 
     go next 
  else
   answer "No - you cannot proceed on until you type in the correct code!" 
 end if
end mouseUp



Best

Klaus

Posted: Mon Feb 25, 2008 11:10 pm
by BvG
Damn, forgot the clear, that's what I get for suggesting stuff i haven't used since years :(

Posted: Mon Feb 25, 2008 11:36 pm
by gillilandd
Thanks to you both - the script Klaus posted works great.
Doug Gilliland

Posted: Tue Feb 26, 2008 7:01 pm
by Mark
Hi,

I created a little stack with a password field, which you can copy into your own project. Go to the Economy-x-Talk homepage (see below), click on the Developer link on the left and find the Password Fields stack the bottom of that page.

Best,

Mark