Back to Contents


Built-in Functions

Summary:

See also: Utility Functions, Variables, Functions, Operators, Built-in Classes.


What is a built-in function?

A built-in function is a predefined function that is included in the runtime system or provided as a library function automatically linked to your programs. You do not have to link with any additional BDL library to create your programs. The built-in functions are part of the language.

See also Utility Functions.

Warnings:

  1. Do not confuse built-in functions with SQL aggregate functions like:
  2. Do not confuse built-in functions with operators. Some operators have the same syntax as functions, but these are real language operators that have a specific order of precedence. Operators can be used in different contexts according to the BDL grammar. See for example:

List of built-in functions

Function Description
ARG_VAL() Returns a command line argument by position.
ARR_COUNT() Returns the number of records entered in a program array during or after execution of the INPUT ARRAY statement.
ARR_CURR() Returns the current row in a DISPLAY ARRAY or INPUT ARRAY.
DOWNSHIFT() Returns a string value in which all uppercase characters in its argument are converted to lowercase.
ERR_GET() Returns the text corresponding to an error number.
ERR_PRINT() Prints in the error line the text corresponding to an error number.
ERR_QUIT() Prints in the error line the text corresponding to an error number and terminates the program.
ERRORLOG() Copies the string passed as a parameter into the error log file.
FGL_BUFFERTOUCHED() Returns TRUE if the current input buffer was modified since the field was selected.
FGL_DIALOG_GETBUFFER() Returns the value of the current field as a string.
FGL_DIALOG_GETBUFFERLENGTH() When using a paged display array, returns the number of rows to fill the array buffer.
FGL_DIALOG_GETBUFFERSTART() When using a paged display array, returns the row offset to fill the array buffer.
FGL_DIALOG_GETCURSOR() Returns the position of the edit cursor in the current field.
FGL_DIALOG_GETFIELDNAME() Returns the name of the current input field.
FGL_DIALOG_GETKEYLABEL() Returns the text associated to a key in the current interactive instruction.
FGL_DIALOG_INFIELD() Returns TRUE if the field passed as a parameter is the current input field.
FGL_DIALOG_SETBUFFER() Sets the value of the current field as a string.
FGL_DIALOG_SETCURRLINE() Moves to a specific row in a record list.
FGL_DIALOG_SETCURSOR() Sets the position of the input cursor within the current field.
FGL_DIALOG_SETFIELDORDER() Enables or disables field order constraint.
FGL_DIALOG_SETKEYLABEL() Sets the text associated to a key for the current interactive instruction.
FGL_DRAWBOX() Draws a rectangle based on character terminal coordinates in the current open window.
FGL_DRAWLINE() Draws a line based on character terminal coordinates in the current open window.
FGL_GETCURSOR() Returns the position of the edit cursor in the current field.
FGL_GETENV() Returns the value of the environment variable having the name you specify as argument.
FGL_GETFILE() Transfers a file from the front-end to the application server machine.
FGL_GETHELP( ) Returns the help message according to a number.
FGL_GETKEYLABEL() Returns the default label associated to a key.
FGL_GETPID( ) Returns the system process id.
FGL_GETRESOURCE( ) Returns the value of an FGLPROFILE entry.
FGL_GETVERSION( ) Returns the build number of the runtime system.
FGL_GETWIN_HEIGHT() Returns the number of rows of the current window.
FGL_GETWIN_WIDTH() Returns the width of the current window as a number of columns.
FGL_GETWIN_X() Returns the horizontal position of the current window.
FGL_GETWIN_Y() Returns the vertical position of the current window.
FGL_KEYVAL() Returns the key code of a logical or physical key.
FGL_LASTKEY() Returns the key code of the last key pressed by the user.
FGL_PUTFILE() Transfers a file from from the application server machine to the front-end.
FGL_REPORT_PRINT_BINARY_FILE() Prints a file containing binary data during a report.
FGL_REPORT_SET_DOCUMENT_HANDLER() Defines the document handler to be used for a report.
FGL_SET_ARR_CURR() Sets the current line in a record list.
FGL_SETENV() Sets an environment variable
FGL_SETKEYLABEL() Sets the default label associated to a key.
FGL_SETSIZE() Sets the size of the main application window.
FGL_SETTITLE() Sets the title of the main application window.
FGL_SYSTEM() Starts a program in a UNIX terminal emulator when using a graphical front end.
FGL_WIDTH() Returns the number of columns needed to represent the string.
FGL_WINDOW_GETOPTION() Returns the attributes of the current window.
LENGTH() Returns the number of characters of the string passed as a parameter.
NUM_ARGS() Returns the number of program arguments.
ORD() Returns the ASCII value of the first byte of a character expression.
SCR_LINE() Returns the number of the current screen record in its screen array.
SET_COUNT() Specifies the number of records that contain data in a static array.
SHOWHELP() Displays a runtime help message, corresponding to its specified argument, from the current help file.
STARTLOG() Initializes error logging and opens the error log file passed as a parameter.
UPSHIFT() Returns a string value in which all lowercase characters in its argument are converted to uppercase.

List of de-supported built-in functions:

Function Description
FGL_FORMFIELD_GETOPTION() Returns attributes of a specified form field.
FGL_GETKEY() Waits for a keystroke and returns the key code.
FGL_GETUITYPE() Returns the type of the front end.
FGL_SCR_SIZE( ) Returns the number of rows of a screen array of the current form.
FGL_WINDOW_OPEN( ) Opens a new window with coordinates and size.
FGL_WINDOW_OPENWITHFORM( ) Opens a new window with coordinates and form.
FGL_WINDOW_CLEAR( ) Clears the window having the name that is passed as a parameter.
FGL_WINDOW_CLOSE( ) Closes the window having the name that is passed as a parameter.
FGL_WINDOW_CURRENT( ) Makes current the window having the name that is passed as a parameter.

ARG_VAL( )

Purpose:

This function returns a command line argument by position.

Context:

  1. At any place in the program.

Syntax:

CALL ARG_VAL( position INTEGER ) RETURNING result STRING

Notes:

  1. position is the argument position. 0 returns the name of the program, 1 returns the first argument.

Usage:

This function provides a mechanism for passing values to the program through the command line that invokes the program. You can design a program to expect or allow arguments after the name of the program in the command line.

Like all built-in functions, ARG_VAL() can be invoked from any program block. You can use it to pass values to MAIN, which cannot have formal arguments, but you are not restricted to calling ARG_VAL() from the MAIN statement. You can use the ARG_VAL() function to retrieve individual arguments during program execution. You can also use the NUM_ARGS() function to determine how many arguments follow the program name on the command line.

If position is greater than 0, ARG_VAL(position) returns the command-line argument used at a given position. The value of position must be between 0 and the value returned by NUM_ARGS(), the number of command-line arguments. The expression ARG_VAL(0) returns the name of the application program.

See also: NUM_ARGS().


NUM_ARGS( )

Purpose:

This function returns the number of program arguments.

Context:

  1. At any place in the program.

Syntax:

CALL NUM_ARGS( ) RETURNING result INTEGER

Notes:

  1. returns 0 if no arguments are passed to the program.

See also: ARG_VAL().


SCR_LINE( )

Purpose:

This function returns the number of the current screen record in its screen array

Context:

  1. During a DISPLAY ARRAY or INPUT ARRAY statement.

Syntax:

CALL SCR_LINE( ) RETURNING result INTEGER

Notes:

  1. The current record is the line of a screen array that is highlighted at the beginning of a BEFORE ROW or AFTER ROW clause.

Warnings:

  1. When using new graphical objects such as TABLEs, this function can return an invalid screen array line number, because the current row may not be visible if the user scrolls in the list with scrollbars. 

See also: ARR_CURR().


SET_COUNT( )

Purpose:

This function specifies the number of records that contain data in a static array.

Context:

  1. Before a DISPLAY ARRAY or INPUT ARRAY statement.

Syntax:

CALL SET_COUNT( nbrows INTEGER )

Notes:

  1. nbrows defines the number of rows in the static array.
  2. Using this function is equivalent to the COUNT attribute of INPUT ARRAY and DISPLAY ARRAY statements.

Usage:

When using a static array in an INPUT ARRAY (with WITHOUT DEFAULTS clause) or a DISPLAY ARRAY statement, you must specify the total number of records in the array. In typical applications, these records contain the values in the retrieved rows that a SELECT statement returned from a database cursor. You specify the number of rows with the SET_COUNT() function or with the COUNT attribute of INPUT ARRAY and DISPLAY ARRAY statements.

Warning: You do not have to specify the number of rows when using a dynamic array. When using a dynamic array, the number of rows is defined by the getLength() method of the array object.

See also: ARR_CURR(), FGL_SET_ARR_CURR()


ARR_COUNT( )

Purpose:

This function returns the number of records entered in a program array during or after execution of the INPUT ARRAY statement.

Context:

  1. Can be called at any place in the program, but should be limited to usage inside or after INPUT ARRAY blocks.

Syntax:

CALL ARR_COUNT( ) RETURNING result INTEGER

Notes:

  1. Returns the current number of records that exist in the current array.
  2. Typically used inside INPUT ARRAY blocks.

Usage:

You can use ARR_COUNT() to determine the number of program records that are currently stored in a program array. In typical FGL applications, these records correspond to values from the result set of retrieved database rows from the most recent query. By first calling the SET_COUNT() function or by using the COUNT attribute of INPUT ARRAY, you can set an upper limit on the value that ARR_COUNT() returns.

ARR_COUNT() returns a positive integer, corresponding to the index of the furthest record within the program array that the user accessed. Not all the rows counted by ARR_COUNT() necessarily contain data (for example, if the user presses the DOWN ARROW key more times than there are rows of data).

See also: INPUT ARRAY, ARR_CURR()


ARR_CURR( )

Purpose:

This function returns the current row in a DISPLAY ARRAY or INPUT ARRAY.

Context:

  1. During a DISPLAY ARRAY or INPUT ARRAY statement.

Syntax:

CALL ARR_CURR( ) RETURNING result INTEGER

Usage:

The ARR_CURR() function returns an integer value that identifies the current row of a list of rows in a INPUT ARRAY or DISPLAY ARRAY instruction. The first row is numbered 1.

You can pass ARR_CURR() as an argument when you call a function. In this way the function receives as its argument the current record of whatever array is referenced in the INPUT ARRAY or DISPLAY ARRAY statement.

The ARR_CURR() function can be used to force a FOR loop to begin beyond the first line of an array by setting a variable to ARR_CURR() and using that variable as the starting value for the FOR loop.

The built-in functions ARR_CURR() and SCR_LINE() can return different values if the program array is larger than the screen array.

See also: INPUT ARRAY, DISPLAY ARRAY, ARR_COUNT(), FGL_SET_ARR_CURR(), SCR_LINE()


ERR_GET( )

Purpose:

This function returns the text corresponding to an error number.

Context:

  1. At any place in the program.

Syntax:

CALL ERR_GET( error-number INTEGER ) RETURNING result STRING

Notes:

  1. error-number is a runtime error or an Informix SQL error.
  2. For development only.

Warnings:

  1. Informix SQL error numbers can only be supported if the program is connected to an Informix database.

See also: ERRORLOG(), STARTLOG(), ERR_QUIT(), ERR_PRINT(), Exceptions.


ERR_PRINT( )

Purpose:

This function prints in the error line the text corresponding to an error number.

Context:

  1. At any place in the program.

Syntax:

CALL ERR_PRINT( error-number INTEGER )

Notes:

  1. error-number is a runtime error or an Informix SQL error.
  2. For development only.

Warnings:

  1. Informix SQL error numbers can only be supported if the program is connected to an Informix database.

See also: ERRORLOG(), STARTLOG(), ERR_QUIT(), ERR_GET(), Exceptions.


ERR_QUIT( )

Purpose:

This function prints in the error line the text corresponding to an error number and terminates the program.

Context:

  1. At any place in the program.

Syntax:

CALL ERR_QUIT( error-number INTEGER )

Notes:

  1. error-number is a runtime error or an Informix SQL error.
  2. For development only.

Warnings:

  1. Informix SQL error numbers can only be supported if the program is connected to an Informix database.

See also: ERRORLOG(), STARTLOG(), ERR_QUIT(), ERR_GET(), Exceptions.


ERRORLOG( )

Purpose:

This function copies the string passed as parameter into the error log file.

Context:

  1. At any place in the program.

Syntax:

CALL ERRORLOG( text STRING )

Notes:

  1. text is the character string to be inserted in the error log file.
  2. The error log must be started with STARTLOG().

See also: STARTLOG(), Exceptions.


SHOWHELP( )

Purpose:

This function function displays a runtime help message, corresponding to its specified argument, from the current help file.

Context:

  1. At any place in the program.

Syntax:

CALL SHOWHELP( help-number INTEGER )

Notes:

  1. help-number is the help message number in the current help file.
  2. You set the current help file with the HELP FILE clause of the OPTIONS instruction.

See also: OPTIONS, Message Files.


STARTLOG( )

Purpose:

This function initializes error logging and opens the error log file passed as the parameter.

Context:

  1. At the beginning of the program.

Syntax:

CALL STARTLOG( filename STRING )

Notes:

  1. filename is the name of the error log file.
  2. Runtime errors are automatically reported.
  3. You can insert error records manually with the ERRORLOG() function.

Usage:

Call STARTLOG() in the MAIN program block to open or create an error log file. After STARTLOG() has been invoked, a record of every subsequent error that occurs during the execution of your program is written in the error log file. If you need to report specific application errors, use the ERRORLOG() function to make an entry in the error log file.

The default format of an error record consists of the date, time, source-module name and line number, error number, and error message. If you invoke the STARTLOG() function, the format of the error records appended to the error log file after each subsequent error are as follows:

Date: 03/06/99 Time: 12:20:20
Program error at "stock_one.4gl", line number 89.
SQL statement error number -239.
Could not insert new row - duplicate value in a UNIQUE INDEX column.
SYSTEM error number -100
ISAM error: duplicate value for a record with unique key.

The STARTLOG() and ERRORLOG() functions can be used for instrumenting a program, to track how the program is used. This use is not only valuable for improving the program but also for recording work habits and detecting attempts to breach security.

If the argument of STARTLOG() is not the name of an existing file, STARTLOG() creates one. If the file already exists, STARTLOG() opens it and positions the file pointer so that subsequent error messages can be appended to this file. The following program fragment invokes STARTLOG(), specifying the name of the error log file in a quoted string that includes a pathname and a file extension. The function definition includes a call to the built-in ERRORLOG() function, which adds a message to the error log file.

See also: ERRORLOG(), Exceptions.


FGL_BUFFERTOUCHED( )

Purpose:

This function returns TRUE if the input buffer was modified after the current field was selected.

Context:

  1. In AFTER FIELD, AFTER INPUT, AFTER CONSTRUCT, ON KEY, ON ACTION blocks.

Syntax:

CALL FGL_BUFFERTOUCHED( ) RETURNING result INTEGER

Notes:

  1. returns TRUE if the input buffer has been touched after the current field was selected.

Warnings:

  1. This function is not equivalent to FIELD_TOUCHED(): The flag returned by FGL_BUFFERTOUCHED() is reset when you enter a new field, while FIELD_TOUCHED() returns always TRUE for a field that was modified during the interactive instruction.

See also: FGL_DIALOG_SETBUFFER(), FGL_DIALOG_GETBUFFER().


FGL_DIALOG_GETBUFFER( )

Purpose:

This function returns the value of the current field as a string.

Context:

  1. In INPUT , INPUT ARRAY, CONSTRUCT instructions.

Syntax:

CALL FGL_DIALOG_GETBUFFER( ) RETURNING result STRING

Notes:

  1. Returns the content of the input buffer of the current field.
  2. Only useful in a CONSTRUCT instruction, because there is no variable associated to fields in this case.

See also: FGL_DIALOG_SETBUFFER(), FGL_BUFFERTOUCHED(), GET_FLDBUF().


FGL_DIALOG_SETBUFFER( )

Purpose:

This function sets the input buffer of the current field, and assigns corresponding program variable when using UNBUFFERED mode.

Context:

  1. In INPUT , INPUT ARRAY, CONSTRUCT instructions.

Syntax:

CALL FGL_DIALOG_SETBUFFER( value STRING )

Notes:

  1. value is the text to set in the current input buffer.
  2. Only useful in a CONSTRUCT instruction, because there is no variable associated to fields in this case.

Warnings:

  1. With the default buffered input mode, this function modifies the input buffer of the current field; the corresponding input variable is not assigned. It makes no sense to call this function in BEFORE FIELD blocks of INPUT and INPUT ARRAY. However, if the statement is using the UNBUFFERED mode, the function will set both the field buffer and the program variable. If the string set by the function does not represent a valid value that can be stored by the program variable, the buffer and the variable will be set to NULL.

  2. This function sets the 'touched' flag of the current form field, and the 'touched' flag of the dialog. Therefore, both FIELD_TOUCHED() and FGL_BUFFERTOUCHED() would return TRUE if you call this function.

See also: FGL_DIALOG_GETBUFFER(), FGL_BUFFERTOUCHED(), GET_FLDBUF().


FGL_DIALOG_GETFIELDNAME( )

Purpose:

This function returns the name of the current input field.

Context:

  1. In INPUT , INPUT ARRAY, CONSTRUCT or DISPLAY ARRAY instructions.

Syntax:

CALL FGL_DIALOG_GETFIELDNAME( ) RETURNING result STRING

Notes:

  1. Returns the name of the current input field.

Warnings:

  1. Only the column part of the field name is returned.

See also: FGL_DIALOG_INFIELD()


FGL_DIALOG_INFIELD( )

Purpose:

This function returns TRUE if the field passed as the parameter is the current input field.

Context:

  1. In INPUT , INPUT ARRAY, CONSTRUCT or DISPLAY ARRAY instructions.

Syntax:

CALL FGL_DIALOG_INFIELD( field-name STRING ) RETURNING result INTEGER

Notes:

  1. field-name is the name if the form field.

Warnings:

  1. Only the column part of the field name is used.

See also: INFIELD()


FGL_DIALOG_SETCURSOR( )

Purpose:

This function sets the position of the input cursor in the current field.

Context:

  1. In interactive instructions.

Syntax:

CALL FGL_DIALOG_SETCURSOR( index INTEGER )

Notes:

  1. index is the character position in the text.

See also: FGL_GETCURSOR().


FGL_DIALOG_SETFIELDORDER( )

Purpose:

This function enables or disables field order constraint.

Context:

  1. At the beginning of the program or around INPUT instructions.

Syntax:

CALL FGL_DIALOG_SETFIELDORDER( active INTEGER )

Notes:

  1. When active is TRUE, the field order is constrained.
  2. When active is FALSE, the field order is not constrained.

Usage:

Typical BDL applications control user input with BEFORE FIELD and AFTER FIELD blocks. In many cases the field order and  the sequential execution of AFTER FIELD blocks is important in order to validate the data entered by the user. But with graphical front ends you can use the mouse to move to a field. By default the runtime system executes all BEFORE FIELD and AFTER FIELD blocks of the fields used by the interactive instruction, from the origin field to the target field selected by mouse click. If needed, you can force the runtime system to ignore all intermediate field triggers, by calling this function with a FALSE attribute.


FGL_DIALOG_SETCURRLINE( )

Purpose:

This function moves to a specific row in a record list.

Context:

  1. During a DISPLAY ARRAY or INPUT ARRAY instruction.

Syntax:

CALL FGL_DIALOG_SETCURRLINE( line INTEGER, row INTEGER )

Notes:

  1. line is the line number in the screen array.
  2. row is the row number is the array variable.

Warnings:

  1. The line parameter is ignored in GUI mode.
  2. You can use the FGL_SET_ARR_CURR() function instead.
  3. Control blocks like BEFORE ROW and field/row validation in INPUT ARRAY are performed, as if the user moved to another row, except when the function is called in BEFORE DISPLAY or BEFORE INPUT.

FGL_SET_ARR_CURR( )

Purpose:

This function moves to a specific row in a record list.

Context:

  1. During a DISPLAY ARRAY or INPUT ARRAY instruction.

Syntax:

CALL FGL_SET_ARR_CURR( row INTEGER )

Notes:

  1. row is the row number is the array variable.

Usage:

This function is typically used to control navigation in a DISPLAY ARRAY or INPUT ARRAY.

When a new row is reaching by using with this function, the first field editable gets the focus.

Warning: Control blocks like BEFORE ROW and field/row validation in INPUT ARRAY are performed, as if the user moved to another row, except when the function is called in BEFORE DISPLAY or BEFORE INPUT.


FGL_SETENV( )

Purpose:

This function sets the value of an environment variable.

Context:

  1. At any place in the program.

Syntax:

CALL FGL_SETENV( variable STRING, value STRING )

Notes:

  1. variable is the name of the environment variable.
  2. value is the value to be set.

Warnings:

  1. Use this function at your own risk: You may experience unexpected results if you change environment variables that are already used by the current program - for example, when you are connected to INFORMIX and you change the INFORMIXDIR environment variable.
  2. There is a little difference between Windows and UNIX platforms when passing a NULL as the value parameter: On Windows, the environment variable is removed, while on UNIX, the environment variable gets an empty value (i.e. it is not removed from the environment).

See also: FGL_GETENV()


FGL_DRAWBOX( )

Purpose:

This function draws a rectangle based on the character terminal coordinates in the current open window.

Context:

  1. At any place in the program.

Syntax:

CALL FGL_DRAWBOX( height, width, line, column, color INTEGER )

Warnings:

  1. This function is provided for backward compatibility.

See also: FGL_DRAWLINE()


FGL_DRAWLINE( )

Purpose:

This function draws a line based on the character terminal coordinates in the current open window.

Context:

  1. At any place in the program.

Syntax:

CALL FGL_DRAWLINE( posX, posY, width, color INTEGER )

Warnings:

  1. This function is provided for backward compatibility.

See also: FGL_DRAWBOX()


FGL_LASTKEY( )

Purpose:

This function returns the key code of the last key pressed by the user.

Context:

  1. Any interactive instruction.

Syntax:

CALL FGL_LASTKEY( ) RETURNING result INTEGER

Notes:

  1. The function returns NULL if no key has been pressed.

Warnings:

  1. This function is provided for backward compatibility.

See also: FGL_KEYVAL().


FGL_KEYVAL( )

Purpose:

This function returns the key code of a logical or physical key.

Context:

  1. At any place in the program.

Syntax:

CALL FGL_KEYVAL( character STRING ) RETURNING result INTEGER

Notes:

  1. character can be a single character, a digit, a printable symbol like @, #, $ or a special keyword.
  2. Keywords recognized by FGL_KEYVAL() are: ACCEPT, HELP, NEXT, RETURN, DELETE, INSERT, NEXTPAGE, RIGHT, DOWN, INTERRUPT, PREVIOUS, TAB, ESC, ESCAPE, LEFT, PREVPAGE, UP, F1 through F64, CONTROL-character ( except A, D, H, I, J, L, M, R, or X )
  3. If you specify a single character, FGL_KEYVAL() considers the case. In all other instances, the function ignores the case of its argument, which can be uppercase or lowercase letters.
  4. The function returns NULL if the parameter does not correspond to a valid key.

Warnings:

  1. This function is provided for backward compatibility especially for TUI mode applications. FGL_KEYVAL() is well supported in text mode, but this function can only be emulated in GUI mode, because the front-ends communicate with the runtime system with other events as keystrokes.

Usage:

FGL_KEYVAL() can be used in form-related statements to examine a value returned by the FGL_LASTKEY() function.

To determine whether the user has performed an action, such as inserting a row, specify the logical name of the action (such as INSERT) rather than the name of the physical key (such as F1). For example, the logical name of the default Accept key is ESCAPE. To test if the key most recently pressed by the user was the Accept key, specify FGL_KEYVAL("ACCEPT") rather than FGL_KEYVAL("escape") or FGL_KEYVAL("ESC"). Otherwise, if a key other than ESCAPE is set as the Accept key and the user presses that key, FGL_LASTKEY() does not return a code equal to FGL_KEYVAL("ESCAPE"). The value returned by FGL_LASTKEY() is undefined in a MENU statement.

See also: FGL_LASTKEY().


FGL_REPORT_PRINT_BINARY_FILE( )

Purpose:

This function prints a file containing binary data during a report.

Context:

  1. In a REPORT routine.

Syntax:

CALL FGL_REPORT_PRINT_BINARY_FILE( filename STRING )

Notes:

  1. filename is the name of the binary file.

Warnings:

  1. This function is provided for backward compatibility.

FGL_REPORT_SET_DOCUMENT_HANDLER( )

Purpose:

This function redirects the next report to an XML document handler.

Context:

  1. Before / After the execution of a REPORT.

Syntax:

CALL FGL_REPORT_SET_DOCUMENT_HANDLER( handler om.SaxDocumentHandler )

Notes:

  1. handler is the document handler variable.

FGL_GETCURSOR( ) / FGL_DIALOG_GETCURSOR()

Purpose:

This function returns the position of the edit cursor in the current field.

Context:

  1. In interactive instructions.

Syntax:

CALL FGL_GETCURSOR( ) RETURNING index INTEGER

Notes:

  1. index is the character position in the text.

See also: FGL_DIALOG_SETCURSOR().


FGL_GETWIN_HEIGHT( )

Purpose:

This function returns the number of rows of the current window.

Context:

  1. At any place in the program.

Syntax:

CALL FGL_GETWIN_HEIGHT( ) RETURNING result INTEGER

Warnings:

  1. This function is provided for backward compatibility.

See also: FGL_GETWIN_WIDTH().


FGL_GETWIN_WIDTH( )

Purpose:

This function returns the width of the current window as a number of columns.

Context:

  1. At any place in the program.

Syntax:

CALL FGL_GETWIN_WIDTH( ) RETURNING result INTEGER

Warnings:

  1. This function is provided for backward compatibility.

See also: FGL_GETWIN_WIDTH().


FGL_GETWIN_X( )

Purpose:

This function returns the horizontal position of the current window.

Context:

  1. At any place in the program.

Syntax:

CALL FGL_GETWIN_X( ) RETURNING result INTEGER

Warnings:

  1. This function is provided for backward compatibility.

See also: FGL_GETWIN_Y().


FGL_GETWIN_Y( )

Purpose:

This function returns the vertical position of the current window.

Context:

  1. At any place in the program.

Syntax:

CALL FGL_GETWIN_X( ) RETURNING result INTEGER

Warnings:

  1. This function is provided for backward compatibility.

See also: FGL_GETWIN_X().


LENGTH( )

Purpose:

This function returns the number of bytes of the expression passed as parameter.

Context:

  1. At any place in the program.

Syntax:

CALL LENGTH( expression ) RETURNING result INTEGER

Notes:

  1. expression is any valid expression.
  2. Trailing blanks are not counted in the length of the string.
  3. If the parameter is NULL, the function returns zero.

Warnings:

  1. The function counts bytes, not characters. This is important in a multi-byte environment.
  2. Most database servers support an equivalent scalar function in the SQL language, but the result may be different from the FGL built-in function. For example, Oracle's LENGTH() function returns NULL when the string is empty. 

See also: FGL_WIDTH().


FGL_GETVERSION( )

Purpose:

This function returns the build number of the runtime system.

Context:

  1. At any place in the program.

Syntax:

CALL FGL_GETVERSION( ) RETURNING result STRING

Warnings:

  1. Provided for debugging info only; please do not write business code dependent on the build number.
  2. The format of the build number returned by this function is subject of change in future versions.

FGL_GETHELP( )

Purpose:

Returns the help text according to its identifier by reading the current help file.

Context:

  1. At any place in the program, after the definition of the current help file (OPTIONS HELP FILE).

Syntax:

CALL FGL_GETHELP( id INTEGER ) RETURNING result STRING

Notes:

  1. id is the help text identifier.

See also: The OPTIONS instruction.


FGL_GETPID( )

Purpose:

This function returns the system process identifier.

Context:

  1. At any place in the program.

Syntax:

CALL FGL_GETPID() RETURNING result INTEGER

Notes:

  1. The process identifier is provided by the operating system; it is normally unique.

See also: FGL_SYSTEM().


FGL_DIALOG_GETBUFFERSTART( )

Purpose:

This function returns the row offset of the page to feed a paged display array.

Syntax:

CALL FGL_DIALOG_GETBUFFERSTART( ) RETURNING result INTEGER

Usage:

See DISPLAY ARRAY


FGL_DIALOG_GETBUFFERLENGTH( )

Purpose:

This function returns the number of rows of the page to feed a paged display array.

Syntax:

CALL FGL_DIALOG_GETBUFFERLENGTH( ) RETURNING result INTEGER

Usage:

See DISPLAY ARRAY


FGL_PUTFILE

Purpose:

Transfers a file from the application server machine to the front end workstation.

Syntax:

CALL fgl_putfile(src STRING, dst STRING)

Notes:

  1. src contains the name of the source file to send.
  2. dst contains the name of the file to write on the front end.

FGL_GETFILE

Purpose:

Transfers a file from the front end workstation to the application server machine.

Syntax:

CALL fgl_getfile(src STRING, dst STRING)

Notes:

  1. src contains the name of the source file to retrieve from the front end workstation.
  2. dst contains the name of the file to write on the server side.

FGL_GETENV( )

Purpose:

This function returns the value of the environment variable having the name you specify as the argument.

Syntax:

CALL FGL_GETENV( variable STRING ) RETURNING result STRING

Notes:

  1. variable is the name of the environment variable.
  2. If the specified environment variable is not defined, the function returns a NULL value.
  3. If the environment variable is defined but does not have a value assigned to it, the function returns blank spaces.

Warnings:

  1. If the returned value can be a long character string, be sure to declare the receiving variable with sufficient size to store the character value returned by the function. Otherwise, the value will be truncated.

Usage:

The argument of FGL_GETENV() must be the name of an environment variable. If the requested value exists in the current user environment, the function returns it as a character string and then returns control of execution to the calling context. 

See also: FGL_SETENV()


FGL_GETKEYLABEL( )

Purpose:

This function returns the default label associated to a key.

Syntax:

CALL FGL_GETKEYLABEL( keyname STRING ) RETURNING result STRING

Notes:

  1. keyname is the logical name of a key such as F11 or DELETE, INSERT, CANCEL.

Warnings:

  1. This function is provided for backward compatibility.

See also: FGL_SETKEYLABEL(), FGL_DIALOG_GETKEYLABEL().


FGL_SETKEYLABEL( )

Purpose:

This function sets the default label associated to a key.

Syntax:

CALL FGL_SETKEYLABEL( keyname STRING, label STRING )

Notes:

  1. keyname is the logical name of a key such as F11 or DELETE, INSERT, CANCEL.
  2. label is the text associated to the key. 

Warnings:

  1. This function is provided for backward compatibility.

See also: FGL_SETKEYLABEL(), FGL_DIALOG_SETKEYLABEL().


FGL_DIALOG_GETKEYLABEL( )

Purpose:

This function returns the label associated to a key for the current interactive instruction.

Syntax:

CALL FGL_DIALOG_GETKEYLABEL( keyname STRING ) RETURNING result STRING

Notes:

  1. keyname is the logical name of a key such as F11 or DELETE, INSERT, CANCEL.

Warnings:

  1. This function is provided for backward compatibility.

See also: FGL_SETKEYLABEL(), FGL_DIALOG_SETKEYLABEL().


FGL_DIALOG_SETKEYLABEL( )

Purpose:

This function sets the label associated to a key for the current interactive instruction.

Syntax:

CALL FGL_DIALOG_SETKEYLABEL( keyname STRING, label STRING )

Notes:

  1. keyname is the logical name of a key such as F11 or DELETE, INSERT, CANCEL.
  2. label is the text associated to the key. 

Warnings:

  1. This function is provided for backward compatibility.

See also: FGL_SETKEYLABEL(), FGL_DIALOG_GETKEYLABEL().


FGL_SETSIZE( )

Purpose:

This function sets the size of the main application window.

Syntax:

CALL FGL_SETSIZE( width INTEGER, height INTEGER )

Notes:

  1. width is the number of columns of the window.
  2. height is the number of lines of the window.

Warnings:

  1. This function is provided for backward compatibility.

See also: FGL_SETTITLE().


FGL_SETTITLE( )

Purpose:

This function sets the title of the main application window.

Syntax:

CALL FGL_SETTITLE( label STRING )

Notes:

  1. label is the text of the title. 

Warnings:

  1. This function is provided for backward compatibility.

See also: FGL_SETSIZE().


FGL_SYSTEM( )

Purpose:

This function starts a program in a UNIX terminal emulator when using a graphical front end.

Syntax:

CALL FGL_SYSTEM( command STRING )

Notes:

  1. command is the command line to be executed on the server. 

Warnings:

  1. This function is provided for backward compatibility.

Usage:

The function starts a program that needs a UNIX terminal emulator when using the Windows Front End, even if the current program has been started without a visible terminal. The command parameter is a string or variable that contains the commands to be executed. The UNIX terminal will be raised and activated. The terminal is automatically lowered when the child process finishes.

See also: WINEXEC().


FGL_WIDTH()

Purpose:

This function returns the number of columns needed to represent the printed version of the expression.

Context:

  1. At any place in the program.

Syntax:

CALL FGL_WIDTH( expression ) RETURNING result INTEGER

Notes:

  1. expression is any valid expression.
  2. Trailing blanks are counted in the length of the string.
  3. If the parameter is NULL, the function returns zero.

See also: LENGTH().


FGL_WINDOW_GETOPTION( )

Purpose:

This function returns attributes of the current window.

Syntax:

CALL FGL_WINDOW_GETOPTION( attribute STRING ) RETURNING result STRING

Notes:

  1. attribute is the name of a window attribute. This can be one of name, x, y, width, height, formline, messageline.

Warnings:

  1. This function is provided for backward compatibility.

FGL_GETRESOURCE( )

Purpose:

This function returns the value of an FGLPROFILE entry.

Context:

  1. At any place in the program.

Syntax:

CALL FGL_GETRESOURCE( name STRING ) RETURNING result STRING

Notes:

  1. name is the FGLPROFILE entry name to be read.
  2. If the entry does not exist in the configuration file, the function returns NULL.
  3. See also FGLPROFILE definition.

Warnings:

  1. FGLPROFILE entry names are not case sensitive.

ORD( )

Purpose:

This function accepts as its argument a character expression and returns the integer value of the first byte of that argument.

Context:

  1. At any place in the program.

Syntax:

CALL ORD( source STRING ) RETURNING result INTEGER

Notes:

  1. source is a string expression.
  2. This function is case-sensitive.
  3. Only the first byte of the argument is evaluated.
  4. Returns NULL if the argument passed is not valid.
  5. For a default (U.S. English) locale, this function is the logical inverse of the ASCII() operator.

See also: FGL_KEYVAL(), ASCII().


DOWNSHIFT( )

Purpose:

This function returns returns a string value in which all uppercase characters in its argument are converted to lowercase.

Context:

  1. At any place in the program.

Syntax:

CALL DOWNSHIFT( source STRING ) RETURNING result STRING

Notes:

  1. source is the character string to convert to lowercase letters.
  2. Non-alphabetic or lowercase characters are not altered.

Warnings:

  1. Conversion depends on locale settings (the LC_CTYPE environment variable).

See also: UPSHIFT().


UPSHIFT( )

Purpose:

This function returns a string value in which all lowercase characters in its argument are converted to uppercase.

Context:

  1. At any place in the program.

Syntax:

CALL UPSHIFT( source STRING ) RETURNING result STRING

Notes:

  1. source is the character string to convert to uppercase letters.
  2. Non-alphabetic or uppercase characters are not altered.

Warnings:

  1. Conversion depends on locale settings (the LC_CTYPE environment variable).

See also: DOWNSHIFT().


The key code table

Warning: These are internal key codes. Avoid hardcoding these numbers in your sources; otherwise your 4gl source will not be compatible with future versions of Genero FGL. Always use the FGL_KEYVAL(keyname) function instead.

Value Key name Description
1 to 26 Control-x Control key,  where x is the any letter from A to Z. The key code corresponding to Control-A is 1, Control-B is 2, etc.
others < 256 ASCII chars Other codes correspond to the ASCII characters set.
2000 up The up-arrow logical key.
2001 down The down-arrow logical key.
2002 left The left-arrow logical key.
2003 right The right-arrow logical key.
2005 nextpage The next-page logical key.
2006 prevpage The previous-page logical key.
2008 help The help logical key.
2011 interrupt The interrupt logical key.
2012 home The home logical key.
2013 end The end logical key.
2016 accept The accept logical key.
2017 backspace The backspace logical key.
3000 to 3255 Fx Function key, where x is the number of the function key. The key code corresponding to a function key Fx is 3000+x-1, for example, 3011 corresponds to F12.