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 20899. If no exception number is specified, the system assigns an arbitrary numeric value within the range 20900 to 21000. 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 ?'"`UNIQ--nowiki-00000001-QINU`"'? Dim As Note ?'"`UNIQ--nowiki-00000002-QINU`"'? Error <Message> [<exception number>]

Availability

All versions

Scope

Configuration, Task or Terminal

Since Version 4.5.17 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

See Also