Freigeben über


LINENO( ) Function

Returns the line number of a line being executed in a program relative to the first line of the main program.

LINENO([1])

Return Values

Numeric

Parameters

  • 1
    Returns the line number relative to the first line of the current program or procedure. If you omit the 1 argument, the line number is returned relative to the first line of the main program.

Remarks

Program lines are counted starting from the top of the program. Comment lines, continuation lines, and blank lines are included in the line number count. If a program is suspended during execution, LINENO( ) returns the number of the program line at which program execution was suspended. LINENO( ) returns 0 if a program is canceled.

By default, line numbers are returned relative to the beginning of the main program. If a procedure is called, line numbering continues from the top of the calling program.

LINENO( ) is useful for debugging programs. You can set a breakpoint to stop program execution at a specific line number by opening the Breakpoints window, setting the Type to 'Break when expression is true' and adding LINENO( ) = nExpression in the Expression textbox.

Example

The following example is part of a simple error-handling routine.

ON ERROR DO bug_proc WITH LINENO( )
BRWS  && Causes an error
ON ERROR

** Bug_Proc error handler **

PROCEDURE bug_proc
PARAMETERS gnBadLine
WAIT WINDOW 'Error occurred at line: ' + ALLTRIM(STR(gnBadLine))
RETURN

See Also

ERROR( ) | MESSAGE( ) | PROGRAM( ) | SYS(16) - Executing Program File Name | Error Messages A-Z | Error Messages by Number