Random Name Generator
James Cass
cassj at earthlink.net
Wed Dec 29 21:01:07 EST 2004
Robert -
Ken just showed you how easy it is to get things done with Rev. If you
wanted to try your exercise another way, just for understanding the
programmatic steps needed to get your result, you could break it down
like this (this code goes in the script of Ken's "Go" button):
on mouseUp
-- Ken's example. Revolution makes it easy to pick a random item
from the list.
--put any line of field "User Names" into field "Selected User"
-- Old school with a Rev twist
set lineDel to return -- set the line delimiter
put the number of lines of fld "User Names" into numNames
put random(numNames) into randNum -- pick a random line number from
1 to the number of names
put line randNum of fld "User Names" into fld "Selected User"
--show a random name from the list
end mouseUp
Ken's method is much more compact of course. :-)
Hope this helps....James
------------------------------------
When mind control works,
you won't know it.
On Dec 29, 2004, at 4:53 PM, Ken Ray wrote:
> On 12/29/04 2:20 PM, "Robert Sabo" <viper4559 at yahoo.com> wrote:
>
>> Hey Everyone,
>>
>> I just joined this group. Seems pretty cool.
>
> Hey, Robert... welcome!
>
>> Well here's my problem. I am trying to make a program that will allow
>> you to
>> input however many names you want into a list. This list will be on
>> the bottom
>> section where you can delete users. The middle section will contain a
>> text
>> area for you to input another username and the top level will run the
>> program.
>> This program is going to be setup to randomly output a name from the
>> list. I
>> got my layout already made, however I am having problems finding good
>> help on
>> how to script what I want to do with the username list.
>
> Suppose you had a list field called "User Names" which will contain
> the list
> of user names, and a separate field called "Selected User" which will
> contain the name of the randomly selected user name from the "User
> Names"
> field. Add to this a button that says "Go", and you have this:
>
> -- Script of button "Go"
> on mouseUp
> put any line of field "User Names" into field "Selected User"
> end mouseUp
>
> Easy, no?
>
> Ken Ray
> Sons of Thunder Software
> Web site: http://www.sonsothunder.com/
> Email: kray at sonsothunder.com
>
>
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> http://lists.runrev.com/mailman/listinfo/use-revolution
>
>
More information about the use-livecode
mailing list