PennController for IBEX › Forums › FAQ / Tips › DashedSentence in a PennController trial › Reply To: DashedSentence in a PennController trial
Hi Jeremy,
thanks for your reply. What I didn’t like about DashedSentence was the format of the results file output (it printed new column header labels for each trial–I know that would be fixed once I get my data into R, but I wanted to tidy things up for my test runs). I figured out newController
based on your comment, but decided to just use Option 2 (recreated DashedSentence
based on your code), and it worked great.
I had arrays of variable
in the s
parameter because I wanted to present the sentence in chunks, rather than word-by-word (each variable contained one chunk). In case anybody else stumbles upon this thread wanting to do something similar, I was able to adapt your reproduction of DashedSentence (from Option 2) by changing let words = sentence.split(' ')
to let words = sentence.split('*')
. Then I added an asterisk (*) to my .csv file to indicate where the chunk boundaries should be.
Here’s my adaptation (including setting the font to Courier):
dashed = (sentence, remove) => {
let words = sentence.split('*'), blanks = words.map(w=>w.split('').map(c=>'_').join('') );
let textName = 'dashed'+words.join('');
// We'll return cmds: the first command consists in creating (and printing) a Text element with dashes
let cmds = [ newText(textName, blanks.join(' ')).print() .settings.css("font-family","courier")]; // COURIER as font
// We'll go through each word, and add two command blocks per word
for (let i = 0; i <= words.length; i++)
cmds = cmds.concat([ newKey('dashed'+i+words[i], " ").log().wait() , // Wait for (and log) a press on Space
getText(textName).text(blanks.map((w,n)=>(n==i?words[n]:w)).join(' ')) ]); // Show word
if (remove) // Remove the text after the last key.wait() is parameter specified
cmds.push(getText(textName).remove());
return cmds;
}
and then later inside a PennController.Tempalte() I called on ‘dashed’:
...dashed(variable.critical, "remove")
Worked great, thanks!
Best,
Daniela