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.3example(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.
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.
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
@newTrial(
@ newText("q1", "What's up?")
@ .print()
@ ,
@ getText(q1)
$ .test.text( "Hi" )
@)
-
Adds a text to the screen and then tests if it is equal to the string “Hi” .
@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() ) @ ) @) </code></pre>
- 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 onF
orJ
, otherwise it waits 1s before moving on to the next trial.