## Reference
Codes and Code Values

Codes in SuperLab serve three main purposes:

- To "describe" a trial, stimulus list item, or event: They are intended to help you with the post-processing of data collected with SuperLab. The idea is to create codes, provide them with values, and attach the values to trials, events, or stimulus list items. When you run the experiment, the collected data is saved as a plain text file with one line per response. Each code that you create will result in an additional column (field) being added to the data file, with the contents of the column being the code values. With some planning, you can have your data saved already pre-coded.

- To determine the correct response: Once you have attached a code value to an event or stimulus list item, you can tell SuperLab what is the correct response based on a code value (see the Event Editor's Correct Response tab).

- To help with conditional branching: The code value that's attached to a trial can be changed while an experiment is running, e.g. to mark a trial as having been presented or to indicate that the participant's response to a trial was correct. Then, when building an expression in the Block Editor (either in the When to Run tab or in the Macros tab), you can tell SuperLab to evaluate trials that have a specific code value attached to them.

### Creating Codes

To create a code, click on the Experiment menu and select Codes. The following dialog appears:

The dialog snapshot above shows four codes already created. Click on a code to see its values; in the example above, the code "Front or Back" has two values.

- To create a new code, click on the New button on the left hand side. Another dialog appears:
  When creating a code, you must specify what you intend to use it with: trials, or events and stimulus list items.

- To create a value for the code, select the code and then click on the New button on the right hand side.

- Click on one of the two Delete buttons to delete a code or a code value. If the code or code value is being used elsewhere in the program, SuperLab will ask you to confirm.

- Click on one of the two Edit buttons to edit a code or a code value. You can rename a code or code value at any time without having to reassign it to a trial, event, or stimulus list item.

### Using Codes

Once you have created codes and values, you can use in the following places:

- You can attach code values to a trial in the Trial Editor's Code Values tab

- You can attach code values to stimulus list items in the Stimulus List Editor.

- You can attach code values to events in the Event Editor's Code Values tab. This is possible only if the event does not use a stimulus list.

- You can change a code value using an "action" in the Event Editor's Feedback tab by first specifying the condition for which to execute the action, e.g. if response is correct, and then creating a new action.

- When creating or editing an expression in the Block Editor, you can specify a subset of trials that has a particular code value attached to them.

### See Also

- Block Editor

- Event Editor