Library Functions

Magnolia introduces new syntax for calling predefined functions, so-called “library functions”.

Syntax:

Out = LibraryName::FunctionName(Arg1, ..., ArgN).

Note that use of the return value is mandatory.

String Library

Join(fragments : array, seperator='') → string

Return a string which is the concatenation of the strings in the fragments array. The separator between elements is the seperator.

Example:

//Saetze
Test (2) 20 a.
//Ausfuehrung
Test(1) = "a".
Test(2) = "b".
Out = String::Join(Test, "|") .
/* Makes "a|b" */
Split(string, seperator, maxsplit=None) → array

Splits string at each seperator into an array. Maxsplit limits the number of splits done.

Replace(string, old, new) → string

Makes a copy of string and replaces all occurences of old in the copy by new. Returns the copy.

Find(string, needle, start=None, end=None) → int

Finds first occurence of needle in string. gefunden is updated accordingly. The position of the occurence is returned.

Database Library

CreateTableAs(table, statement, *args) → reserved

Creates or replaces the table referred to by table, using the SQL statement given as statement. Any occurences of %s are replaced by the arguments args.

Example:

//Dateien
Tab1 "Tab1.dat".
Tab1tmp "Tab1.tmp".
//Ausfuehrung
Out = Database::CreateTableAs(Datasource!Tab1tmp, "SELECT \"Name\",\"Location\" FROM " + Database::TableName(Datasource!Tab1) + " WHERE \"Name\" = %s AND \"Location\" = %s", "Smith", "Vienna") .
InsertInto(table, statement, *args) → reserved

Inserts records into the table referred to by table, using the SQL statement given as statement. Any occurences of %s are replaced by the arguments args.

Example:

//Dateien
Tab1 "Tab1.dat".
Tab1tmp "Tab1.tmp".
//Ausfuehrung
Out = Database::InsertInto(Datasource!Tab1tmp, "SELECT \"Name\",\"Location\" FROM " + Database::TableName(Datasource!Tab1) + " WHERE \"Name\" = %s AND \"Location\" = %s", "Smith", "Vienna") .
TableName(table) → string

Returns the fully qualified SQL table name for a given table. Especially useful for namespaced tables.

Execute(statement, *args) → rowcount

Execute SQL statement given as statement against the database. Any occurences of %s are replaced by the arguments args. Number of affected rows is returned.

Example:

//Ausfuehrung
/* Delete all records from tab1 */
Out = Database::Execute("DELETE FROM " + Database::TableName(Datasource!Tab1)).
SelectOne(record, statement, *args) → rowcount

Execute SQL statement given as statement (must be a SELECT) against the database. Any occurences of %s are replaced by the arguments args. Number of affected rows is returned, and gefunden and eindeutig are updated accordingly. If gefunden and eindeutig (exactly one row is returned), the row is copied into record.

Example:

//Ausfuehrung
Out = Database::SelectOne(Record!Testsatz, "SELECT FROM " + Database::TableName(Datasource!Tab1) + " LIMIT 1") .
GetCrLf() → string

Return the sequence rn as a string. Useful for InterOp.

Runtime Library

GetStationId() → string

Returns the runtime Station ID as set in the registry or autodiscovered.