Please use our GitHub Issues page for all new support inquiries. If you need to contact us directly, please e-mail [email protected]

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?

asked 16 Jan '12, 16:06

Jesse's gravatar image

Jesse ♦
accept rate: 53%

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])
permanent link

answered 26 Jan '12, 08:50

Jesse's gravatar image

Jesse ♦
accept rate: 53%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text]( "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:


question asked: 16 Jan '12, 16:06

question was seen: 3,650 times

last updated: 26 Jan '12, 08:50

powered by OSQA