ERROR

Concept Link IconSee also

Return the error code, program name, function name, or line number of the last error.

WebVue support - Yes.

Mode

Mnemonic

Syntax

1 ERRNO 1
2 PROGRAM 2
3 FUNCTION 2
4 LINE 1
5 TOFILE 3

Syntax 1

IntVal = ERROR(Mode);

Return type: INTEGER.

Execution

Mode

Mnemonic

Action

1

ERRNO

Return the last error code that occurred.

 

 

Return:

0 = No error.
1 = Incorrect string argument.
2 = The value is below the lower limit.
3 = The value is above the higher limit.
5 = The file is already open (FOPEN).
6 = The file is already closed (FCLOSE, FSEEK, FPUTS).
7 = The file failed to open (FOPEN).

4

LINE

Return the line number where the error last occurred.

Syntax 2

IntVal = ERROR(Mode);

Return type: STR.

Execution

Mode

Mnemonic

Action

2

PROGRAM

Return the name of the program where the error last occurred.

3

FUNCTION

Return the name of the function where the error last occurred.

Syntax 3

IntVal = ERROR(Mode, Filename);

Return type: INTEGER.

Execution

Mode

Mnemonic

Action

5

TOFILE

Redirects all the errors, which are displayed in the debug window to the specified filename. To disable redirection enter "" for the filename. If executed in a WebVue session context this instruction is processed by the computer that hosts the web back end and the file is created on that computer.

 

 

Return: The name of the program where the error last occurred.

Use \\ to specify the path to be used, so as to generate single \'s in the path string. If the path is not specified, the file is created by default in the TP folder of the project.

Example

SUB Main()

DIM intResult as integer;

'open the file

intResult = Error("TOFILE","errorfile.txt");

If (FOPEN("MESSAGE.TXT","R")==0) Then

  'If error in opening:

  PRINT ("code=\t",ERROR("ERRNO"));

  PRINT ("prog=\t",ERROR("PROGRAM"));

  PRINT ("fonc=\t",ERROR("FUNCTION"));

  PRINT ("line=\t",ERROR("LINE"));

Else

  'If no error in opening MESSAGE.TXT:

  '...

End If

END SUB