Skip to content
This repository has been archived by the owner on Aug 30, 2019. It is now read-only.
Jesse Lingeman edited this page Jul 20, 2012 · 1 revision

Purpose

Function for loading an OpenSHAPA file into Ruby. This function is very useful for looping over entire studies, performing an operation on each OpenSHAPA file in the study, such as printing an entire study or adding a column to every file in the study.

Additionally, it is important to note that loadDB will return the database as a Ruby variable that can be stored. In order to use the loaded database with any other function in the API, that database must be saved to $db. See the example below.

Parameters

Filename (String)

The filename/path of where we want to save the file.

Returns

Database

The loaded database. Save it to $db to work with it.

Project

The project information. This stores all of the plugin configuration information.

Examples

# We first have to create a string that points to the directory we want to store
# the file in.

# Load the file on the Desktop called test.opf. The tilde (~) is a shortcut
# for the current users' home directory. ~/Desktop is the current users' Desktop.
# File.expand_path is what will expand that tilde into a full path, so it is necessary.

filename = File.expand_path("~/Desktop/test.opf")

# Load the database into $db, making it accessible to all of the other functions.
# Save the project information in $pj. Saving the project information there
# is not necessary, but this way if we called saveDB after some manipulation,
# then it will be saved too.
$db, $pj = loadDB(filename)