The Nodil Manual

Contents:

Command line options

The nodil command starts the interpreter according to the specification given by the options and parameters. By default, nodil [options ...] [initial webal command] starts an interactive session on the terminal. The optional nodil command appended is executed initially. Other running conditions are specified in the command line options:

-DFsize kWords

Redefine the size of the Defined Function Area. The actual size is given by the following argument. It represent the requested size in kilo double bytes. If the specified size is larger than the maximum allowed, or less than the minimum, the extremum value is used.

Example: nodil -DFsize 16

-filedriven path-of-file
-f path-of-file

Start Nodil as an autonomous process, disconnected from the parent terminal group. Standard output is connected to the standard output of the parent. This facility is normally provided to start a file-driven nodil program.

Example: nodil -f my_programd - will run my_program as an autonomous process.

-help
-h
-?

Prints out a summary of command line options.

-nohistory
-nohist

To prevent the reloading of history list from the saved history file when nodil starts.

-server
-s

Start a nodil server process. The server types available are Immediate Execute, IMEX and Remote Execute, EXEC.

Example: nodil -s IMEX EXEC

-trace
-t

Enable the trace facility. For interactive nodil a printout is produced during the execution which shows some of the settings and events during the execution.

-WAsize kWords

Redefine the size of the nodil Working Area. The actual size is given by the following argument. It represent the requested size in kilo double bytes. If it is larger than the maximum allowed, or less than the minimum, the extreme value is used.

Example: nodil -WAsize 180

Environment

Some specific environment variables will impact the execution of nodil programs

NODIL_INIT - Initializing command

Specifies a initial nodil command in order to customized the environment. Typical use of this facility is to load external functions and data into the nodil environment, and thus to customize the execution environment. The value of the NODIL_INIT variable is interpreted as a nodil command line. It will be executed before the command optionally specified as an argument in the command line. Defined functions and global data which are linked or loaded by this command are treated as non volatile. They are not erased by ZDEF command. Hence, it provides a method to create a static environment for the execution the program.

For interactive nodil, it is also possible to customize the environment with the .nodil_profile file in the user's HOME directory.

NODIL_HISTORY - nodil history

The environment variable NODIL_HISTORY contains the filename of the history file. The default filename is .nodil_history file in the current user's HOME directory.

Socket Port Numbers

The port numbers for the various services are retrieved by the get service by name call. If the service undefined in the network data base the default values are used:

Data Types

Floating Point

The standard numerical Data Types is double-precision (64 bits) floating point, in native computer format for internal representation and in IEEE standard format for external ( files and network ) representation. In the external representation the bytes and words are in the natural network order.

Numeric Arrays ( declared by DIMENSION command ) accept all the basic numeric scalar C data types:

The copy function facilitates conversion and transfer data from between different types of numerical arrays. Conversion from double (real) to floating point arrays may result in lost of accuracy of the data without any warning. Also, the copy function facilitates conversion and transfer from a string (seen as an array of bytes) to numerical values. If the destination element is a Nodil string, an limitation on the maximum string length applies.

To specify a value with bit 15 on, the 32 bits notation must be used. If not the sign bit is automatically extended i.e. SET mask. =[[0FFFF).

Example: DIM-LONG la(3,5); SET la(1,4)=[[f234a678; % SET la(1,4) to -231430536
SET v = [[08000; % only bit 15 is set

The precision condition of + or - 5e-8 in a IF statement does not apply on integer values.

It is possible to declare strings and string-array to be read-only by means of the ronly function.

16 and 32 bits binary printing control

The print control character ’?’ produces a binary printout. Numbers in the range [-38768 .. 65535] are printed in 16 bits format. Number outside this range are printed in 32 bits format. The ’??’ can be used to force the 32 bits binary printing format.

32 Bit Logical and Bit Functions

The functions and, ior, neg, xor and bit apply to 32 bits words. The shift function can be done on 32 bits range. Remember that to define a mask value with the bit 15 on, the extended 32 bits notation must be used (example SET mask. = [[0FFFF).

Relational and Logical Operations

The relational operators of are:

By using these operators when the two arithmetic expressions are not pure integer values (in the 32 bits domain) the two expressions are considered equal if the difference between them is less than + or - 5E-8 relative to the first one.

The new relational operators:

do not apply any approximation of the values in the comparison.

A condition may be the OR of several relational expressions.

Defined Functions

The numeric variable FLAG created with the DEFINE construct does not use the convention as describes in the Nodil yellow report. A new convention has been concocted:

Global Defined functions are available with shared memory facility.

Global Data and Shared Functions

Global data and shared defined functions are available to concurrent processes (executing programs) of the same computer. This facility use the shared memory. The sharing of memory provides the fastest means for exchanging data between processes. To be used by a program Global data or Shared functions must be created (one time) and linked to the process. Up to 27 global data segments and 27 shared function segments are simultaneously available in a given computer. The identifier of these segments is done with a single alphabetic character ( a ... z or A ... Z ). A Shared function memory segment start with the magic number (short int) -4 and a Global data memory segment with the magic number -3. After this magic number the structure of the segment is the standard Nodil linked list of elements. For a string variable the space allocated is always set-up to support the maximum size of a string. The IPC key used to identify the shared memory segment are generated with the ftok file to key from the empty file /tmp/NODAL/NODAL_IPC which is automatically created if it does not exist. The id character of ftok is the single alphabetic identifier character of the segment converted into lower case for shared function segments, and into uppercase for global data segments. The content of these segments can be save into files, for re-creation or to reload their content.

Shared functions

The content of a shared function segment is identical to the content of the defined function area and data. Strings and string arrays are available for read and write operation. In case of string array write, the string element of the array must exist and the new string must be of exactly the same size as the target string. This limitation does not exist for simple strings. Shared functions must be linked by LINKDF function call before they are LDEF loaded. The already linked shared functions are not unlinked by subsequent LDEF calls. Unlinking is done with the ZDEF command. Operation permissions is determined by the access permissions of the shared memory segment.

Global Data

Any data type is allowed in Global Data:

The name of the data elements are restricted to the system name i.e. a name with more than two characters, without dot .. When a Global data segment is created or reloaded from file, the element of this file must have system name or name which are eligible to be transformed into system name during loading process. Such name must have more than two alphabetic characters, and dot .. The name transformation process remove the dot . at the end of the name and the embedded dot . are converted into colon :. Operation permissions are determined by the access permissions of the shared memory segment.

FILE NAME and IDENTIFIER

File name using tilde convention are expanded according to the standard use: ~user_name into user initial directory path, ~/ into the current user initial directory. The file identifier used by file access routines is stream identifier, a pointer, associated with the file by open file functions. The file descriptor number is not used for file access.

NODAL EXTENDED FACILITIES

Facilities which are available in the current implementation.

@ - execute a shell command @ ls -l *.nod
The remaining part of the line is passed on to the system call. Nodil waits until the call has been completed.
% - a comment follows SET v=1; % initialize variable v
The remaining part of the line is a comment.
? - help ? VALUE
This presents an alternate access to the HELP facility.
?off - stop tracing ?off
?off kernel
Turn off tracing of execution.
?on - start tracing ?on
?on kernel
Turn on tracing of execution.
! - repeat from history !38 => redo command line 38
!-4 => redo the 4th previous command
!! => redo the last command (equivalent to !-1)
!xyz => redo the command starting with xyz
Repeat a command from the history list specified by the argument. A positive value is the number of the command, and a negative value is its relative position.

Commands

The nodil commands consist of a set of keywords which govern the excution of the program.

Main Commands

ASK ASK "value of v1 " v1 "value of v2 " v2 "value of v3 " v3
The ASK Command prints the specified promt followed by a : for each value indicated. The user types a numerical expression which is evaluated and assigned to the variable.
CALL CALL close(stream)
close(stream)
The CALL command transfers the control to the specifyed subroutine. This keyword can be left and is assumed by default when there is no assignment of value.
DATA DATA; % dump the variables
DATA v1 v2; % dump variables v1 and v2
DATA(v1,v2); % dump variables v1 and v2
The DATA command dumps the Nodil variables. If a list of variable is given as argument, these variables are dumped, if not all the current list of Nodil variables are dumped. The dump of the variable header is in decimal for the size, type, and the 3 extra short words. The name is dump as ASCII characters, and in octal : the 6 values are enclosed in parenthesis. The body of the variable is dumped as unsigned short word in hexadecimal.
DEFINE DEFINE-FUN func; % a function without parameter
DEFINE-CALL subf(r-x, s-st)
DEFINE-STR strfun(r-x, v-y)
The Define command defines a Call-type subroutine (no returned value), a function or a string function. The body of the routine is the content of the text buffer.
DIMENSION DIMENSION AR(5,7); % array of 5 rows of 7 columns
DIMENSION R(34)
DIMENSION-I S(34)
DIMENSION-S st
The DIMENSION command creates a array according to the qualifier. This qualifier to be used for the various types of arrays are as follows with the minimum abbreviations emphasised in bold print: BYTE, SHORT, INTEGER, LONG, FLOAT, DOUBLE, REAL and STRING for arrays of strings. SHORT and INTEGER types refer to the same short integer type (16 bits). This feature is for compatibility with the previous version of Nodil on mini and micro processors. For numerical array, the 1 or 2 dimensions of the array must be defined. For string arrays no dimension specification is needed. The two dimension numerical arrays are row,column, i.e. the first subscript is the row, and the second is the column. They are stored by column, the first subscript, row, varies most rapidly. They can be accessed as a single dimensional array, for which the index calculation is:
index := row_index + (column_index -1)*nb_of_row
10.10 DIM A(3,5)

20.20 SET A(1,2) = 10

30.10 % is equivalent to:

40.20 SET A(4) = 10

50.10 % where the index is calculated as : 1+(2-1)*3 = 4
DO DO 10!90
The DO command executes line/group segments of the program as a subroutine. An error exception handling can be specified with the "!" syntax. This exception block is seen as an implicit GOTO in case of an error.
EDIT EDIT [{line-number | group-number}] [filtering-pattern]
i.e.
EDIT 10 30.12 20; % edit group 10, line 30.12 and group 20
ED; % edit the complete text buffer
ED 10.40 20 "for"; % edit line 10.40, line with "for" in block 20
ED "zizi"; % edit all the line containing "zizi"
The EDIT command allows editing of one or more lines of program. A series of lines or groups of lines can edited in one go. An optional pattern can be specified to edit only the lines which match the pattern. The and the keys can be used to move across the lines to be edited. The end of edition condition is either when the complete line/group specification has been exhausted, or on abort character (escape character or tty interrupt character ).
END END
The END command terminates the program execution without leaving Nodil.
ERASE ERASE va 1.2 (30.4 , 50) 90 st
The Erase command erases variables and program lines from the working area. Variable names, line numbers, group numbers or line ranges can be given as command parameters. The space character is the separator. A line range is specified by a doublet of line number (or group number) comma ',' separated, and enclosed in a pair of round brackets '(). The reserved names : ALL, ALLP and ALLV stand for "erase all program and variables", "erase all program lines" and "erase all variables", respectively. If no parameter is given, the default is ERASE ALLV.
EXECUTE EXECUTE ("lxplus.cern.ch") 10 a b
The EXECUTE command sends the specifyed Nodil group of the user program together with the variables to the computer to be executed by the appropriate server. The remote computer is specifyed by its InterNet name.
FOR FOR i=20, -2, 0; SET v=func(i); IF v < 0; ROF
The FOR command executes a loop, with automatic increment (or decrement) of the control variable. The ROF command can be used to break out the FOR loop.
GOTO SET v=12.80; GOTO v 12.80
The GOTO command transfers the control to the specifyed program line number. Note: GOTO outside the current line-group is not allowed within a DO construct.
HELP HELP
HELP DO
The HELP command presents documentation to the user. When executed without any arguments, then a the complete list of commands and functions is written to the interactive output stream. When an argument list is present, then the NodilMan is searched for the argument, and the result is presented on a Web browser.
HISTORY
The HISTORY command prints the contents of the history list. This facility is only available in interactive Nodil.
IF IF a=1 OR a=5; SET a = a+10
IF (a-10) 50.10, 50.30, 52
IF (a-10) 50.10, 50.30; SET v=a
The IF command executes the remainder of the comand-line if the logical expression is found to be TRUE. The expression may contain OR statements to allow alternate statements to preempt. The first arithmetic expression must not be enclosed in brackets to avoid confusion with the triple-branch mode. The comparison operators are:
  1. '=' approximately equal
  2. '>' approximately greater
  3. '<' approximately less
  4. '>=' approximately greater or equal
  5. '<=' approximately less or equal
  6. '<>' approximately unequal

  7. '==' equal
  8. '>>' greater
  9. '<<' less
  10. '>>=' greater
  11. '<<=' less
  12. '!=' not-equal
For the first 6 comparison operators, the comparison is done with the aproximation of abs(5E-8) on the array element. For the next 6 comparison operators no approximation is applied. The triple branch version of the IFcommand allows program jumps to be controlled by the sign of an arithmetic expression. If the value is less, equal or greater to zero, the control is passed respectively to the first, second or third specified lines. If the corresponding line number is missing, the next command is executed.
IMEX IMEX("mote.magooweb.ch") TYPE ctime
The IMEX command sends the command to the IMEX server on the specified computer. The result string is returned and printed on the output stream. The computer spcification must be a resolveable name.
LDEF LDEF dfile1 dfile2
The LDEF command loads the contents of the specified file(s) into the defined function area. Before the Defined Function Area has been cleared by ZDEF Nodil command, linking of Shared Function Segments is not allowed.
LIST LIST 10 20.3 99
The LIST command lists program lines and groups in the current working area. When no parameters are specified, all lines are listed.
LISV
The LISV command lists the variables in the current working area. If a program is loaded, the name of the program file is also displayed.
LOAD LOAD file_name
The LOAD command loads the contents ot the file into the working area. The file can contain both data or program lines. The working area is not cleared prior to the loading, and hance, any corresponding elements in the working area are replaced.
OLD OLD file_name
The OLD command flushes the working area and loads program and data from the file.
ODEF ODEF name_of_defined_function
The ODEF command command copies the body (program lines) of the defined function into the working area and deletes the function from the list of defined functions.
OVERLAY OVERLAY filename, new_arg1, new_arg2, ...., new_arg16
The OVERLAY command runs the program stored on the file as an overlay in the working area. The program disappears after termination. The numerical value of the arguments (up to 16) are stored in arg(1), arg(2) ..., arg(16). The STRARG string function can be used to pass a string parameter to the overlay program. Any legal numerical expression, separated by commas, can be used to specify the parameters list.
QUIT QUIT
The QUIT command terminates of the current program and teminates the process.
REMIT REMIT a
The REMIT command sends data items back to the program which issue the EXECUTEcommand. If this command is not executed by an EXEC server process, it is interpreted as a RETURN statement from a DO command.
RETURN RETURN
The RETURN command returns from a DO group execution.
ROF FOR i=1,10; FOR j=5,20; TYPE i j; IF i*j>100; ROF
The ROF command breaks out of the line of the FOR loop. Execution control is passed on to the following line.
RUN RUN
RUN [10]
RUN [10] file_name
RUN file_name
The RUN command starts a loaded program. If there is no file_name in the argument list, then the currently loaded program is run from the lowest line number. A line number or line group enclosed in square brackets, [], runs the program starting from that line or group. If the last argument is a file_name, then the contents of that file is first loaded into the working area.
SAVE SAVE file_name
SAVE file_name 2 VA VB VC
SAVE file_name ALLP VA VB VC
The SAVE command saves program and data to a file. Specific block number can be specifyed and list of variables. The predefined keyword ALLP and ALLV can be used to specify the all currently loaded program and all the existing variables in the text buffer.
SDEF SDEF file_name
The SDEF command saves the contents of the Defined Function Area to a file.
SET SET v = a + b - 8
The SET command assigns the value of the expression to a numeric variable. If the variable does not already exist, it is created.
TYPE TYPE "result = "%10.04 A+B !
The TYPE command types out on odev stream the list of items. This list can contain expressions, strings and control sequences such as:
  • ! for new line
  • %X for format change
  • &X for X spaces characters.
VALUE VALUE a
The VALUE command exits from a defined function returning the expression value as the function value.
WAIT WAIT( mote.magooweb.com )
The WAIT command waits for the data to be remitted from the EXECUTE in the specifyed computer.
WAIT-TIME WAIT-TIME 2.5
The WAIT-TIME command waits for the specifyed (in second) amount of time.
WHILE WHILE a=1 OR a=5; DO 80
The WHILE command allows the execution of the remainder of a line of commands in a loop until the condition is not longer true. The condition may be the OR of several logical expressions. In arithmetic expressions comparison, if at least one of the two value is not an integer value, the two expression are considered equal if the difference between them is less than + or - 5E-8 relative to the first. If the two expression are integer values (zero fractional part), no approximation is done during the comparison. The new expressions comparison operators == (equal), != (not-equal), >> (greater), << (less) >= (greater or equal) and <= (less or equal) never apply approximation in the comparison of the expressions.
ZDEF ZDEF
The ZDEF command clears the defined function area and unlink any Shared functions segments linked which are not frozen.

String Commands

$ASK $ASK "string 1 " s1 "string 2 " s2
The $ASK string command types a column for each string required; the user types a string to define each variable. If the string variable exists, the content of this variable is edited, else the string variable is created.
$DO $SET a = "TYPE date"; $DO a
The $DO string command executes the command stored in the string.
$IF $IF str = "abcdefg"; DO 50
$IF (str - "abcdefg") 10, 50, 60
The $IF command executes the remaining part of the line according to the lexical comparison of the argument string. This lexical comparison is done on the basis of the internal encoding of characters. The comparison operators are >, <, >=, <=, <>, ==, !=, >>, << .
The triple branch version of the command allows program jumps to be controlled by the sign of a string expression. This expression can be only a lexical subtraction of two concatenations. If the value is less, equal or greater than zero, the control is passed to, respectively, the first, second or third program lines specified. If the corresponding line number is missing, the next command is executed.
$MATCH $MATCH STR1 P1 : 50.10
The $MATCH command matches the string with the pattern. If the match fails, control will be transfered to the specified program line.
$PATTERN $PATTERN p1 = "abcdef"
The $PATTERN command creates the pattern variable from the given expression.
$SET $SET s = "abcdef" v1
The $SET command sets the string variable to the result of the concatenation. If the variable does not already exist it is created.
$VALUE $VALUE "abcdef"
The $value command exits from the Defined String Function with the concatenation as function value.

Functions

Mathematical Functions

abs SET val = abs(am)
The abs mathematical function returns the absolute value of the argument.
acos SET y = acos(x)
The acos mathematical function returns the arc cosine of the argument in the range 0 to π.
acosh SET y = acosh(x)
The acosh mathematical function returns the arc hyperbolic cosine of the argument in the range 0 to π.
affine ( object1 -o-> image1 , object2 -o-> image2)
affine(array, o1, i1, o2, i2)
The transformation y = alpha*x + beta can be defined with:
affine(array, 0, beta, 1, alpha+beta)
Make an affine transformation of a of real, double or float array. The transformation is defined by image elements. These elements are not necessarily inside the domain of the array. The image array overwrites the object array.
and SET z = and(m,n)
mathematical function returns the bitwise and of the integer representation of the two arguments.
asin SET y = asin(x)
The asin mathematical function returns arc sine in the range -π/2 to π/2.
asinh SET y = asinh(x)
The asinh mathematical function returns arc hyperbolic sine.
at2 SET t = at2(x,y)
The at2 mathematical function returns arc tangent of x/y in the range -π/2 to π/2.
atan SET y = atan(x)
The atan mathematical function returns arc tangent in the range -π/2 to π/2.
atanh SET y = atanh(x)
The atanh mathematical function returns arc hyperbolic tangent.
bessel SET y = bessel(j0, x)
SET y = bessel(jn, n, x)
The bessel mathematical function of the first and second kind for real arguments and integer orders. The function selectors are: j0 j1 jn y0 y1 yn
bit SET bit(nb, data) = 1
SET z = bit(nb, data)
The bit mathematical function reads or sets a specified bit in a integer representation of the parameter.
cos SET y = cos(x)
The cos mathematical function returns the cosine of x (in radians).
cosh SET y = cosh(x)
The cos mathematical function returns the hyperbolic cosine of x (in radians).
erf SET y = erf(x)
The erf returns the error function of the argument.
erfc SET y = erfc(x)
The erfc function returns the 1.0 - error function of the argument.
eval SET z = eval("2 + 5")
The Eval function evaluates the argument string as a numerical expression.
exp SET one = exp(0)
The exp function returns the exponential.
fft fft(data, -1)
The fft(z, algorithm) function calculates a Fast Fourier Transform (FFT) on the argument array of dimension z(2, N) where:
  • in cartesian form:
    • z(1,i) contains the real part of the complex series;
    • z(2,i) contains the imaginary part of the complex series.
    i.e. a complex number in the series can be expressed as: zi = z(1,i) + j * z(2,i)
  • in polar form:
    • z(1,i) contains the magnitude;
    • z(2,i) contains the angle in radians ranged from -π to π.
    i.e. a complex number in the series can be expressed as: zi = z(1,i) * ε z(2,i)
The output data array overwrites the the input array. The specification of the direction of the transform and the choice of the algorithm is packed into the second parameter of the function call. The direction of the transform is specified by the sign of the second parameter, i.e. <0 for forward, >0 for reverse. The algorithms of the Discrete Fourier Transforms (DFT) are defined as follows:

Let x0....xn-1 be complex numbers, then the DFT is defined by the formula:

and the inverse DFT is defined by the formula:

The value of the second parameter selects algorithm to be used for the transform.
  • 1 - specifies cartesian form and automatic selection of the optimum algorithm for the transform.
  • 2 - specifies cartesian form and selects the Cooley and Tukey algorithm
  • 3 - specifies cartesian form and selects the Singleton algorithm
  • 4 - specifies cartesian form and selects the Discrete Fourier Transform (DFT) algorithm
  • 101 - specifies polar form and automatic selection of the optimum algorithm for the transform.
  • 102 - specifies polar form and selects the Cooley and Tukey algorithm
  • 103 - specifies polar form and selects the Singleton algorithm
  • 104 - specifies polar form and selects the Discrete Fourier Transform (DFT) algorithm
For the values 1, 101, -1 and -101, the optimum algorithm is chosen according to the following criteria:
  • If the number of data points is a pure power of 2, the Cooley and Tukey algorithm is used,
  • Else -
    • On condition that the decomposition criterions are satisfied, i.e. the maximum prime factor of N must be less or equal to 23,
    • and the number of prime factors of N is less than 210,
    • and the square-free portion K of N as two or more prime factors, then 210 must be greater than K.
    then the R. C. Singleton algorithm (mixed-radix fast Fourier transform algorithm) is used.
  • If not the discrete Fourier transform algorithm is used.
Detail information can be found in CERN Computer Center Program Library routine D702. The execution speed of the transform depends considerably on the algorithm selected. With the exception of the Cooley and Tukey algorithm, a maximum number of 2048 data points is allowed. In the polar form, if the modulus of the result is less than 1.0E-12, modulus and angle are forced to 0.0, and if the angle is less than 1.0E-12 radian, the angle is forced to 0.0 radian. If just the modulus of the transformed signal is needed, then the function spectrum can be used.
fpt SET y = fpt(x)
The fpt function returns the fractional part of the parameter.
ior SET z = ior(m,n)
The ior function returns the boolean inclusive or of the two numerical parameters.
log SET ln = log(x)
The log function returns the natural logarithm as provided by the library function.
log10 SET lg = log10(x)
The Log10 function returns the base 10 logarithm as provided by the C library function.
long TYPE long(]]-10)
FFFFFFF6
The long function returns the expression in a 32 bits representation. This feature is useful to force 32 bits representation of 16 bits integer. (range : -32768 .. 32767). The returned value is either a number or a string according to the context. If the returned value is a string, the expression can be qualified by the formating prefix ] for octal, ]] for hexadecimal and ? for binary.
lqfit lqfit(y_array, x_array, 1st_index, Last_index, alpha, beta)
lqfit(y_array, y_array, 1st, last, alpha, beta); % special case : X values are : (1st-1), 1st, ... last-1)
The lqfit function computes and returns the linear square estimators α and β which approximate the data defined by the two arrays y and x by the relation y(x) = α + β * x. The elements for which the approximation is evaluated are in the array index range [1st_index ... last_index]. The x and y arrays must be of the same type Float, and of the same size. These arrays are assumed to be single dimension arrays. If the parameters x and y refere to the same array element), then the x value for a given y element is taken as the "distance to the 1st element" of the y array, which is the array index value -1.
max SET ma = max(array)
The max function returns the maximum value of an array
min SET mi = min(array)
The min function returns the minimum value of an array
mod SET mo = mod(x,y)
The mod mathematical function returns the value x modulo y
neg SET z = neg( n )
The neg function returns the one's complement of the numerical parameter.
pie SET pi = pie
The pie mathematical function returns the value of the mathematical π.
rand SET k = rand
The rand mathematical function returns successive pseudo-random numbers in the range from 0.0 to 1.0.
random SET k = random
The random mathematical function returns successive pseudo-random numbers in the range from 0 to (2 **31)-1 as provided by the random(3) Standard C Unix library. This function can be used as a random bit patern generator, but the bit 31 is never set.
sgn SET si = sgn( x )
The sgn mathematical function returns +1 or -1 according to the sign of the parameter x
shift SET y = shift( x, n )
The shift mathematical function returns a the value of the the parameter x shifted bitwise left, if n is positive, or right if negative. The parameter x is converted to an integer and rounded before the shift.
sin SET y = sin( x )
The sin mathematical function returns the sine of the parameter x (in radians).
sinh SET y = sinh( x )
The sin mathematical function returns the hyperbolic sine of the parameter x (in radians).
smooth SET x.ofmax = smooth(raw_array, smooth_array, mean, sigma, weighting, del_bad_points, processing_class)
The smooth mathematical function smoothens the given raw data array (real or float array) using the cubic spline interpolating algorithm. It is assumed that the abscissa of the points is uniformly distributed. The smoothed data are returned in the output array which must be of the same type and size as the raw data array. The function returns the abscissa of the upper point of the smoothed curve, the mean (1st momentum) and the standard deviation (square root of the 2nd momentum). A large value ( > 20 ) give a strong coupling, hence a weak smoothing, a low value ( < 1 ) gives a weak coupling, hence a strong smoothing. If the del_bad_points flag is set, i.e. not equal to zero, and the size of the raw_array is < 100, then the abnormal point deletion is performed.
The parameter processing_class defines additional data processing as follows:
  • processing_class = 0: the momentum parameters of the smoothed data are computed only for the kernel part of the data (a window of 2 times the size of the half height around the maximum of the smoothed curve).
  • processing_class = 1: the base line on the left and the right size of the curve is removed. The momentum are then computed for the corrected curve.
  • processing_class = 2: no special processing is done to compute the momentum.
Subsequent calls to smoothda may be made in order to retrieve interpolated points. A resource exhausted error may be returned if there is not enough dynamic memory available for the processing.
smoothda SET y.max = smoothda( x_array, y_array, x.min, x.max)
The smoothda mathematical function returns a set of uniformly distributed interpolated points on a smoothed curve established by a preceding call to smooth. The interpolated points are returned into x_array and y_array which must be of the same type (real or float) and same size. The number of points is defined by the size of the arrays, and they are uniformly distributed in x between x min and x max. The value of x extremum can be any values in the range of the definition of the smoothed curve ( 0.0 to "size_of_raw_data_array -1" ). The function value on return is the maximum y value of the smoothed curve ( the y value of the x value returned by the call to smooth). If there was no prior call to smooth, then the error Unauthorised actionis generated.
spectrum CALL spectrum(floating point array)
The spectrum mathematical function computes the frequency spectrum of the signal defined by its magnitude: a real array a(N) of N elements. The output overwrites the input. The function calls the fft function with real data. The returned spectrum values are two time the modulus value of the returned fft values. Only the first (N+1)/2 values are significant in the returned array. If the magnitude and the phase of the signal is needed, it is more appropriate to use the fft function in polar mode.
sqr SET y = sqr( x )
The sqr mathematical function returns the square root the parameter.
tan SET y = tan(x)
The tan mathematical function returns trigonometric tangent of the angle in the parameter (radians).
tanh SET y = tanh(x)
The tanh mathematical function returns the trigonometric hyperbolic tangent in the parameter.
xor SET z = xor(m,n)
The xor function returns the bolean exclusive or of the two numerical parameters.

Pattern Functions

abort
The abort pattern function exits from the Defined String Function with the concatenation as function value. It provokes a failure of the associated $MATCH.
any
The any pattern function matches any single character contained in the parameter concatenation.
arb
The arb pattern function matches any character or string.
fail
The fail pattern causes a mismatch hence alternatives will be tried.
len
The len pattern function matches a string of the given length.
notany
The notany pattern function matches a single character which is not contained in conc.
pos
The pos pattern function matches the specified character position in string.
rpos $MATCH C 'ABCDDCBA' rpos(n)

The rpos pattern function anchors the pattern to occur at position n counted from the end of the string.

rtab$MATCH C 'ABCDDCBA' rtab(n)
The rtab function matches up to position n counted from the end of the string. n characters should be available in the string.
span span( concatenation )
The span pattern function matches the longest run of characters contained in the concatenation, starting from the current cursor position.
tab tab( position )
The tab pattern function matches up to the specified position in string.

String Functions

alpha $SET st = alpha
The alpha string function returns the alphabet in upper case (A ... Za ... z)
ctime TYPE ctime; % print the current date and time
SET v = 732563401; TYPE ctime(v) % convert to date and time
The ctime function returns the current time and date string as provided by the ctime standard C Unix library function. If a parameter is provided, it is assumed to be a time value, in the standard UNIX reference time in seconds since 00:00:00 GMT, January 1, 1970.
date $SET da = date
The date string function returns the current date in ISO-format ( yyyy-MM-DD-HH:MM:SS )
ident TYPE ident
Nodil Version 2010-10-29 UNIX Linux-V2.6.32-25-generic i686
The ident string function returns a string which reports on the computing environment.
inpc $SET c = inpc(stream)
$SET c = inpc; % read from idev
The inpc string function returns a single character from an open stream. If the input stream is not specified, the next character from idev stream is returned.
input $SET st = input(stream)
$SET st = input; % read from idev
The input string function returns a line from an open stream. If the input stream is not specified, the next line from idev stream is returned.
num $SET s = num
The num string function returns the string "0123456789".
output $SET output(stream) = s $SET outc = s; % write on odev
The output function writes a string to an opened stream. If the output stream is not specified, it writes the byte on the odev stream.
serase TYPE serase
The serase convenience function returns a string suitable for clearing the terminal screen and position the cursor at the top left hand position on the screen.
size SET sz = size( st )
The size function returns the number of characters in the parameter string concatenation.
sort sort(str_arr, +)
sort(str_arr, -)
The sort function sorts the elements of a string array in ascending (+) or descending (-) order.
strmsz $SET sm = strmsz
The strmsz string function returns a space-filled string of the maximum length.
strarg $SET strarg = "toto" $SET st = strarg
The strarg string function retruns or strores the global string variable.
subs $SET sb = subs( begin_index, end_index, concatenation )
$SET subs( begin_index, end_index, concatenation ) = "looser"
The subs string function returns or sets the specified substring of given concatenation.
ucase TYPE ucase( "qwerty" )
The ucase function converts the parameter string parameter to upper case.

Utility Functions

arg SET arg(3) = 123.456
The arg is an array of 16 global variables of the type real.
arrins SET arrins(array_name, position, size) = data
The arrins function inserts a value into a specified position in a numerical array. The elements which follow the insertion point are moved forward, and the last element is lost. The size of the significant data in the array (3rd parameter) can be used to improve the performance of insertion, when a large array is partially filled with data. If this parameter is >= 0, only the significant data are moved. A value < 0 (or obviously if it is larger than the actual size of the array) means that all the data are significant.
A two dimension array can be handled, but it is seen as a single dimension array by this function.
arsize SET as = arsize(array_name)
The arsize function returns the array highest meaningful index of a numerical or a string array.
ascii SET as = ascii("@")
The ascii function returns the sum of all the ASCII codes of the characters of a string.
chain chain prog1 prog2 prog3
The chain function runs consecutive files retaining data in the nodil text buffer.
close close(stream)
close(-1); % close all opened files
close(-2); % close all opened files
The close function closes an open file.
clrkb CALL clrkb
The clrkb function flushes any pending character from the terminal input buffer. This function is applied to idev stream when connected to a terminal driver.
copy copy(SA, DA, 1, 10); % copy from SA(1).. into DA(10)
The copy function copies the source array to the destination array; from source element start to destination element start. The copy is terminated when either array is exhausted. String array are not allowed. One of the two arrays can be replaced with a Nodil string (i.e. a byte array).
envar $SET pwd = envar("PWD")
The envar function allows setting and reading of environment variables.
ermes $SET em = ermes(error_code)
The ermes function returns the error message string for the error code in the parameter.
error SET er = error
SET error = 33; %trigger error : Unauthorised action
SET error = 0; % clear error
The error function returns the last error code in read mode and provokes an error in write mode. A value of -4 can be used to trigger a break condition of the program. The value 0 applied in write mode, can be used to clear error conditions and specially the particular error messages registered for particular for software packages. This call also resets the errno, system error number.
errout errout
The errout function prints the last error detected, with the line number, in the same format as the default error handler would do.
fcopy fcopy("source_file_path", "dest_file_path")
The fcopy function copies the source_file to the destination_file.
find SET x = find(string_array, "truc")
The find function searches the string array for the first occurrens of the string. It returns the index of the successful element or -1 if unsuccessful.
first SET z = first( array [boolean operator] [expression] )
i.e.
SET z = first(ar >> 3*v)
The first function searches the array for the first occurrens that satisfies the condition. It returns the index of the successful element or -1 if unsuccessful. The comparison operators are:
  1. '=' approximately equal
  2. '>' approximately greater
  3. '<' approximately less
  4. '>=' approximately greater or equal
  5. '<=' approximately less or equal
  6. '<>' approximately unequal
  7. '==' equal
  8. '>>' greater
  9. '<<' less
  10. '>>=' greater
  11. '<<=' less
  12. '!=' not-equal
For the first 6 comparison operators, the comparison is done with the aproximation of abs(5E-8) on the array element. For the next 6 comparison operators no approximation is applied.
fromc SET x = fromc
The fromc function returns the IP address of the client computer. If fromc is not called from a server process, then a 0 is returned.
getuc SET ui=0; SET gi=0; getuc(ui, gi)
The getuc function acquires the current UID and GID of the calling process. The UID is returned in the first parameter, and the GID in the second.
header SET a=6; SET hd = header(a)
The header function returns the address of the named program element.
hName
The hName function returns the hostname of this host.
inbt SET b = inbt(stream)
SET b = inbt; % read from idev
The inbt function returns the next byte from an open stream. If the input stream is not specified, the next byte from idev stream is returned.
int SET i = int(x)
The int function returns the integer part of a numeric value.
IPaddr
The IPaddr function returns the IP address of this host.
ipcinfo
The ipcinfo function prints status information about Inter Process Communication. At the time of writing, only shared memory is impemented, either as Shared functions or Global variable segment.
lisa
The lisa function prints a list of mathematical functions.
lisd lisd; lisd a b; %list available define functions and segment a and b
The lisd function prints a list of defined functions. Without a parameter list, define functions are listed. When followed by a Shared functions segment identifiers, the contents of these segments are listed. The segments do not need to be linked to the the current process.
lisenv
The lisenv function prints a list of the environment variables. They are also called the static variables. These variables are automatically set up by the system at start-up. This function displays also information on the current working set attached, if any.
lisfst
The lisfst function prints the statistics of function calls.
lisg lisg; lisg a b; %list linked global and segment a and b
The lisg function prints the Global variables. If no parameter list is given, the currently attached Global Data are displayed. If a list of segment identifiers is provided, the content of these Global Data shared memory segments is printed.
lisindex
The lisindex function lists the names of commands and resident functions in alphabetical order.
lisr
The lisr function prints a list of standard functions and a list of all the resident functions. The abbreviation in the parameter list (if any) have the following meaning:
  • rv = read only floating point value
  • iv = read only integer (16 bits short int) value
  • lv = read only long (32 bits long int) value
  • sv = read only string concatenation value
  • nr = name of an existing data element
  • rr = real variable (floating point)
  • ir = 16 bits short integer represented as a real variable
  • lr = 32 bits long integer represented as a real variable
  • sr = string variable
  • ar = numerical array
  • nm = name (maxi 8 characters)
  • fp = variable type (free and string free functions only)
  • ... = 0 or more parameter list (free and string free functions only)
  • ?? = unknown element type
loc SET l = loc(address)
The loc function returns the contents of the address, interpreted as a short integer (2 bytes). If the address value is outside the virtual address space of the current process, a system error is returned.
lpr lpr( $HOME_anchered_file_path )
The lpr function sends the file to the lpr.
lshmdf lshmdf(a, "define1"); % load shared functions segment a from the file 'define1.nod'
The lshmdf function creates and/or loads the Shared Functions Segment from the content of a file. The file must be created with SDEF command. On creation access permission is set to read/write for any class of users. Elements allowed in the normal Defined Function Area can be loaded into the Shared Functions Segments, i.e
  • defined functions
  • define-call
  • define-string
  • and other simple variables:
    • scalar
    • array
    • numerical
    • string
    read-write or read-only
Other elements, like program lines, are just ignored. String are available for read and write with a length up to the maximum. String array are also available for read-write, but on write the array string element must preexist, and the size of the string to be save in the array must be the same as the current size of the target string element. The owner of the shared memory segment can reload with the function lshmdf on the segment. The size of the segment is automatically adjusted as required. Other users can only change the value of read/write variables.
lshmgd lshmgd(a, "global1"); % load Global data segment a from the file 'global1.nod'
The lshmgd function creates and/or loads the Global Data Segment from the content of a file. On creation access permission is set to read/write for any class of users. Only variables, scalar or array, numerical or string, read-write or read-only, are loaded from the file, other element are ignored. To be loaded a variable must had a system name i.e. more than 2 alphabetic characters without the dot . or a name which can transformed into system name during the loading process. String are available for read and write with a length up to the maximum. String array are also available for read-write, but on write the array string element must already exist, and the size of the string to be save in the array must be the same as the current size of the target string element. The owner of the shared memory segment can reload it with a new set of variables by means of the lshmgd function. The size of the segment is adjusted as required. Other users can only change the value of read/write variables. During the loading procedure the names of the variables are transformed into system variable names by removing any puntuation mark . at the end of the name and transforming the embedded dot . into a colon :. The transformed name must be a system name.
lust
The lust function lists the user functions. These are normally specific to the local environment. The abbreviations are as for the lisr function.
nodlin $SET s = NODLIN(ln)
$SET NODLIN(ln) = s
The nodlin function may be used to get the contents of a NODAL line where ln is the number, or, create a Nodil line whose content is the string s.
ntype SET q = ntype
The ntype function returns the type number of the running Nodil.
  1. = Interactive
  2. = File driven
  3. = EXEC server
  4. = IMEX server
odev SET od = odev
SET odev = open("w", file_name)
The odev function sets or returns the output device assignment. The output device can be assigned to an already opened file.
open fi = open("R", file_name)
fi = open("W", file_name)
fi = open("A", file_name)
The open function opens a named file for read ("R"), write ("W") or append ("A"), and it returns the stream number.
outbt SET outbt(stream) = z
The outbt function writes a byte to an opened stream.
ronly ronly(restriced_variable_name)
i.e.
>SET mypie=pie; ronly(mypie); LISV

mypie 12 ReadOnlyReal 3.1416

0 words of TEXT 12 words of DATA : leaving 131028
The ronly function converts a variable to a read-only variable. The variable can be a real variable, a numerical array, a string or a string array. The name of the variable must contain more than two alphabetic characters.
rwdata rwdata( operation_mode, file_name/stream_number, data1, data2, ... )
The rwdata function reads or writes Fortran type format data. The following values for the operation_mode apply:
  • "R" for Read
  • "W" for Write
  • "A" for Append
  • "F" file-name is first opened and then closed
  • "L" stream number which will not be closed
The allowed combinations are:
  • "RF"
  • "RL"
  • "WF"
  • "WL"
  • "AF"
  • "AL"
The second parameter is file_name or stream_number. The following parameters list the variables or arrays to receive the data.
squeez squeez
The squeez function reduces the program to the minimum abbreviation and remove all comments.
start start("my_program.nod")
start("[2] my_program") % start my_program.nod from block 2
The start function starts up a new copy of the interpretor running the specified file. If a block number is specified enclosed in [ ] brackets, the program starts at the beginning of the specified block. The default file type is .nod .
stderr SET er = stderr
The stderr function returns the stream identity associated with standard error.
stdin SET si = stdin
The stdin function returns the stream identity associated with standard input.
stdout SET so = stdout
The stdout function return the stream identity associated with standard output.
stty CALL stty
The stty function reports some characteristics of the terminal as defined by the terminal type and termcap data base, and according to the setting of the terminal driver ( done by stty command ).
system CALL system("ls -l *.nod")
The system function issues a shell command. The string parameter value is given to the system call. Nodil waits until the call has completed.
time SET ti = time

DIM-I da(6); SET da(1) = 1995; SET da(2) = 1; SET da(3) = 5 SET da(4) = 13; SET da(5) = 40; SET da(6) = 21;
SET ti.1 = time(da)
The time function returns the computer time in seconds.
If no parameter is provided to the function, the current computer time is returned, with the fraction part of the second as available in the computer.
If an array of six 16 bit integers (16 bit short) or long (32 bit long) is provided as a parameter, then the time corresponding to this date and hour is returned. This data can be to compute any time difference or as an input to the ctime function. In this case there is no decimal fraction part in the returned time value. The format of the six integer array is:
  1. year: the year
  2. month [1..12]
  3. day of the month [1..31]
  4. hour of the day [0..23]
  5. minute of the hour [0..59]
  6. second of the minute [0..59]
If some value is out of valid range the error value out of range (error code 37) is returned.
twait CALL twait(2.5)
The twait function waits for the specified time in seconds. The effect is identical to the WAIT-TIME command.
what what(name1, name2, ... )
what name1 name2 ...
The what function prints short information about one or more element names given in the parameter list.