Page 1 of 1

Delete content of a Text entry field and recover it in next

Posted: Tue Sep 15, 2009 11:13 pm
by mtecedor
Hi All,

I am new in Revolution and kind of struggling with very basic stuff.

I am trying to program a very basic application. In the first card the user has to type his/her name and press Enter.
The enter button takes him/her to the next card, in which (s)he is welcome by name.

My problems are:
1. I am not able to recover the user's name in the next card.
2. I am not able to delete the content of the text entry field, so when I reopen the stack I always find the last name I wrote.

My script looks like this:

on mouseEnter
set lockcursor to true
set cursor to hand
end mouseEnter

on mouseLeave
set lockcursor to false
set cursor to arrow
end mouseLeave

on mouseDown theButton --go to next page--
if theButton is 1 then go to card "2"
put "Hello," & field "name" into field "welcome"
set the visible of field "welcome" to true
end mouseDown

Any suggestions?

Posted: Wed Sep 16, 2009 6:08 am
by acidjazz
Hi mtecedor,

Couple of things. First, it looks like you're trying to write one long script that I'm guessing you placed in the stack. Generally you place snippets of code into the objects that use them, that way you don't have to check by saying "if theButton is 1 ..." You can simply put this into the script for Button 1, and when its clicked it'll do its thing:

Code: Select all

on mouseUp
   put "Hello"&&field "name" into field "welcome" of card 2
   go card 2
end mouseUp
Notice that it's "mouseup" not "mousedown" and you don't need "theButton." Notice also that if you're referring to a field that's not on the same card as your script, you have to tell runrev where that field actually is (i.e., "of card 2)". Finally, to clear a text field just use this in the script of Card 1 :

Code: Select all

On PreOpenCard
   put empty into field "name"
End PreOpenCard
I'm sure others will have suggestions, but this will get you a little further along.

Good Luck!
AcidJazz

Re: Delete content of a Text entry field and recover it in n

Posted: Wed Sep 16, 2009 8:31 am
by Klaus
Hi mtecedor,
mtecedor wrote:...

Code: Select all

on mouseDown theButton --go to next page--
   if theButton is 1 then go to card "2"

## NOW you are already on card 2 and obivously there is NO field "name" on this cd 2!
## IF ther is also a field "Name" on card 2 the content maybe different than on card 1!
## So just add a "desciptor" to the field and you are done :-)

   put "Hello," & field "name" OF CARD 1 into field "welcome"
   set the visible of field "welcome" to true
end mouseDown
...
Hint!
You put QUOTES around "2"!?
Does this mean you named your card "2"?

That is a bad idea since the engine may get confused and reads card 2 (card NUMBER 2 = second card in stack)!
To avoid this, leave the QUOTES if you mean the number 2 and use a "real name" otherwise: "C2" or whatever, just no plain numbers!)


Best

Klaus

It worked!

Posted: Wed Sep 16, 2009 10:20 pm
by mtecedor
Thanks a lot, Klaus and AcidJazz.

That worked.