Page 1 of 1

using repeat loops to add info

Posted: Sat Sep 29, 2012 8:34 pm
by PoLyGLoT
Hi,

I've randomized the numbers 1-12. I'm trying to use the random numbers one at a time to put information into a different bin (i.e., if the first number is 6, I want to put the information in card field "6" into bin1; if the second number is 4, I want to put the information in card field "4" into bin2, etc.). I need to do this for all 12 numbers.

This code doesn't work:

sort lines of card field "randombin" of card "orders" by random(12) #sorts my numbers
repeat with x = 1 to 12
put item 1 of line x of card field "randombin" of card "orders" into y
put card field y of card "main task materials" into matlist(x) <-------------------How can I use the "x" in the repeat loop to add 1(so that it starts with matlist1, then matlist2, etc....)
end repeat

Re: using repeat loops to add info

Posted: Sun Sep 30, 2012 10:08 am
by Mark
Hi,

Here's an example:

Code: Select all

local lMatList

constant k12 = "1,2,3,4,5,6,7,8,9,10,11,12"

on makeArray
  put k12 into myVar12
  sort items of myVar12 by random(number of items of k12)
  repeat with x = 1 to number of items of k12
   // use square brackets to make new array
    put card fld (item x of myVar12) of cd "main task materials" into lMatList[x]
  end repeat
end makeArray
Kind regards,

Mark