Announcing the new Datavyu v1.3.6 with enhanced features and transcription support!

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 ♦
11181015
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 ♦
11181015
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

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "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:

×11
×10
×1
×1

question asked: 16 Jan '12, 16:06

question was seen: 2,353 times

last updated: 26 Jan '12, 08:50

powered by OSQA