Page 1 of 1

How do I make a variable and put it in a text field?

Posted: Fri Nov 27, 2009 10:31 pm
by modfox
How do I make a variable, and then put it into a text field?
This is what I'm trying to do:

Code: Select all

put any character of "abcdef1234567890" into trand
on mouseUp
   put trand into field testing
   
end mouseUp
I want trand to be the variable that will have a random character, then I want to put that character into the field testing.
Every time I try this it just puts trand into the field, and I can't find anything anywhere on how to do this.

Re: How do I make a variable and put it in a text field?

Posted: Fri Nov 27, 2009 10:40 pm
by bn
Welcome to the forum Modfox,

you would want to move the code above the mouseUp below the mouseUp, that is it.

Code: Select all

on mouseUp
   put any character of "abcdef1234567890" into trand
   put trand into field "testing"
end mouseUp
please put field names into quotes. It works without but it is a source of future trouble hard to track down.
In Rev you almost everything happens inside a handler, that is a structure that starts with "on myCommand" or "function myFunction" and ends with "end NameOfHandler"
Outside of a handler you only declare global variables, script local variables, constants. I think that is it for outside of handler code.
Keep asking if you get stuck.
regards
Bernd

Re: How do I make a variable and put it in a text field?

Posted: Fri Nov 27, 2009 10:42 pm
by modfox
Thanks! I could have sworn I tried that, but it works now!
And thanks for the welcome.

Edit:
I'm trying to make an app that will generate a series of 12 random characters (6 sets of 2)
What's the best way of doing this?

Re: How do I make a variable and put it in a text field?

Posted: Sat Nov 28, 2009 12:49 am
by malte
welcome modfox,

you can use a nested repeat loop for that:

Code: Select all

on mouseUp
  local trand
   repeat 6
     repeat 2
       put any character of "abcdef1234567890" after trand
     end repeat
     put cr after trand
   end repeat
   put trand into field "testing"
end mouseUp