PennController for IBEX › Forums › Support › Random Number Generator › Reply To: Random Number Generator
August 24, 2020 at 2:51 pm
#6014
![](https://www.pcibex.net/wp-content/uploads/2018/10/IMG_8365-e1540835663655-150x150.jpg)
Keymaster
Hello Callie,
Sorry for the late reply, I was away from the office last week. What you can do is generate the random number at the beginning of the experiment, but present it only at the end. Here’s a dummy experiment for illustration purposes:
PennController.ResetPrefix(null) // Shorten command names (keep this line here) uniqueID = [1,2,3,4].map(v=>Math.floor((1+Math.random())*0x10000).toString(16).substring(1)).join('-'); Header( // void ) .log( "ID" , uniqueID ) newTrial("intro", newButton("Hello").print().wait() ) newTrial("experiment", newButton("World").print().wait() ) SendResults() newTrial("end", newText("your id: "+uniqueID).print(),newButton().wait() )
Let me know if you need assistance adapting this to your case
Jeremy