The new PCIbex Farm is here! Be sure to check out all of its new features and changes.

Link Search Menu Expand Document

Text element

Action commands
Test commands

description

Represents text.

syntax

newText(ELEMENT_NAME: string, TEXT: string)
  • ELEMENT_NAME: The name of the newly-created element.
  • TEXT : The text contained by the element.

since

beta 0.3

example(s)


@newText("helloworld", "Hello world.")
@    .print()
  • The code above adds the text Hello world. to the screen.

Action commands

text.text

syntax

.text()

description

Resets the text of the element.

example

click to expand

@newText("onlyTextOnScreen", "You have not pressed the spacebar yet")
@    .print()
@,
@newKey("spacebar", " ")
@    .wait()
@,
@getText("onlyTextOnScreen")
@    .text("Now you have pressed the spacebar.")
  • Updates the text after the spacebar was presssed.
↑ back to top

text.unfold

syntax

.unfold()

description

Unfolds the text in delay milliseconds.

example

click to expand

@newText("Hello world")
$    .unfold( 3000 )
@,
@newTimer(3000)
@    .start()
@    .wait()
  • Starts unfolding the text “Hello world” in 3s (which is very slow for only two words) and immediately starts a 3s timer and waits until it ends.
↑ back to top


Test commands

text.test.text

syntax

.test.text()

description

Tests whether the text matches the string (identical, case-sensitive) or the regular expression.

example

click to expand

@Template( row => 
@  newTrial(
@    newText("sentence", row.Text ).print()
@    ,
@    newImage( row.Image ).print()
@    ,
$    getText("sentence")
$       .test.text( /\?$/ )
$       .success( newKey("fj").log().wait() )
$       .failure( newTimer(1000).start().wait() )
@  )
@)
  • Prints a Text element named sentence onto the page using the text from the current table row’s Text column, and below it an Image element using the filename from the current table row’s Image column. Then, tests whether the text content of the sentence Text element ends with a ? character: if it does, the script waits for a keypress on F or J, otherwise it waits 1s before moving on to the next trial.
↑ back to top