-
Notifications
You must be signed in to change notification settings - Fork 20
checkValidCodes
This function will check a variable's arguments for typos.
Primary Variable (String of variable name or RVariable)
This is the variable that will be checked for typos.
Whether or not we want to dump the results of this output to a file or simply print them to the console. If this is set to a string, it will create a file and use that. If a file already exists in that place, it will append to it rather than overwriting it.
A file pointer can also be passed here and that will be used instead of opening a new file pointer.
If you do not want to use a dump file, simply pass a blank string (""
) as the
parameter.
These parameters are given in the form of argument name/valid codes pairs. The syntax for this is slightly confusing. See example below for a concrete example.
The idea is to first pass a string that is the name of an argument. For example, if we had an argument called "reachhand" that had valid codes of "l", "r", "b", or "n" (representing left, right, both hands, and no reach, respectively), we would pass two arguments like this: "reachhand", ["l", "r", "b", "n"]. Note that the second parameter is inside of square brackets [], this denotes a Ruby Array.
See below for examples.
Nothing.
# We want to check the codes on an argument called reachhand in the trial variable.
# Valid codes for this argument are "l", "r", "b", and "n". We also want to check
# codes on another argument called headturn, and valid codes are "y" and "n".
# First get string to path of the output file we want to save to.
output_file = File.expand_path("~/Desktop/output.txt")
# Now check the codes
checkValidCodes("trial", output_file, "reachhand", ["l", "r", "n", "b"], "headturn", ["y", "n"])