Picking Random Name From Array
Posted: Thu Feb 20, 2020 12:45 am
Hi, i need help with trying to pick a random name out of an array
here is the code
(The comments are only their as this is revision for a computing science class and the teacher likes us to make comments)
The problem with this is that the output is the number of the name but not the actual name any help with making it the name which is outputed would be greatly apprciated
here is the code
(The comments are only their as this is revision for a computing science class and the teacher likes us to make comments)
Code: Select all
Global Var_Names, Array_Names, Loop_Count, TKeys, tRandomPick
On Mouseup
setup_variabels
Get_Names
Display_Name
end Mouseup
On setup_variabels
Put 0 into loop_count //interger
Put Clear Into Array_Names //String Array
end setup_variabels
On Get_names
repeat with loop = 1 to 10 //Looping the upcoming commands 10 times
Ask "What is the names you want to enter (Enter one at a time)"
Put it into Array_Names[loop] //Putting the 10 names into an array
end repeat
end Get_names
On Display_Name
Put any line of the keys of Array_names into tRandomPick //Picking random name
Put tRandomPick into field "Output" //Outputing the random name
end Display_Name