I'm trying to make a proc to output a string of random numbers, based on a given limit.
Code: Select all
bind dcc o|- otrandset ot:randset
#number of random questions to pick each time a test is begun
set ot_var(qlimit) "10"
proc ot:total { } {
# returns the number of total questions
global ot_q
return [array size ot_q]
}
proc ot:randset { hand idx arg } {
global ot_var
if {![valididx $idx]} {
return 0
}
set tot [ot:total]
set i ""
while {[llength [join $i]] <= $ot_var(qlimit)} {
set r [rand $tot]
if {[lsearch [join $i] $r] == "-1" && $r != "0"} {
set i [lappend i $r]
} else {
continue
}
}
putdcc $idx "[llength [join $i]] random numbers: \'$i\'"
return 0
}