Populate a field with values from a list
Hello!
I need to write some values in a field.
There are around 10 different values, that i want to put in a field in random order.
I guess i first need to put them in a separate table, or in a list or array, and then with some formula write them in the field... but i dont know how to do that programmatically ).
Please help! )
9 replies
- 
  Do you want a true random selection of values? Where you can get the same random number? Or do you want to exclude previous selections? 
- 
  This was an interesting ask. Here is my 2 cents on the matter. Put the following in a button and have a text field called Text on the same form. let letterArray := ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J"]; let numArray := for loop1 from 1 to 11 do [floor(random() * 10)] end; Text := concat(for loop2 in numArray do item(letterArray, loop2) end)Line 1, creates an array of letters to print. Lines 2 - 4, use a for loop to create an array of 10 randomly generated numbers. Lines 5 - 7, uses a for loop and number array from line 2, to get the corresponding letter with the item() command. Then we use the concat() command to turn the new array into a string then set the field 'Text' to be equal to this new string. I'm not sure how I would not allow repeating numbers. I'll give that a try in the following days and report back if I find a solution. 
- 
  I know it's a bit of a sledgehammer to crack a nut but this gives and array of 0 to 9 randomly sorted let numArray := for loop1 from 1 to 100 do [floor(random() * 10)] end; unique(numArray)Regards John 
- 
  This works in the console let letterArray := ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J"]; let numArray := unique(for loop1 from 1 to 100 do [floor(random() * 10)] end); let Text := concat(for loop2 in numArray do item(letterArray, loop2) end); Text
- 
  With comma's: (F,G,F,J,C,E,J,H,C,J) let letterArray := ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J"]; for i from 0 to 10 do item(letterArray, floor(random() * 10)) endWithout Comma's: (DADCJCFEAC) let letterArray := ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J"]; let p := ""; for i from 0 to 10 do let c := item(letterArray, floor(random() * 10)); p := p + c end; pOr oneliner with comma's: for i from 0 to 10 do item(["A", "B", "C", "D", "E", "F", "G", "H", "I", "J"], floor(random() * 10)) end 
- 
  Thanks to here is another script to have non-repeating values. let letterArray := ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J"]; let numArray := slice([0], 0, 0); while length(numArray) < 10 do let newItem := floor(random() * 10); if not contains(numArray, newItem) then numArray := array(numArray, [newItem]) end end ; Text := concat(for loop2 in numArray do item(letterArray, loop2) end)
- 
  Other two possibilitys. Repeating items let basicString := "ABCDEFGHIJ"; join(for i in range(10) do item(basicString, floor(random() * 10)) end, "")Nonrepeating let basicString := "ABCDEFGHIJ"; join(for i in range(10) do let result := item(basicString, floor(random() * length(basicString))); basicString := replacex(basicString, result, ""); result end, "")
- 
  Guys, wow! Thank you so much! I did not expect such a variety in aproaching this task. Im gonna try every method and report back! Thanks again! Good day to everybody!!! 
Content aside
- 1 yr agoLast active
- 9Replies
- 107Views
- 
    5
    Following
    
