Public Member Functions | |
DataSource | sql (string table_or_query, void connection_name) |
void | include (string file) |
numeric | simulationrun (void value) |
string | database (string driver, string params) |
void | cls (string column, string keyname) |
void | dumpDataSource (DataSource ds, integer n) |
void | p (object what) |
DataSource | loadFile (string file_name, string file_type) |
numeric | simulationrun2 (number id) |
void | load (string table_name, string file_name, bool delete) |
Static Public Attributes | |
static int | loadTable |
Functions in GlobalScope are general purpose helping functions. Global functions can be accessed without a "Object". e.g. you can use print("foo");
instead of GlobalScope.print("foo");
. In addition, no instantiation or creation of objects is necessary.
Most of the specific functionality of the Motive Client is encapsulated in objects like DataSource
or Bindings that are used in an object oriented programming style. In addition, some helping function are provided in the "global" scope.
These helping functions are defined either as C++ functions exposed to the scripting environment, or as a JavaScript libary that is include() into the script code. While there is no way to change the former (except with new versions of the client), the latter can be modified and adapted by the user. Modifying the library files is not recommended, though.
include "libary.js";
in your script file! See also http://motive.corporate-wiki.net/index.php/Javascript_libraryvoid GlobalScope::cls | ( | string | column, | |
string | keyname | |||
) | [inline] |
string GlobalScope::database | ( | string | driver, | |
string | params | |||
) | [inline] |
opens a database connection and returns a 'handle'
driver | name of the database driver, i.e. database type. Values: 'SQLITE', 'ODBC', 'MYSQL'. See DataSource for details. | |
params | list of additional parameters; the type and meaning of the parameters depend on the driver |
function testSQL() { var ds = new DataSource; //var db=database('MYSQL', 'host', 'user', 'pwd'); var db=database('SQLITE', 'E:/dev/motive/client/src/tests/data/iland.sqlite'); print("using now database" + db); ds.connection = db; // set database 'db' as the connection for this datasource ds.open('sql', 'stand'); // query the table 'stand' from the database ds.showInfo(); // show some overview information }
void GlobalScope::dumpDataSource | ( | DataSource | ds, | |
integer | n | |||
) | [inline] |
print 'n' lines of the datasource ds to the debug output.
The function is part of the default library.js
ds | an (opened) DataSource | |
n | number of lines to print |
void GlobalScope::include | ( | string | file | ) | [inline] |
loads a script library file.
file | filename to be included. Use include to add libraries written in JavaScript to your project. if file is a relative path, the client looks for file first in the current directory, then in the libraries that are built into the client. |
void GlobalScope::load | ( | string | table_name, | |
string | file_name, | |||
bool | delete | |||
) | [inline] |
load the content of a file into the motive database. This function is useful for a simple and quick import of data that follows exaclty the required data structure from the MOTIVE database. The table_name
is the name of a existing table in the MOTIVE database (e.g. 'standtype').
table_name | table name of the MOTIVE target table | |
file_name | filename to be loaded. | |
delete | if true, records are deleted before the import operation |
DataSource GlobalScope::loadFile | ( | string | file_name, | |
string | file_type | |||
) | [inline] |
file() loads and returns a file base data source from file_name
. If file_type
is omitted, the type of the data source is autodetected (based on the file-extension of file_name
).
The function is part of the default library.js
file_name | source file (see DataSource documentation) | |
file_type | file type of the source |
void GlobalScope::p | ( | object | what | ) | [inline] |
prints custom information to the console depending on the type of what:
The function is part of the default library.js
what | thing to print |
numeric GlobalScope::simulationrun | ( | void | value | ) | [inline] |
creates an or selects a entry in the simulation run table. If a simulation run with the provided combination of parameters does not exist, a new simulation run is created. The ID of the simulation run is returned and set as the current default simulation run. All subsequent import for simulation result tables share this simulation run id. See also the WIKI page on "simuation run"
structure | defining the meta data keys that define a single simulation run |
numeric GlobalScope::simulationrun2 | ( | number | id | ) | [inline] |
sets the current simulation run (used for future import operations) to the provided id
. If the ID does not exist, an error is thrown. see also the alternate version of simulationrun() allowing the creation of simulation runs.
id | of the simulation run |
DataSource GlobalScope::sql | ( | string | table_or_query, | |
void | connection_name | |||
) | [inline] |
create and return a SQL data source. connection_name
is the name of the database connection (see the database() function). If omitted, the "temporary" database is the default.
The function is part of the default library.js
table_or_query | source to be selected from; either a table (if provided as a single table name) or a SQL query. | |
name | of the database connection (see GlobalScope::database()). |