FAQ: How can I combine text and variables into a single text string (concatenate)
Combining or concatenating various data types into a text string can be very useful when creating tasks in Experiment Builder.  For example, concatenation can be used to provide feedback to the participant  (e.g. “You got x out of y correct”), or to present a useful recording status message on the Host PC (e.g. Trial x of y, Image: z.jpg). Concatenation can also be useful for sending meaningful and unique messages into the EDF file to mark critical trial events, via the Message property of nodes in the Recording Sequence.

Data types
Experiment Builder recognizes various data types:
  • String - text, any value provided within “ “ marks and any keyboard key-value, e.g. Hello, “1”, and Esc
  • Number - either integer (1,2,3) or float values (0.5, 5.23, 10.2)
  • Boolean - True or False
  • Color - RGB values (Red, Green, Blue) on a scale from 0-255, eg. 1,1,2 or 255,255,255
  • Point - Location values given as x,y coordinates, e.g. 100,200 or 540,960
  • List - A list, defined within [], can be formed of any of the above, eg. [(255,255,255), (0,0,0)] is a list of two colors (black and white); [(960, 540), (660, 540), (1260, 540)] is a list of three point values. *the first item in the list is indexed to 0, the second to 1 etc.

String Concatenation
String concatenation involves combining (or adding) multiple variables and text (strings). As such any concatenated string should start with “=”.  Any typed text must be within quotation marks (“ “), and all other non-string variables must be cast as strings with the str() function/classification, e.g. str(variable.value). In the example below, the number variable ‘Count_Correct’ is used to produce a Feeback text string that will inform the participant on how many of the 20 trials they have correctly detected. Note that between each value (either text within quotes or str() variables), the + symbol is used to concatenate them into a single string. If a character (white) space is required between variables, you can add one with + “ “ +, which is a text string containing a space.
This type of feedback can also be useful as a recording status message on the Host PC, for example informing the experimenter about how many trials are completed and/or which trial type is currently showing. You can add recording status messages to your project by filling out the EyeLink Record Status Message property of the RECORDING sequence,  as shown below. In this example, the recording status message will appear as: Trial x image.jpg, where x is the current trial iteration (trial number), and image.jpg is the image filename being shown to the participant, referenced from the image column of the data source.