Skip to content
This repository has been archived by the owner on Aug 30, 2019. It is now read-only.

transferVariable

Jesse Lingeman edited this page Jul 20, 2012 · 1 revision

Purpose

Function for transfering an OpenSHAPA variable from one OpenSHAPA database to another. You can also select whether or not the variable should be removed from the original database upon transfer.

This is useful for reducing the size of large OpenSHAPA database files by moving columns into separate files, or breaking up a file so two coders can work on different columns at the same time. The files can then be merged back together.

Parameters

Source Database (String to OpenSHAPA DB file)

The database we want to transfer a variable FROM. If a blank string is passed to this variable (""), then the database that is currently in $db (i.e., the currently opened database) will be used.

Target Database (String to OpenSHAPA DB file)

The database we want to transfer a variable TO. If a blank string is passed to this variable (""), then the database that is currently in $db (i.e., the currently opened database) will be used.

Delete Variable on Transfer (boolean)

Whether or not the variable will be deleted from the source database upon successful transfer. If something breaks in the function before a transfer is completed, the variable will not be deleted. NOTE: Use with caution.

Variable names* (Strings)

The names of the variables to transfer from the source to the target DB. You can list as many as you like, as long as they all exist in the source database.

Returns

Nothing.

Examples

# Set up the strings to the database files
source_db = File.expand_path("~/Desktop/source.opf")
target_db = File.expand_path("~/Desktop/target.opf")

# The source file above contains two columns we want to transfer:
# trial and condition. Move both of these to the target file and DO NOT delete them
# upon move.

transferVariable(source_db, target_db, false, "trial", "condition")