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

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
modfox
Posts: 3
Joined: Fri Nov 27, 2009 10:29 pm

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

Post by modfox » Fri Nov 27, 2009 10:31 pm

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.

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4171
Joined: Sun Jan 07, 2007 9:12 pm

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

Post by bn » Fri Nov 27, 2009 10:40 pm

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

modfox
Posts: 3
Joined: Fri Nov 27, 2009 10:29 pm

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

Post by modfox » Fri Nov 27, 2009 10:42 pm

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?

malte
Posts: 1098
Joined: Thu Feb 23, 2006 8:34 pm
Contact:

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

Post by malte » Sat Nov 28, 2009 12:49 am

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

Post Reply