Database level code can be entered via the Options available when Ninox is operating in Administrative Mode. Once in Admin Mode, the Options tab will appear in the button pod in the top, left-hand corner of the Ninox Desktop. The tab, button pod and Option window with the two Database-level code areas are highlighted in the image below.

GLOBAL SCRIPT DEFINITIONS – Code written as a Global Script Definition (GSD) via the Ninox Database Options screen results in parameterized sub-routines that can be called from any other level (Table, Record or Field) in the database. To create a Global Script, one uses the “function” function to indicate that the code that follows is to be treated as a re-usable and callable sub-routine. The syntax for the “function” function is as follows:

function (name of function)(parameter : parameter type) do where:

function is spelled out in all lower case letters and is the first command in the code block;

(name of function) is the user-assigned name that will be used to identify and call this sub-routine from anywhere else inside the database application;

parameter is a variable that will contain a value passed to this subroutine; and

parameter type is an indicator used to define the type of content (text, number, date, time) that the parameter field will receive.

Once a sub-routine has been defined in the manner described above, it may be called from anywhere else in the application by code with the following syntax:

(name of function)(“parameter”) where:

(name of function) is the name that is assigned to the sub-routine code block; and

parameter is the value that the calling function is passing to the sub-routine and upon which the subroutine is called to act. In the image below, three different functions are defined.

FULLNAME – The subroutine defined at lines 1 through 3 receives three text parameters (fname, lname, prename) and, on line 2, concatenates them together to create a full name

DLLRTOPOUND – The subroutine defined at lines 4 through 6 receives two numeric parameters (dllr, fctr) and, on line 5, multiplies them together to translate American Dollars into British Pounds

EXTRACTCHAR – The subroutine defined at lines 7 through 9 receives one text and one numeric parameter (txtStrng, pos) and, on line 8 returns a sub-string of txtStrng equal to the character string that begins at the fctr position and extends for number characters

In the image below, we see the three sub-routines above called from lower levels of code.

in the examples above, the first call will return the concatenated text string “Mr. Joseph Campbell”, the second call will return the value 2300 (2500 * 92/100) and the third call will return the text string “ll” which is the sub-string of text of “Hello” that begins at the 3rd character and extends for two positions

Revision: 5
Last modified: 2019/03/31


Esta informação foi útil ?

Sim Não
Você indicou que esse tópico não foi útil para você.....
Você poderia deixar um comentário sobre o motivo ? Obrigado !
Obrigado pelo seu feedback.

Publique seu Comentário

Please do not use this for support questions.
For customer support, please contact us here.