How do I write a script that makes sure there aren't any typos in my codes, according to some list of valid codes for each argument? |
There is actually a function in the scripting API to do this. To do it, we use the function "check_valid_codes". As an example, consider we have a column called "trial", and it has three arguments we want to check: hand, turn, and unit. Hand can have the codes "l", "r", "b", or "n" (for left, right, both, none), turn can have "l" or "r" (for left and right), and unit is 1, 2, or 3. We would use the function: # First argument is the name of the column, the second is an output file. If the output file is # a blank string, i.e., "", then output is displayed to the OpenSHAPA Ruby output window. # The remaining arguments are argument_name and then an array of valid arguments. check_valid_codes("trial", "", "hand", ["l","r","b","n"], "turn", ["l","r"], "unit", [1,2,3]) |