PennController for IBEX › Forums › Support › How to add page breaks in between randomized items? › Reply To: How to add page breaks in between randomized items?
September 21, 2022 at 12:34 pm
#8514
Jeremy
Keymaster
Hi Lily,
The function sepWithN
is not a native function to Ibex or PCIbex: what definition do you use? Using this definition, your code (with 5
) works perfectly for me:
function SepWithN(sep, main, n) { this.args = [sep,main]; this.run = function(arrays) { assert(arrays.length == 2, "Wrong number of arguments (or bad argument) to SepWithN"); assert(parseInt(n) > 0, "N must be a positive number"); let sep = arrays[0]; let main = arrays[1]; if (main.length <= 1) return main; else { let newArray = []; while (main.length){ for (let i = 0; i < n && main.length>0; i++) newArray.push(main.shift()); for (let j = 0; j < sep.length; ++j) newArray.push(sep[j]); } return newArray; } }; } function sepWithN(sep, main, n) { return new SepWithN(sep, main, n); }
NB: since you have PennController.ResetPrefix(null)
at the top of your script, you don't need to have the PennController.
prefix on any of the commands below, ie you can replace PennController.Sequence
with Sequence
, PennController.CheckPreloaded
with CheckPreloaded
, and so on
Jeremy