PennController for IBEX › Forums › Support › Generating a random confirmation code with function() › Reply To: Generating a random confirmation code with function()
September 25, 2019 at 10:42 am #4231
You’re almost there, but unfortunately you can’t refer to other PennController elements in a
let alphanum = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz"; PennController( newVar("ID", "") .settings.global() .set(v =>[...Array(8)].reduce(a=>a+alphanum.charAt(Math.floor(Math.random()*alphanum.length)),'')) , newText("code", "") .settings.text( getVar("ID") ) .print() ) .log("code", getVar("ID"))
I made the ID var global so you can add its value at the end of your results lines using .log.
NB: I reused your code but of course the trial defined here will be fully executed (and done) in an instant unless you add a
wait command on an element of an appropriate type.