MC-Basic:COMMON or DIM SHARED var name AS NOTE or ERROR ascii number

From SoftMC-Wiki
Jump to: navigation, search
Language: English  • 中文(简体)‎

Creates a user exception and defines a corresponding error message.

An exception may be declared at either the system or task levels. The interpreter and error handler processes an application exception as it does with any other internal error or note. The application exception may be trapped with TRY/CATCH, ONERROR or ONSYSTEMERROR, and the system responds by stopping the task or motion according to the exception severity.

You can specify an exception number from 20001 to 22498. If no exception number is specified, the system assigns an arbitrary numeric value within the range 22499 to 22999. Do not assume this value will be the same from load to load.

<message> is the exception message to be printed when the exception is invoked. The exception can be deleted from the system using the DELETEVAR command.

Syntax

common shared <name> as error "<message>" [number]
dim shared <name> as error "<message>" [number]
common shared <name> as note "<message>" [number]
dim shared <name> as note "<message>" [number]

Availability

All versions

Scope

Configuration, Task or Terminal

Since Version 4.17.5 the global (common shared) declaration is also possible from Task and Library contexts. Both parameters of user error/note (message and number) can be reassigned during the loading of the declaring task or library.

Limitations

  • Severity may be only Note or Error.
  • The exception number must be unique.
  • Array and subroutine definitions are not supported

Examples

Common Shared MyErr as Error "App Error" 20001
common shared err as error "My Error"

See Also