Page 1 of 1

Random Chars

Posted: Fri Feb 21, 2014 11:06 pm
by KennyR
Hello everyone...new question of the day for me....I am trying to assign each label of a group of buttons to a random character and am running into issues....I just simply want to randomly pick a letter between A-Z and assign the button that letter. So far I am having some luck but out of the 50 buttons I have in the group, only about 1/2 of those actually get a random character. Not sure why...I am using a repeat loop to assign each button a random letter from a field...maybe someone can help....thanks

Code: Select all

local pLetter
on mouseUp
   repeat with x=1 to the number of btns in group "alpha"
       put any char of fld "alphabet" into pLetter
      set the label of btn x to pLetter
      put empty into pLetter
      end repeat
end mouseUp 

Re: Random Chars

Posted: Fri Feb 21, 2014 11:29 pm
by Dixie
50 buttons and 26 letters in the alphabet... or am I missing something ?

Re: Random Chars

Posted: Fri Feb 21, 2014 11:30 pm
by KennyR
LOL! I did think of that....I repeated the alphabet in the field like 75 times!! Nice one though!

Re: Random Chars

Posted: Fri Feb 21, 2014 11:44 pm
by LCNeil
Hi Kenny,

Try specifically referencing the "alpha" group when setting the button names
set the label of btn x of group "alpha" to pLetter
I created a quick test stack that change all buttons as expected
randombuttonalpha.livecode.zip
(2.07 KiB) Downloaded 258 times
Kind Regards,


Neil Roger
--
RunRev Support Team ~ http://www.runrev.com
-

Re: Random Chars

Posted: Fri Feb 21, 2014 11:53 pm
by KennyR
Roger, Thank you very much for taking the time to construct that example for me! That was awesome! Works EXACTLY as I wanted....

Best
Kenny

Re: Random Chars

Posted: Fri Feb 21, 2014 11:55 pm
by LCNeil
Glad I was able to help :) Have a great weekend.

 Kind Regards,


Neil Roger
--
RunRev Support Team ~ http://www.runrev.com
-