Supported On | UX* WS DOS |
Option Required | KBD |
Keyboard Executable | No |
Programmable | Yes |
In an IF ... THEN ... | Yes |
OFF CDIAL disables any ON CDIAL branching currently set up.
OFF CDIAL
IF Done THEN OFF CDIAL
When using HP BASIC/UX on HP-UX systems running X Windows, devices to be addressed using OFF CDIAL must not have been opened by the X Windows server. These devices must also be connected to the local system since they cannot be accessed on a remote system. See the section "Opening Input Devices" in the chapter "System-Level Customization" found in the Using the X Window System, Version 11 manual, for details on how to prevent the X Window server from opening specified HIL devices.
Supported On | UX* WS DOS IN* |
Option Required | CLOCK |
Keyboard Executable | No |
Programmable | Yes |
In an IF ... THEN ... | Yes |
OFF CYCLE cancels event-initiated branches previously defined and enabled by an ON CYCLE statement.
OFF CYCLE
IF Stop_timer THEN OFF CYCLE
OFF CYCLE destroys the log of any CYCLE event which has already occurred but which has not been serviced.
If OFF CYCLE is executed in a subprogram such that it cancels an ON CYCLE in the calling context, the ON CYCLE definition is restored upon returning to the calling context.
Resolution is 20 milliseconds for Series 300/400, and 10 milliseconds for Series 700. A new child process of HP BASIC/UX is started for the timer.
Supported On | UX* WS DOS |
Option Required | CLOCK |
Keyboard Executable | No |
Programmable | Yes |
In an IF ... THEN ... | Yes |
OFF DELAY cancels event-initiated branches previously defined and enabled by an ON DELAY statement.
OFF DELAY
IF Done THEN OFF DELAY
OFF DELAY destroys the log of any DELAY event which has already occurred but which has not been serviced.
If OFF DELAY is executed in a subprogram such that it cancels an ON DELAY in the calling context, the ON DELAY definition is restored upon returning to the calling context.
Resolution is 20 milliseconds for Series 300/400, and 10 milliseconds for Series 700. A new child process of HP BASIC/UX is started for the timer.
Supported On | UX WS DOS |
Option Required | None |
Keyboard Executable | No |
Programmable | Yes |
In an IF ... THEN ... | Yes |
OFF END cancels event-initiated branches previously defined and enabled by an ON END statement.
OFF END @File
IF Special THEN OFF END @Source
Item | Description | Range |
---|---|---|
I/O path name | name assigned to a mass storage file | any valid name (see ASSIGN) |
If OFF END is executed in a subprogram and cancels an ON END in the context which called the subprogram, the ON END definitions are restored when the calling context is restored.
If there is no ON END definition in a context, end-of-file (EOF) and end-of-record (EOR) are reported as errors.
Supported On | UX WS DOS |
Option Required | TRANS |
Keyboard Executable | No |
Programmable | Yes |
In an IF ... THEN ... | Yes |
OFF EOR cancels event-initiated branches previously defined and enabled by an ON EOR statement.
OFF EOR @Device
OFF EOR @File
Item | Description | Range |
---|---|---|
I/O path name | name assigned to a device, a group of devices, a mass storage file, or a pipe | any valid name |
The I/O path may be assigned either to a device, a group of devices, or to a mass storage file or pipe; however, if the I/O path is assigned to a BUFFER, an error is reported when the OFF EOR statement is executed.
OFF EOR destroys the log of any EOR event which has already occurred but which has not been serviced.
If OFF EOR is executed in a subprogram such that it cancels an ON EOR in the calling context, the ON EOR definition is restored upon returning to the calling context.
Supported On | UX WS DOS |
Option Required | TRANS |
Keyboard Executable | No |
Programmable | Yes |
In an IF ... THEN ... | Yes |
OFF EOT cancels event-initiated branches previously defined and enabled by an ON EOT statement.
OFF EOT @Device
OFF EOT @File
Item | Description | Range |
---|---|---|
I/O path name | name assigned to a device, a group of devices, a mass storage file, or a pipe | any valid name |
The I/O path may be assigned either to a device, a group of devices, or to a mass storage file or pipe; however, if the I/O path is assigned to a BUFFER, an error is reported when the OFF EOT statement is executed.
OFF EOT destroys the log of any EOT event which has already occurred but which has not been serviced.
If OFF EOT is executed in a subprogram such that it cancels an ON EOT in the calling context, the ON EOT definition is restored upon returning to the calling context.
Supported On | UX WS DOS IN |
Option Required | None |
Keyboard Executable | No |
Programmable | Yes |
In an IF ... THEN ... | Yes |
OFF ERROR cancels event-initiated branches previously defined and enabled by an ON ERROR statement. Subsequent errors are reported to the user in the usual fashion.
OFF ERROR
Supported On | UX WS* DOS* |
Option Required | None |
Keyboard Executable | No |
Programmable | Yes |
In an IF ... THEN ... | Yes |
OFF EXT SIGNAL cancels event-initiated branches previously defined by an ON EXT SIGNAL statement. This statement can be entered in the HP BASIC/UX/WS editor, but it executes only in HP BASIC/UX in X.
OFF EXT SIGNAL 4
OFF EXT SIGNAL
Item | Description | Range |
---|---|---|
signal number | numeric expression, rounded to integer | 1 through 32 (see ON EXT SIGNAL) |
Not specifying a system signal number disables the event-initiated branches for all system signals. Specifying a signal number causes the OFF EXT SIGNAL to apply to the event-initiated log entry for the specified signal only.
Any pending ON EXT SIGNAL branches for the affected signals are lost and further signals are vectored to the default handler for the EXT SIGNAL. See ON EXT SIGNAL for a description of the default actions for each EXT SIGNAL.
The action to be taken for an EXT SIGNAL is inherited when entering a new context (subprogram). This action stays in effect until an ON EXT SIGNAL or OFF EXT SIGNAL is executed. When an OFF EXT SIGNAL is executed within a context, the action for that external signal reverts to its default action. When the context is exited, the current action reverts to what it was in the calling context.
Supported On | UX* WS DOS |
Option Required | KBD |
Keyboard Executable | No |
Programmable | Yes |
In an IF ... THEN ... | Yes |
OFF HIL EXT disables an end-of-line interrupt previously enabled by an ON HIL EXT statement. When this statement is executed, any pending ON HIL EXT branch is canceled.
OFF HIL EXT
IF NOT Hil_active THEN OFF HIL EXT
When using HP BASIC/UX on HP-UX systems running X Windows, devices to be addressed using OFF HIL EXT must not have been opened by the X Windows server. These devices must also be connected to the local system since they cannot be accessed on a remote system. See the section "Opening Input Devices" in the chapter "System-Level Customization" found in the Using the X Window System, Version 11 manual, for details on how to prevent the X Window server from opening specified HIL devices.
Supported On | UX WS DOS IN |
Option Required | IO |
Keyboard Executable | No |
Programmable | Yes |
In an IF ... THEN ... | Yes |
OFF INTR cancels event-initiated branches previously defined by an ON INTR statement.
OFF INTR
OFF INTR 12
OFF INTR Hpib
Item | Description | Range |
---|---|---|
interface select code | numeric expression, rounded to an integer; Default = all interfaces | 5, and 7 through 31 |
Not specifying an interface select code disables the event-initiated branches for all interfaces. Specifying an interface select code causes the OFF INTR to apply to the event-initiated log entry for the specified interface only.
Any pending ON INTR branches for the affected interfaces are lost and further interrupts are ignored.
If OFF INTR is executed in a subprogram such that it cancels an ON INTR in the calling context, the ON INTR definition is restored upon returning to the calling context.
Supported On | UX WS DOS |
Option Required | None |
Keyboard Executable | No |
Programmable | Yes |
In an IF ... THEN ... | Yes |
OFF KBD cancels event-initiated branches previously defined and enabled by an ON KBD statement. Subsequent key-presses are sent to the operating system in the normal manner.
OFF KBD
IF NOT Process_keys THEN OFF KBD
When this statement is executed, any pending ON KBD branch is canceled, and the keyboard buffer is cleared.
If OFF KBD is executed in a subprogram such that it cancels an ON KBD in the calling context, the canceled ON KBD definition is restored when the calling context is restored. However, the keyboard buffer's contents are not restored with the calling context, because the buffer was cleared with the OFF KBD.
Supported On | UX WS DOS IN |
Option Required | KBD |
Keyboard Executable | No |
Programmable | Yes |
In an IF ... THEN ... | Yes |
OFF KEY cancels event-initiated branches previously defined and enabled by an ON KEY statement.
OFF KEY
OFF KEY 2
Item | Description | Range |
---|---|---|
key selector | numeric expression, rounded to an integer; Default = all keys | 0 through 19 |
Not specifying a softkey number disables the event-initiated branches for all softkeys. Specifying a softkey number causes the OFF KEY to apply to the specified softkey only. If OFF KEY is executed in a subprogram and cancels an ON KEY in the context which called the subprogram, the ON KEY definitions are restored when the calling context is restored.
Any pending ON KEY branches for the affected softkeys are lost. Pressing an undefined softkey generates a beep.
Supported On | UX* WS DOS |
Option Required | None |
Keyboard Executable | No |
Programmable | Yes |
In an IF ... THEN ... | Yes |
OFF KNOB cancels event-initiated branches previously defined and enabled by the ON KNOB statement.
OFF KNOB
Any pending ON KNOB branches are lost. Subsequent use of the knob results in normal scrolling or cursor movement.
Devices to be addressed using OFF KNOB must not have been opened by the X Windows server. These devices must also be connected to the local system since they cannot be accessed on a remote system. See the section "Opening Input Devices" in the chapter "System-Level Customization" found in the Using the X Window System, Version 11 manual, for details on how to prevent the X Window server from opening specified HIL devices.
Supported On | UX WS DOS |
Option Required | IO |
Keyboard Executable | No |
Programmable | Yes |
In an IF ... THEN ... | Yes |
OFF SIGNAL cancels event-initiated branches previously defined and enabled by an ON SIGNAL statement. If no signal selector is provided, all ON SIGNAL definitions are canceled. OFF SIGNAL only applies to the current context.
OFF SIGNAL
OFF SIGNAL Sig_number
Item | Description | Range |
---|---|---|
signal selector | numeric expression, rounded to an integer; Default = all keys | 0 through 15 |
Supported On | UX* WS DOS |
Option Required | CLOCK |
Keyboard Executable | No |
Programmable | Yes |
In an IF ... THEN ... | Yes |
OFF TIME cancels event-initiated branches previously defined and enabled by an ON TIME statement.
OFF TIME
IF Attended THEN OFF TIME
OFF TIME destroys the log of any TIME event that has occurred but has not been serviced.
If OFF TIME is executed in a subprogram such that it cancels an ON TIME in the calling context, the ON TIME definition is restored upon returning to the calling context.
Resolution is 20 milliseconds for Series 300/400, and 10 milliseconds for Series 700. A new child process of HP BASIC/UX is started for the timer.
Supported On | UX* WS DOS IN |
Option Required | None |
Keyboard Executable | No |
Programmable | Yes |
In an IF ... THEN ... | Yes |
OFF TIMEOUT cancels event-initiated branches previously defined and enabled by an ON TIMEOUT statement.
OFF TIMEOUT
OFF TIMEOUT 12
OFF TIMEOUT Hpib
Item | Description | Range |
---|---|---|
interface select code | numeric expression, rounded to an integer; Default = all interfaces | 7 through 31 |
Not specifying an interface select code disables the event-initiated branches for all interfaces. Specifying an interface select code causes the OFF TIMEOUT to apply to the event-initiated branches for the specified interface only. When OFF TIMEOUT is executed, no more timeouts can occur on the affected interfaces.
If OFF TIMEOUT is executed in a subprogram such that it cancels an ON TIMEOUT in the calling context, the ON TIMEOUT definition is restored upon returning to the calling context which includes the ON TIMEOUT event-branching and the previous timeout value that was specified for the interface.
All channels of MUX interfaces have timeouts disabled by OFF TIMEOUT without an interface select code.
Supported On | UX WS DOS |
Option Required | None |
Keyboard Executable | No |
Programmable | Yes |
In an IF ... THEN ... | Yes |
ON transfers program execution to one of several destinations selected by the value of the pointer.
ON X1 GOTO 100,150,170
IF Point THEN ON Point GOSUB First,Second,Third,Last
Item | Description | Range |
---|---|---|
pointer | numeric expression, rounded to an integer | 1 through 74 |
line number | integer constant identifying a program line | 1 through 32 766 (1 through 2 147 483 646 for HP BASIC/UX 700) |
line label | name of a program line | any valid name |
If the pointer evaluates to 1, the first line number or label is used. If the pointer evaluates to 2, the second line number or label is used, and so on. If GOSUB is used, the RETURN is to the line following the ON...GOSUB statement.
If the pointer evaluates to less than 1 or greater than the number of lines listed, error 19 results. The specified line numbers or labels must be in the same context as the ON statement.
Supported On | UX* WS DOS |
Option Required | KBD |
Keyboard Executable | No |
Programmable | Yes |
In an IF ... THEN ... | Yes |
ON CDIAL sets up and enables a branch to be taken upon sensing rotation of one of the dials on a "control dial" device.
ON CDIAL GOSUB Dial_serv_rtn
ON CDIAL,Priority CALL Dial_sub
Item | Description | Range |
---|---|---|
priority | numeric expression, rounded to an integer; Default = 1 | 1 through 15 |
line label | name of a program line | any valid line name |
line number | integer constant identifying a program line | 1 through 32 766 (1 through 2 147 483 646 for HP BASIC/UX 700) |
subprogram name | name of a SUB or CSUB subprogram | any valid name |
All CDIAL function registers are automatically cleared when ON CDIAL is executed.
The interrupt service routine for the branch initiated when one of the control dials is rotated should read the number of pulses with the CDIAL function.
If ON CDIAL is used to set up control dial interrupts and then disabled (with OFF CDIAL), the CDIAL function can still be used to determine valid information about control dials: however, note that subsequent pulses will not be accumulated into the CDIAL registers, and when a register is read with CDIAL, that register is automatically cleared by the system.
The most recent ON CDIAL (or OFF CDIAL) overrides any previous ON CDIAL branching. If the overriding branch is defined in another context (such as in a SUB subprogram or user-defined FN), then the overriding branch is canceled and the overridden branch is restored upon return to the calling context.
The ON CDIAL statement behaves like the ON KNOB and ON HIL EXT statements:
The priority can be specified, with the highest represented by a value of 15. (This is the highest user-specifiable priority; however, ON END and ON TIMEOUT have priorities of 16, and ON ERROR has a priority of 17.) An ON CDIAL branch can interrupt the currently executing program segment, if its priority is higher than the current SYSTEM PRIORITY (use SYSTEM$("SYSTEM PRIORITY") to determine the current priority).
Upon completion of the interrupt service routine, CALL and GOSUB branches are returned to the next line that would have been executed if the ON CDIAL branch had not been serviced; the system priority is returned to the value in effect before the ON CDIAL branch occurred. RECOVER forces the program to go directly to the specified line in the context containing the ON CDIAL statement; when RECOVER forces a change of context, the system priority is restored to the value which existed in the original (defining) context at the time that the context was exited.
CALL and RECOVER remain active (that is, they can initiate branches) when the context changes to a subprogram (SUB), unless the change in context is caused by a keyboard-originated CALL statement. GOSUB and GOTO remain active when the context changes to a subprogram, but the branch is not initiated until after the calling context is restored.
ON CDIAL branches are disabled by DISABLE, temporarily disabled when the program is executing an INPUT, LINPUT, or ENTER KBD... statement; and deactivated by OFF CDIAL.
ON CDIAL does not initiate branches for other "knob" devices (such as built-in knobs of 98203 keyboards or HIL mouse devices).
Devices to be addressed using ON CDIAL must not have been opened by the X Windows server. These devices must also be connected to the local system since they cannot be accessed on a remote system. See the section "Opening Input Devices" in the chapter "System-Level Customization" found in the Using the X Window System, Version 11 manual, for details on how to prevent the X Window server from opening specified HIL devices.
Supported On | UX* WS DOS IN* |
Option Required | CLOCK |
Keyboard Executable | No |
Programmable | Yes |
In an IF ... THEN ... | Yes |
ON CYCLE defines and enables an event-initiated branch to be taken each time the specified number of seconds has elapsed.
ON CYCLE Seconds,Priority CALL Sub_name
ON CYCLE Max_time RECOVER Backup
ON CYCLE 3600,3 GOTO 1200
Item | Description | Range |
---|---|---|
seconds | numeric expression, rounded to the nearest 0.01 second for HP BASIC/WS and HP BASIC/UX 700, and 0.02 second for HP BASIC/UX 300/400 | 0.01 through 167 772.16 |
priority | numeric expression, rounded to an integer; Default = 1 | 1 through 15 |
line label | name of a program line | any valid name |
line number | integer constant identifying a program line | 1 through 32 766 (1 through 2 147 483 646 for HP BASIC/UX 700) |
subprogram name | name of a SUB or CSUB subprogram | any valid name |
The most recent ON CYCLE (or OFF CYCLE) definition overrides any previous ON CYCLE definition. If the overriding ON CYCLE definition occurs in a context different from the one in which the overridden ON CYCLE occurs, the overridden ON CYCLE is restored when the calling context is restored, but the time value of the more recent ON CYCLE remains in effect. For more information on the behavior of ON CYCLE in different contexts, read the section "Branching Restrictions" in the chapter "Using the Clock and Timers" in the HP BASIC Programming Guide manual.
The priority can be specified, with the highest priority represented by 15. The highest user-defined priority (15) is less than the priority for ON ERROR, ON END, and ON TIMEOUT (whose priorities are not user-definable). ON CYCLE can interrupt service routines of other event-initiated branches with user-definable priorities, if the ON CYCLE priority is higher than the priority of the service routine (the current system priority). CALL and GOSUB service routines get the priority specified in the ON... statement which set up the branch that invoked them. The system priority is not changed when a GOTO branch is taken.
Any specified line label or line number must be in the same context as the ON CYCLE statement. CALL and GOSUB will return to the next line that would have been executed if the CYCLE event had not been serviced, and the system priority is restored to that which existed before the ON CYCLE branch was taken. RECOVER forces the program to go directly to the specified line in the context containing that ON CYCLE statement. When RECOVER forces a change of context, the system priority is restored to that which existed in the original (defining) context at the time that context was exited.
CALL and RECOVER remain active when the context changes to a subprogram, unless the change in context is caused by a keyboard-originated call. GOSUB and GOTO remain active when the context changes to a subprogram, but the branch cannot be taken until the calling context is restored.
ON CYCLE is disabled by DISABLE and deactivated by OFF CYCLE. If the cycle value is short enough that the computer cannot service it, the interrupt will be lost.
Resolution is 20 milliseconds for Series 300/400, and 10 milliseconds for Series 700. A new child process of HP BASIC/UX is started for the timer.
Supported On | UX* WS DOS |
Option Required | CLOCK |
Keyboard Executable | No |
Programmable | Yes |
In an IF ... THEN ... | Yes |
ON DELAY defines and enables an event-initiated branch to be taken after the specified number of seconds has elapsed.
ON DELAY Seconds,Priority CALL Sub_name
ON DELAY 3 GOTO 5710
ON DELAY Max_time,4 GOSUB No_operator
Item | Description | Range |
---|---|---|
seconds | numeric expression, rounded to the nearest 0.01 second for HP BASIC/WS and HP BASIC/UX 700, and 0.02 second for HP BASIC/UX 300/400 | 0.01 through 167 772.16 |
priority | numeric expression, rounded to an integer; Default = 1 | 1 through 15 |
line label | name of a program line | any valid line name |
line number | integer constant identifying a program line | 1 through 32 766 (1 through 2 147 483 646 for HP BASIC/UX 700) |
subprogram name | name of a SUB or CSUB subprogram | any valid name |
The most recent ON DELAY (or OFF DELAY) definition overrides any previous ON DELAY definition. If the overriding ON DELAY definition occurs in a context different from the one in which the overridden ON DELAY occurs, the overridden ON DELAY is restored when the calling context is restored, but the time value of the more recent ON DELAY remains in effect. For more information on the behavior of ON DELAY in different contexts, read the section "Branching Restrictions" in the chapter "Using the Clock and Timers" in the HP BASIC Programming Guide.
The priority can be specified, with the highest priority represented by 15. The highest user-defined priority (15) is less than the priority for ON ERROR, ON END, and ON TIMEOUT (whose priorities are not user-definable). ON DELAY can interrupt service routines of other event-initiated branches with user-definable priorities, if the ON DELAY priority is higher than the priority of the service routine (the current system priority). CALL and GOSUB service routines get the priority specified in the ON... statement which set up the branch that invoked them. The system priority is not changed when a GOTO branch is taken.
Any specified line label or line number must be in the same context as the ON DELAY statement. CALL and GOSUB will return to the next line that would have been executed if the DELAY event had not been serviced, and the system priority is restored to that which existed before the ON DELAY branch was taken. RECOVER forces the program to go directly to the specified line in the context containing that ON DELAY statement. When RECOVER forces a change of context, the system priority is restored to that which existed in the original (defining) context at the time that context was exited.
CALL and RECOVER remain active when the context changes to a subprogram, unless the change in context is caused by a keyboard-originated call. GOSUB and GOTO remain active when the context changes to a subprogram, but the branch cannot be taken until the calling context is restored.
ON DELAY is disabled by DISABLE and deactivated by OFF DELAY.
Resolution is 20 milliseconds for Series 300/400, and 10 milliseconds for Series 700. A new child process of HP BASIC/UX is started for the timer.
Supported On | UX WS DOS |
Option Required | None |
Keyboard Executable | No |
Programmable | Yes |
In an IF ... THEN ... | Yes |
ON END defines and enables an event-initiated branch to be taken when end-of-file is reached on the mass storage file associated with the specified I/O path.
ON END @Source GOTO 500
ON END @File RECOVER Next_file
ON END @Path CALL Sub_name
Item | Description | Range |
---|---|---|
I/O path name | name assigned to a mass storage file | any valid name (see ASSIGN) |
line label | name of a program line | any valid line name |
line number | integer constant identifying a program line | 1 through 32 766 (1 through 2 147 483 646 for HP BASIC/UX 700) |
subprogram name | name of a SUB or CSUB subprogram | any valid name |
The ON END branch is triggered by any of the following events:
The priority associated with ON END is higher than priority l5. ON TIMEOUT has the same priority as ON END. ON ERROR has a higher priority than ON END. Both can interrupt an ON END service routine.
Any specified line label or line number must be in the same context as the ON END statement. CALL and GOSUB will return to the line immediately following the one during which the end-of-file occurred, and the system priority is restored to that which existed before the ON END branch was taken. RECOVER forces the program to go directly to the specified line in the context containing that ON END statement. When RECOVER forces a change of context, the system priority is restored to that which existed in the original (defining) context was exited.
CALL and RECOVER remain active when the context changes to a subprogram, if the I/O path name is known in the new context. CALL and RECOVER do not remain active if the context changes as a result of a keyboard-originated call. GOSUB and GOTO do not remain active when the context changes to a subprogram.
The end-of-record error (error 60) or the end-of-file error (error 59) can be trapped by ON ERROR if ON END is not active. ON END is deactivated by OFF END. DISABLE does not affect ON END.
Supported On | UX WS DOS |
Option Required | TRANS |
Keyboard Executable | No |
Programmable | Yes |
In an IF ... THEN ... | Yes |
ON EOR defines and enables an event-initiated branch to be taken when an end-of-record is encountered during a TRANSFER.
ON EOR @Path,Priority CALL Sub_name
ON EOR @Device GOTO 1500
ON EOR @File,2 GOSUB Label1
Item | Description | Range |
---|---|---|
I/O path name | name assigned to a device, a group of devices, a mass storage file, or a pipe | any valid name |
priority | numeric expression, rounded to an integer; Default = 1 | 1 through 15 |
line label | name of a program line | any valid line name |
line number | integer constant identifying a program line | 1 through 32 766 (1 through 2 147 483 646
for HP BASIC/UX 700) |
subprogram name | name of a SUB or CSUB subprogram | any valid name |
The I/O path may be assigned either to a device, a group of devices, or to a mass storage file or pipe. If the I/O path is assigned to a BUFFER, an error is reported when the ON EOR statement is executed.
If a TRANSFER statement uses an I/O path name which is local to a subprogram and the TRANSFER has not completed by the time the context is exited, returning to the original context will be deferred until the end of the TRANSFER; at that time the ON EOR event cannot be serviced. To ensure that the event will be serviced, a statement that cannot be executed in overlap with the TRANSFER must be executed before the context is exited. A WAIT FOR EOR @Non_buf statement is used for this purpose.
End-of-record delimiters are defined by the EOR parameters of the TRANSFER statement (i.e., DELIM, COUNT, or END). An EOR event occurs when any of the specified end-of-record delimiters is encountered during a TRANSFER. The event's occurrence is logged, and the specified branch is taken when system priority permits.
The most recent ON EOR (or OFF EOR) definition for a given I/O path name overrides any previous ON EOR definition. If the overriding ON EOR definition occurs in a context different from the one in which the overridden ON EOR occurs, the overridden ON EOR is restored when the calling context is restored.
The priority can be specified, with the highest priority represented by 15. The highest user-defined priority (15) is less than the priority for ON ERROR, ON END, and ON TIMEOUT (whose priorities are not user-definable). ON EOR can interrupt service routines of other event-initiated branches with user-definable priorities, if the ON EOR priority is higher than the priority of the service routine (the current system priority). CALL and GOSUB service routines get the priority specified in the ON... statement which set up the branch that invoked them. The system priority is not changed when a GOTO branch is taken.
Any specified line label or line number must be in the same context as the ON EOR statement. CALL and GOSUB will return to the next line that would have been executed if the EOR event had not been serviced, and the system priority is restored to that which existed before the ON EOR branch was taken. RECOVER forces the program to go directly to the specified line in the context containing that ON EOR statement. When RECOVER forces a change of context, the system priority is restored to that which existed in the original (defining) context at the time that context was exited.
CALL and RECOVER remain active when the context changes to a subprogram, unless the change in context is caused by a keyboard-originated call. GOSUB and GOTO remain active when the context changes to a subprogram, but the branch cannot be taken until the calling context is restored.
ON EOR is disabled by DISABLE and deactivated by OFF EOR.
Supported On | UX WS DOS |
Option Required | TRANS |
Keyboard Executable | No |
Programmable | Yes |
In an IF ... THEN ... | Yes |
ON EOT defines and enables an event-initiated branch to be taken when the last byte is transferred by a TRANSFER statement.
ON EOT @Path,Priority CALL Sub_name
ON EOT @Device GOTO 1500
ON EOT @File,2 GOSUB Label1
Item | Description | Range |
---|---|---|
I/O path name | name assigned to a device, a group of devices, a mass storage file, or a pipe | any valid name |
priority | numeric expression, rounded to an integer; Default = 1 | 1 through 15 |
line label | name of a program line | any valid line name |
line number | integer constant identifying a program line | 1 through 32 766 (1 through 2 147 483 646
for HP BASIC/UX 700) |
subprogram name | name of a SUB or CSUB subprogram | any valid name |
The I/O path may be assigned either to a device, a group of devices, or to a mass storage file or pipe. If the I/O path is assigned to a BUFFER, an error is reported when the ON EOT statement is executed.
If a TRANSFER statement uses an I/O path name which is local to a subprogram and the TRANSFER has not completed by the time the context is exited, returning to the original context will be deferred until the end of the TRANSFER; at that time the ON EOT event cannot be serviced. To ensure that the event will be serviced, a statement that cannot be executed in overlap with the TRANSFER must be executed before leaving the context. A WAIT FOR EOT @Non_buf statement is used for this purpose.
The most recent ON EOT (or OFF EOT) definition for a given path name overrides any previous ON EOT definition. If the overriding ON EOT definition occurs in a context different from the one in which the overridden ON EOT occurs, the overridden ON EOT is restored when the calling context is restored.
The priority can be specified, with the highest priority represented by 15. The highest user-defined priority (15) is less than the priority for ON ERROR, ON END, and ON TIMEOUT (whose priorities are not user-definable). ON EOT can interrupt service routines of other event-initiated branches with user-definable priorities, if the ON EOT priority is higher than the priority of the service routine (the current system priority). CALL and GOSUB service routines get the priority specified in the ON... statement which set up the branch that invoked them. The system priority is not changed when a GOTO branch is taken.
Any specified line label or line number must be in the same context as the ON EOT statement. CALL and GOSUB will return to the next line that would have been executed if the EOT event had not been serviced, and the system priority is restored to that which existed before the ON EOT branch was taken. RECOVER forces the program to go directly to the specified line in the context containing that ON EOT statement. When RECOVER forces a change of context, the system priority is restored to that which existed in the original (defining) context at the time that context was exited.
CALL and RECOVER remain active when the context changes to a subprogram, unless the change in context is caused by a keyboard-originated call. GOSUB and GOTO remain active when the context changes to a subprogram, but the branch cannot be taken until the calling context is restored.
ON EOT is disabled by DISABLE and deactivated by OFF EOT.
Supported On | UX WS DOS IN |
Option Required | None |
Keyboard Executable | No |
Programmable | Yes |
In an IF ... THEN ... | Yes |
ON ERROR defines and enables an event-initiated branch which results from a trappable error. This allows you to write your own error-handling routines.
ON ERROR GOTO 1200
ON ERROR RECOVER Crash
ON ERROR CALL Report
Item | Description | Range |
---|---|---|
line label | name of a program line | any valid name |
line number | integer constant identifying a program line | 1 through 32 766 (1 through 2 147 483 646 for HP BASIC/UX 700) |
subprogram name | name of a SUB or CSUB subprogram | any valid name |
The ON ERROR statement has the highest priority of any event-initiated branch. ON ERROR can interrupt any event-initiated service routine.
Any specified line label or line number must be in the same context as the ON ERROR statement. RECOVER forces the program to go directly to the specified line in the context containing the ON ERROR statement.
Returns via RETURN, SUBEXIT, or SUBEND from ON ERROR GOSUB or ON ERROR CALL routines are different from regular GOSUB or CALL returns. When ON ERROR is in effect, the program resumes at the beginning of the line where the error occurred. If the ON ERROR routine did not correct the cause of the error, the error is repeated. This causes an infinite loop between the line in error and the error handling routine. To avoid a retry of the line which caused the error, use ERROR RETURN instead of RETURN or ERROR SUBEXIT instead of SUBEXIT. When execution returns from the ON ERROR routine, system priority is restored to that which existed before the ON ERROR branch was taken.
CALL and RECOVER remain active when the context changes to a subprogram, unless the change in context is caused by a keyboard-originated call. In this case, the error is reported to the user, as if ON ERROR had not been executed.
GOSUB and GOTO do not remain active when the context changes to a subprogram. If an error occurs, the error is reported to the user, as if ON ERROR had not been executed.
If an execution error occurs while servicing an ON ERROR CALL or ON ERROR GOSUB, program execution stops. If an execution error occurs while servicing an ON ERROR GOTO or ON ERROR RECOVER routine, an infinite loop can occur between the line in error and the GOTO or RECOVER routine.
If an ON ERROR routine cannot be serviced because inadequate memory is available for the computer, the original error is reported and program execution pauses at that point.
ON ERROR is deactivated by OFF ERROR. DISABLE does not affect ON ERROR.
Supported On | UX WS* DOS* |
Option Required | n/a |
Keyboard Executable | No |
Programmable | Yes |
In an IF ... THEN ... | Yes |
ON EXT SIGNAL defines an event-initiated branch to be taken when a system generated signal is received (HP BASIC/UX only). This statement can be entered in the HP BASIC/UX/WS editor, but it executes only in HP BASIC/UX.
ON EXT SIGNAL 4 GOTO 10
ON EXT SIGNAL Sigusr2,12 GOSUB Fred
ON EXT SIGNAL Sigterm,15 CALL Terminate
Item | Description | Range |
---|---|---|
signal number | numeric expression, rounded to integer | (see Semantics) |
priority | numeric expression, rounded to an integer; Default = 1 | 1 through 15 |
line label | name of a program line | any valid line name |
line number | integer constant identifying a program line | 1 through 32 766 (1 through 2 147 483 646
for HP BASIC/UX 700) |
subprogram name | name of a SUB or CSUB subprogram | any valid name |
The ON EXT SIGNAL statement specifies a new action to be taken when a system generated signal is received by HP BASIC. If an ON EXT SIGNAL statement is not specified, then a default system action is be taken. The action for a specific EXT SIGNAL is specified in the table below. The two possible actions that can be taken are:
Exit | HP BASIC is immediately, but gracefully exited. |
Error | An error [number to be determined] is generated at the next end-of-line. |
All ON EXT SIGNAL actions take place at end-of-line except the default action to exit, which takes effect immediately upon receipt.
HP BASIC does not allow all system signals to be caught by users. The table below specifies all system signals, and indicates which can be specified in the EXT SIGNAL statements. All other values cause an error. This table also specifies the default EXT SIGNAL handling action which takes place in the absence of an ON EXT SIGNAL, or after an OFF EXT SIGNAL.
Signal\Number | Signal\Name | Valid\Signal | Default\Action | Comment
|
---|---|---|---|---|
1 | SIGHUP | yes | exit | hangup (lost connection) |
2 | SIGINT | no | - | BASIC CLR-I/O signal |
3 | SIGQUIT | no | - | BASIC RESET signal |
4 | SIGILL | no | - | illegal instruction |
5 | SIGTRAP | no | - | BASIC debugging signal |
6 | SIGIOT | no | - | software generated (abort) |
7 | SIGEMT | yes | error | software generated |
8 | SIGFPE | no | - | floating point execution used internally by BASIC |
9 | SIGKILL | no | - | not catchable by anyone |
10 | SIGBUS | no | - | hardware bus error |
11 | SIGSEGV | no | - | segmentation violation |
12 | SIGSYS | yes | error | bad argument to system call |
13 | SIGPIPE | no | - | write on pipe with no reader |
14 | SIGALRM | yes | error | system alarm clock (used by BASIC) |
15 | SIGTERM | yes | exit | software termination signal |
16 | SIGUSR1 | no | - | used by BASIC for communications |
17 | SIGUSR2 | yes | error | user defined signal |
18 | SIGCLD | no | - | used by BASIC |
19 | SIGPWR | no | - | powerfail; never reaches user |
20 | SIGVTALRM | yes | error | virtual timer alarm |
21 | SIGPROF | yes | error | profiling timer alarm |
22 | SIGIO | yes1 | error | I/O possible signal |
23 | SIGWINDOW | no | - | window/mouse signal |
24 | SIGSTOP | no | - | sendable stop signal not from tty |
25 | SIGTSTP | no | - | stop signal from tty |
26 | SIGCONT | no | - | continue a stopped process |
27 | SIGTTIN | no | - | to readers pgroup upon background tty read |
28 | SIGTTOU | no | - | like TTIN for output |
29 | SIGURG | no | - | BASIC/UX 700 I/O interrupt |
30 | SIGLOST | no | - | remote lock lost (NFS) |
31 | - | no | - | not defined for HP-UX |
32 | SIGDIL | no | - | BASIC/UX 300 I/O interrupt |
1If a measurement server binary is loaded, this signal is not available.
EXT SIGNALS default to and remain enabled unless explicitly disabled with the DISABLE EXT SIGNAL statement.
The priority of an EXT SIGNAL can be specified in the ON EXT SIGNAL statement, with the highest priority represented by 15. The highest priority is less than the priority for ON ERROR, ON END, and ON TIMEOUT. ON EXT SIGNAL can interrupt service routines of other event-initiated branches which have user-definable priorities, if the ON EXT SIGNAL priority is higher than the priority of the service routine (the current system priority). CALL and GOSUB service routines get the priority specified in the ON... statement which set up the branch that invoked them. The system priority is not changed when a GOTO branch is taken.
Any specified line label or line number must be in the same context as the ON EXT SIGNAL statement. CALL and GOSUB return to the next line that would have been executed if the EXT SIGNAL event had not been serviced, and the system priority is restored to that which existed before the ON EXT SIGNAL branch was taken. RECOVER forces the program to go directly to the specified line in the context containing that ON EXT SIGNAL statement. When recover forces a change of context, the system priority is restored to that which existed in the original (defining) context at the time that context was exited.
CALL and RECOVER remain active when the context changes to a subprogram, unless the change in context is caused by a keyboard-originated call. GOSUB and GOTO remain active when the context changes to a subprogram, but the branch cannot be taken until the calling context is restored.
ON EXT SIGNAL is disabled by DISABLE EXT SIGNAL or DISABLE and deactivated by OFF EXT SIGNAL.
The current state of the system signal handling can be determined through the STATUS statement. EXT SIGNALS use the pseudo-select code 33 for providing status information. For each EXT SIGNAL, a status register exists with the same number, and providing the following information:
Status\Number | Comment |
---|---|
-1 |
signal not catchable by user |
0 |
signal disabled |
1 |
signal enabled |
Thus to determine the state of the SIGTERM (15) signal,
STATUS 33,15;A
When an EXT SIGNAL is enabled, and there is no ON EXT SIGNAL setup for it and the default action is an error , a program error is generated if a program is running, or if in a keyboard command (including EXECUTE). If a program is running, an ON ERROR statement can catch the error.
When HP BASIC is idle (not running a program and not executing a keyboard command) all EXT SIGNALS except SIGHUP and SIGTERM are ignored. SIGHUP and SIGTERM exit if they are enabled.
Note that all EXT SIGNALs default to being enabled.
Supported On | UX* WS DOS |
Option Required | KBD |
Keyboard Executable | No |
Programmable | Yes |
In an IF ... THEN ... | Yes |
ON HIL EXT enables an end-of-line interrupt in response to receiving data frm HIL devices whose poll records are not otherwise being processed by the HP BASIC system.
ON HIL EXT 8 GOSUB Ser_routine
ON HIL EXT Mask,Priority CALL Sub-prog
ON HIL EXT 2,3 GOTO Label_1
Item | Description | Range |
---|---|---|
address mask | the sum of 2 raised to the power of each of the addresses of the desired devices; Default = 254 | any even number from 2 through 254 |
priority | numeric expression, rounded to an integer; Default = 1 | 1 through 15 |
line label | name of a program line | any valid line name |
line number | integer constant identifying a program line | 1 through 32 766 (1 through 2 147 483 646 for HP BASIC/UX 700) |
subprogram name | name of a SUB or CSUB subprogram | any valid name |
The address mask provides the capability of being able to enable polling of several devices using the same ON HIL EXT statement. This mask is obtained by raising 2 to the power of each of the addresses of desired devices, and adding these values. Suppose you want to create a mask which would allow interrupts from HP-HIL devices at addresses 1 and 3. You would take 2 and raise it to the first power and add this result to 2 raised to the third power; the final result is a mask value of 10. This indicates that end-of-line interrupts can be received from HP-HIL devices at addresses 1 and 3 in the HP-HIL link. Note that the default mask is 254 (all devices in the link).
While interrupts are enabled, poll records are accumulated and returned via the HILBUF$ function. If the HIL SEND statement results in data being returned from the device, the data is put into HILBUF$ even if HP-HIL interrupts are not enabled (i.e. ON HIL EXT is not currently active). Note that no interrupt is generated, even if HP-HIL interrupts are enabled (i.e. ON HIL EXT is currently active), for data placed in HILBUF$ as a result of HIL SEND. However, care should be taken in this case, since executing ON HIL EXT clears HILBUF$.
HP-HIL devices which can use the ON HIL EXT statement are those whose poll records are not being processed for another purpose by the HP BASIC system or the Keyboard controller. These devices are grouped into two categories:
The main HP-HIL devices which cannot use this function are:
The priority can be specified, with the highest priority represented by 15. The highest user-defined priority (15) is less than the priority for ON ERROR, ON END, and ON TIMEOUT (whose priorities are not user-definable). ON HIL EXT can interrupt service routines of other event-initiated branches with user-definable priorities, if the ON HIL EXT priority is higher than the priority of the service routine (the current system priority). CALL and GOSUB service routines get the priority specified in the ON... statement which set up the branch that invoked them. The system priority is not changed when a GOTO branch is taken.
Any specified line label or line number must be in the same context as the ON HIL EXT statement. CALL and GOSUB will return to the next line that would have been executed if the HIL EXT event had not been serviced, and the system priority is restored to that which existed before the ON HIL EXT branch was taken. RECOVER forces the program to go directly to the specified line in the context containing the ON HIL EXT statement. When RECOVER forces a change of context, the system priority is restored to that which existed in the original (defining) context at the time that context was exited.
CALL and RECOVER remain active when the context changes to a subprogram, unless the change in context is caused by a keyboard-originated call. GOSUB and GOTO remain active when the context changes to a subprogram, but the branch cannot be taken until the calling context is restored.
The most recent ON HIL EXT (or OFF HIL EXT) overrides any previous ON HIL EXT definition. If the overriding ON HIL EXT occurs in another context (such as in a SUB subprogram), then the overridden ON HIL EXT branch is restored when the calling context is restored. (See below for restrictions.)
ON HIL EXT is deactivated by OFF HIL EXT.
The ON HIL EXT statement behaves like the ON CDIAL and ON KNOB statements:
If ON HIL EXT is executed in a context with one mask value, and then another ON HIL EXT is executed in a called context with a different mask value, the former mask value is not restored on return to the calling context. This behavior is similar to the time parameters of ON CYCLE and ON DELAY.
Devices to be addressed using ON HIL EXT must not have been opened by the X Windows server. These devices must also be connected to the local system since they cannot be accessed on a remote system. See the section "Opening Input Devices" in the chapter "System-Level Customization" found in the Using the X Window System, Version 11 manual, for details on how to prevent the X Window server from opening specified HIL devices.
Supported On | UX WS DOS IN |
Option Required | IO |
Keyboard Executable | No |
Programmable | Yes |
In an IF ... THEN ... | Yes |
ON INTR defines an event-initiated branch to be taken when an interface card generates an interrupt. The interrupts must be explicitly enabled using ENABLE INTR.
ON INTR 7 GOTO 500
ON INTR Hpib,4 GOSUB Service
ON INTR Isc,Priority CALL Sub_name
Item | Description | Range |
---|---|---|
interface select code | numeric expression, rounded to an integer | 5, 7 through 31 |
priority | numeric expression, rounded to an integer; Default = 1 | 1 through 15 |
line label | name of a program line | any valid name |
line number | integer constant identifying a program line | 1 through 32 766 (1 through 2 147 483 646 for HP BASIC/UX 700) |
subprogram name | name of a SUB or CSUB subprogram | any valid name |
The occurrence of an interrupt performs an implicit DISABLE INTR for the interface. An ENABLE INTR must be performed to re-enable the interface for subsequent event-initiated branches. Another ON INTR is not required, nor must the mask for ENABLE INTR be redefined.
The priority can be specified, with highest priority represented by l5. The highest priority is less than the priority for ON ERROR, ON END, and ON TIMEOUT. ON INTR can interrupt service routines of other event-initiated branches which have user-definable priorities, if the ON INTR priority is higher than the priority of the service routine (the current system priority). CALL and GOSUB service routines get the priority specified in the ON... statement which set up the branch that invoked them. The system priority is not changed when a GOTO branch is taken.
Any specified line label or line number must be in the same context as the ON INTR statement. CALL and GOSUB will return to the next line that would have been executed if the INTR event had not been serviced, and the system priority is restored to that which existed before the ON INTR branch was taken. RECOVER forces the program to go directly to the specified line in the context containing that ON INTR statement. When RECOVER forces a change of context, the system priority is restored to that which existed in the original (defining) context at the time that context was exited.
CALL and RECOVER remain active when the context changes to a subprogram, unless the change in context is caused by a keyboard-originated call. GOSUB and GOTO remain active when the context changes to a subprogram, but the branch cannot be taken until the calling context is restored.
ON INTR is disabled by DISABLE INTR or DISABLE and deactivated by OFF INTR.
ON INTR and OFF INTR statements may be executed for any I/O card (with its driver) in the machine.
Supported On | UX WS DOS |
Option Required | None |
Keyboard Executable | No |
Programmable | Yes |
In an IF ... THEN ... | Yes |
ON KBD defines and enables an event-initiated branch to be taken when a key is pressed.
ON KBD GOTO 150
ON KBD,Priority GOSUB Label1
ON KBD ALL RECOVER 880
ON KBD ALL,3 CALL Sub_name
Item | Description | Range |
---|---|---|
priority | numeric expression, rounded to an integer; Default = 1 | 1 through 15 |
line label | name of a program line | any valid line name |
line number | integer constant identifying a program line | 1 through 32 766 (1 through 2 147 483 646 for HP BASIC/UX 700) |
subprogram name | name of a SUB or CSUB subprogram | any valid name |
Specifying the secondary keyword ALL causes all keys except [RESET], [SHIFT], and [CTRL] to be trapped. When ALL is omitted, the untrapped keys are those just mentioned, the softkeys, [PAUSE], [STOP], [CLR I/O], [Break], [System], [User], [Menu], and [Shift]-[Menu]. When not trapped, these keys perform their normal functions. When the softkeys are trapped, ON KBD branching overrides any ON KEY branching.
A keystroke triggers a keyboard interrupt and initiates a branch to the specified routine when priority allows. If keystrokes occur while branching is held off by priority, the keystrokes are stored in a special buffer. When keystrokes are in the buffer, branching will occur when priority allows. This buffer is read and cleared by the KBD$ function (see the KBD$ entry).
Knob rotation will generate ON KBD interrupts unless an ON KNOB statement has been executed. Clockwise rotation of the knob produces right-arrow keystrokes; counterclockwise rotation produces left-arrow keystrokes. If the [SHIFT] key is pressed while turning the knob, then clockwise rotation of the knob produces up-arrow keystrokes; counterclockwise rotation produces down-arrow key strokes. Since one rotation of the knob is equivalent to 20 keystrokes (more with HP-HIL knobs), keyboard buffer overflow may occur if the HP BASIC service routine does not process the keys rapidly.
Live keyboard, editing, and display control functions are suspended during ON KBD. To restore a key's normal function the keystroke may be OUTPUT to select code 2.
The most recent ON KBD (or OFF KBD) definition overrides any previous ON KBD definition. If the overriding ON KBD definition occurs in a context different from the one in which the overridden ON KBD occurs, the overridden ON KBD is restored when the calling context is restored.
The priority can be specified, with the highest priority represented by l5. The highest user-defined priority (l5) is less than the priority for ON ERROR, ON END, and ON TIMEOUT (whose priorities are not user-definable). ON KBD can interrupt service routines of other event-initiated branches with user-definable priorities, if the ON KBD priority is higher than the priority of the service routine (the current system priority). CALL and GOSUB service routines get the priority specified in the ON... statement which set up the branch that invoked them. The system priority is not changed when a GOTO branch is taken.
Any specified line label or line number must be in the same context as the ON KBD statement. CALL and GOSUB will return to the next line that would have been executed if the KBD event had not been serviced, and the system priority is restored to that which existed before the ON KBD branch was taken. RECOVER forces the program to go directly to the specified line in the context containing that ON KBD statement. When RECOVER forces a change of context, the system priority is restored to that which existed in the original (defining) context at the time that context was exited.
CALL and RECOVER remain active when the context changes to a subprogram, unless the change in context is caused by a keyboard-originated call. GOSUB and GOTO remain active when the context changes to a subprogram, but the branch cannot be taken until the calling context is restored.
ON KBD is disabled by DISABLE, deactivated by OFF KBD, and temporarily deactivated when the program is executing LINPUT, INPUT, or ENTER KBD.
You can use a relative pointing device, such as the HP 46060A mouse on an HP-HIL interface, if the KBD BIN is present.
Supported On | UX WS DOS IN |
Option Required | None |
Keyboard Executable | No |
Programmable | Yes |
In an IF ... THEN ... | Yes |
ON KEY defines and enables an event-initiated branch to be taken when a softkey is pressed.
ON KEY 0 GOTO 150
ON KEY Number,Priority GOSUB Label1
ON KEY 10 LABEL A$ RECOVER 770
ON KEY 5 LABEL "Print",3 CALL Report
Item | Description | Range |
---|---|---|
key selector | numeric expression, rounded to an integer | 0 through 23 |
prompt | string expression; Default = no label | -- |
priority | numeric expression, rounded to an integer; Default = 1 | 1 through 15 |
line label | name of a program line | any valid line name |
line number | integer constant identifying a program line | 1 through 32 766 (1 through 2 147 483 646 for HP BASIC/UX 700) |
subprogram name | name of a SUB or CSUB subprogram | any valid name |
The most recently executed ON KEY (or OFF KEY) definition for a particular softkey overrides any previous key definition. If the overriding ON KEY definition occurs in a context different from the one in which the overridden ON KEY occurs, the overridden ON KEY is restored when the calling context is restored.
Labels appear in the two bottom lines of the CRT. The label of any key is bound to the current ON KEY definition. Therefore, when a definition is changed or restored, the label changes accordingly. If no label is specified, that label field is blank. Refer to the HP BASIC Programming Guide for a discussion of these labels.
The priority can be specified, with the highest priority represented by l5. The highest user-defined priority (l5) is less than the priority for ON ERROR, ON END, and ON TIMEOUT (whose priorities are not user-definable). On KEY can interrupt service routines of other event-initiated branches with user-definable priorities, if the ON KEY priority is higher than the priority of the service routine (the current system priority). CALL and GOSUB service routines get the priority specified in the ON... statement which set up the branch that invoked them. The system priority is not changed when a GOTO branch is taken.
Any specified line label or line number must be in the same context as the ON KEY statement. CALL and GOSUB will return to the next line that would have been executed if the KEY event had not been serviced, and the system priority is restored to that which existed before the ON KEY branch was taken. RECOVER forces the program to go directly to the specified line in the context containing that ON KEY statement. When RECOVER forces a change of context, the system priority is restored to that which existed in the original (defining) context at the time that context was exited.
CALL and RECOVER remain active when the context changes to a subprogram, unless the change in context is caused by a keyboard-originated call. GOSUB and GOTO remain active when the context changes to a subprogram, but the branch cannot be taken until the calling context is restored.
ON KEY is disabled by DISABLE, deactivated by OFF KEY, and temporarily deactivated when the program is paused or executing LINPUT, INPUT, or ENTER KBD. LINPUT or INPUT.
Supported On | UX* WS DOS |
Option Required | None |
Keyboard Executable | No |
Programmable | Yes |
In an IF ... THEN ... | Yes |
ON KNOB defines and enables an event-initiated branch to be taken when the knob is turned.
ON KNOB .1 GOTO 250
ON KNOB Seconds,Priority CALL Sub_name
ON KNOB 1/2,4 GOSUB Label1
Item | Description | Range |
---|---|---|
seconds | numeric expression, rounded to the nearest 0.01 second | 0.01 through 2.55 |
priority | numeric expression, rounded to an integer; Default = 1 | 1 through 15 |
line label | name of a program line | any valid line name |
line number | integer constant identifying a program line | 1 through 32 766 (1 through 2 147 483 646 for HP BASIC/UX 700) |
subprogram name | name of a SUB or CSUB subprogram | any valid name |
Turning the knob (cursor wheel) generates pulses. After ON KNOB is activated (or re-activated), the first pulse received starts a sampling interval. The "seconds" parameter establishes the length of that sampling interval. At the end of the sampling interval, the ON KNOB branch is taken if the net number of pulses received during the interval is not zero and priority permits. The KNOBX and KNOBY functions can be used to determine the number of pulses received during the interval. If the ON KNOB branch is held off for any reason, the KNOBX and KNOBY functions accumulate the pulses (see KNOBX and KNOBY).
The priority can be specified, with the highest priority represented by l5. The highest user-defined priority (l5) is less than the priority for ON ERROR, ON END, and ON TIMEOUT (whose priorities are not user-definable). ON KNOB can interrupt service routines of other event-initiated branches with user-definable priorities, if the ON KNOB priority is higher than the priority of the service routine (the current system priority). CALL and GOSUB service routines get the priority specified in the ON... statement which set up the branch that invoked them. The system priority is not changed when a GOTO branch is taken.
Any specified line label or line number must be in the same context as the ON KNOB statement. CALL and GOSUB will return to the next line that would have been executed if the KNOB event had not been serviced, and the system priority is restored to that which existed before the ON KNOB branch was taken. RECOVER forces the program to go directly to the specified line in the context containing that ON KNOB statement. When RECOVER forces a change of context, the system priority is restored to that which existed in the original (defining) context at the time that context was exited.
CALL and RECOVER remain active when the context changes to a subprogram, unless the change in context is caused by a keyboard-originated call. GOSUB and GOTO remain active when the context changes to a subprogram, but the branch cannot be taken until the calling context is restored.
The most recent ON KNOB (or OFF KNOB) definition overrides any previous ON KNOB definition. If the overriding ON KNOB definition occurs in a context different from the one in which the overridden ON KNOB occurs, the overridden ON KNOB is restored when the calling context is restored, but the "seconds" parameter of the more recent ON KNOB remains in effect. (See below for restrictions.)
ON KNOB is disabled by DISABLE and deactivated by OFF KNOB.
You can use an HP-HIL relative pointing device, such as a mouse or knob, if the KBD binary is loaded.
The ON KNOB statement behaves like the ON CDIAL and ON HIL EXT statements:
Devices to be addressed using ON KNOB must not have been opened by the X Windows server. These devices must also be connected to the local system since they cannot be accessed on a remote system. See the section "Opening Input Devices" in the chapter "System-Level Customization" found in the Using the X Window System, Version 11 manual, for details on how to prevent the X Window server from opening specified HIL devices.
Supported On | UX WS DOS |
Option Required | IO |
Keyboard Executable | No |
Programmable | Yes |
In an IF ... THEN ... | Yes |
ON SIGNAL defines and enables an event-initiated branch to be taken when a SIGNAL statement is executed using the same signal selector.
ON SIGNAL Selector,Priority CALL Sub_name
ON SIGNAL RECOVER Trap
ON SIGNAL 8 GOTO 770
Item | Description | Range |
---|---|---|
signal selector | numeric expression, rounded to an integer | 0 through 15 |
priority | numeric expression, rounded to an integer; Default = 1 | 1 through 15 |
line label | name of a program line | any valid line name |
line number | integer constant identifying a program line | 1 through 32 766 (1 through 2 147 483 646 for HP BASIC/UX 700) |
subprogram name | name of a SUB or CSUB subprogram | any valid name |
The most recent ON SIGNAL (or OFF SIGNAL) definition for a given signal selector overrides any previous ON SIGNAL definition. If the overriding ON SIGNAL definition occurs in a context different from the one in which the overridden ON SIGNAL occurs, the overridden ON SIGNAL is restored when the calling context is restored.
The priority can be specified, with the highest priority represented by 15. The highest user-defined priority (15) is less than the priority for ON ERROR, ON END, and ON TIMEOUT (whose priorities are not user-definable). ON SIGNAL can interrupt service routines of other event-initiated branches with user-definable priorities, if the ON SIGNAL priority is higher than the priority of the service routine (the current system priority). CALL and GOSUB service routines get the priority specified in the ON... statement which set up the branch that invoked them. The system priority is not changed when a GOTO branch is taken.
Any specified line label or line number must be in the same context as the ON SIGNAL statement. CALL and GOSUB will return to the next line that would have been executed if the SIGNAL event had not been serviced, and the system priority is restored to that which existed before the ON SIGNAL branch was taken. RECOVER forces the program to go directly to the specified line in the context containing that ON SIGNAL statement. When RECOVER forces a change of context, the system priority is restored to that which existed in the original (defining) context at the time that context was exited.
CALL and RECOVER remain active when the context changes to a subprogram, unless the change in context is caused by a keyboard-originated call. GOSUB and GOTO remain active when the context changes to a subprogram, but the branch cannot be taken until the calling context is restored.
ON SIGNAL is disabled by DISABLE and deactivated by OFF SIGNAL.
Supported On | UX* WS DOS |
Option Required | CLOCK |
Keyboard Executable | No |
Programmable | Yes |
In an IF ... THEN ... | Yes |
ON TIME defines and enables an event-initiated branch to be taken when the real-time clock reaches a specified time.
ON TIME Seconds,Priority CALL Sub_name
ON TIME TIMEDATE=3600 GOTO 1440
ON TIME Alarm,15 GOSUB Label3
Item | Description | Range |
---|---|---|
seconds | numeric expression, rounded to the nearest 0.01 second for HP BASIC/WS and &nameux 700, and 0.02 second for HP BASIC/UX 300/400 | 0 through 86 399.99 |
priority | numeric expression, rounded to an integer; Default = 1 | 1 through 15 |
line label | name of a program line | any valid line name |
line number | integer constant identifying a program line | 1 through 32 766 (1 through 2 147 483 646 for HP BASIC/UX 700) |
subprogram name | name of a SUB or CSUB subprogram | any valid name |
The most recent ON TIME (or OFF TIME) definition overrides any previous ON TIME definition. If the overriding ON TIME definition occurs in a context different from the one in which the overridden ON TIME occurs, the overridden ON TIME is restored when the calling context is restored, but the time value of the more recent ON TIME remains in effect. For more information on the behavior of ON TIME in different contexts, read the section "Branching Restrictions" in the chapter "Using the Clock and Timers" in the HP BASIC Programming Guide.
The priority can be specified, with the highest priority represented by 15. The highest user-defined priority (15) is less than the priority for ON ERROR, ON END, and ON TIMEOUT (whose priorities are not user-definable). ON TIME can interrupt service routines of other event-initiated branches with user-definable priorities, if the ON TIME priority is higher than the priority of the service routine (the current system priority). CALL and GOSUB service routines get the priority specified in the ON... statement which set up the branch that invoked them. The system priority is not changed when a GOTO branch is taken.
CALL and GOSUB will return to the next line that would have been executed if the TIME event had not been serviced, and the system priority is restored to that which existed before the ON TIME branch was taken. RECOVER forces the program to go directly to the specified line in the context containing that ON TIME statement. When RECOVER forces a change of context, the system priority is restored to that which existed in the original (defining) context at the time that context was exited.
Any specified line label or line number must be in the same context as the ON TIME statement. CALL and RECOVER remain active when the context changes to a subprogram, unless the change in context is caused by a keyboard-originated call. GOSUB and GOTO remain active when the context changes to a subprogram, but the branch cannot be taken until the calling context is restored.
Unlike ON CYCLE, an ON TIME statement requires an exact match between the clock and the time specified in the defining statement. If the event was missed and not logged, re-executing the ON TIME statement will not result in a branch being taken.
ON TIME is disabled by DISABLE and deactivated by OFF TIME.
Resolution is 20 milliseconds for Series 300/400, and 10 milliseconds for Series 700. A new child process of HP BASIC/UX is started for the timer.
Supported On | UX* WS DOS* IN |
Option Required | None |
Keyboard Executable | No |
Programmable | Yes |
In an IF ... THEN ... | Yes |
ON TIMEOUT defines and enables an event-initiated branch to be taken when an I/O timeout occurs on the specified interface.
ON TIMEOUT 7,4 GOTO 770
ON TIMEOUT Printer,Time GOSUB Message
Item | Description | Range |
---|---|---|
interface select code | numeric expression, rounded to an integer | 7 through 31 |
seconds | numeric expression, rounded to the nearest 0.001 second for HP BASIC/WS, 0.020 second for HP BASIC/UX 300/400, and 0.010 second for HP BASIC/UX 700 | 0.001 through 32.767 |
line label | name of a program line | any valid name |
line number | integer constant identifying a program line | 1 through 32 766 (1 through 2 147 483 646 for HP BASIC/UX 700) |
subprogram name | name of a SUB or CSUB subprogram | any valid name |
There is no default system timeout. If ON TIMEOUT is not in effect for an interface, a device can cause the program to wait forever.
The specified branch occurs if an input or output is active on the interface and the I/O request has not completed within the number of seconds specified. The computer waits at least the specified time before generating an interrupt.
Timeouts apply to ENTER and OUTPUT statements, and operations involving the PRINTER IS, PRINTALL IS, and PLOTTER IS devices when they are external. Timeouts also apply to TRANSFER operations that specify the WAIT attribute. Timeouts do not apply to CONTROL, STATUS, READIO, WRITEIO, CRT alpha or graphics I/O, real time clock I/O, keyboard I/O, or mass storage operations.
The priority associated with ON TIMEOUT is higher than priority 15. ON END has the same priority as ON TIMEOUT. ON ERROR has a higher priority than ON TIMEOUT. Both of them can interrupt an ON TIMEOUT service routine.
Any specified line label or line number must be in the same context as the ON TIMEOUT statement. CALL and GOSUB will return to the line immediately following the one during which the timeout occurred, and the system priority is restored to that which existed before the ON TIMEOUT branch was taken. RECOVER forces the program to go directly to the specified line in the context containing that ON TIMEOUT statement. When RECOVER forces a change of context, the system priority is restored to that which existed in the original (defining) context at the time that context was exited.
CALL and RECOVER remain active when the context changes to a subprogram, unless the change in context is caused by a keyboard-originated call. GOSUB and GOTO do not remain active when the context changes to a subprogram. The TIMEOUT event does remain active. Unlike other ON events, TIMEOUTs are never logged, they always cause an immediate action. If a TIMEOUT occurs when the ON TIMEOUT branch cannot be taken, an error 168 is generated. This can be trapped with ON ERROR. The functions ERRN and ERRDs are set only when the error is generated. They are not set when the ON TIMEOUT branch can be taken.
ON TIMEOUT is deactivated by OFF TIMEOUT. DISABLE does not affect ON TIMEOUT. If OFF TIMEOUT is executed in a subprogram such that it cancels an ON TIMEOUT in the calling context, the ON TIMEOUT definition is restored upon returning to the calling context which includes the ON TIMEOUT event-branching and the previous timeout value that was specified for the interface.
With SRM, ON TIMEOUT defines and enables a branch resulting from an I/O timeout on the specified SRM interface. Although ON TIMEOUT is supported on SRM, its use should be avoided because the asynchronous nature of the SRM system does not allow predictable results.
A TIMEOUT occurring during statements such as RE-SAVE and RE-STORE may leave a temporary file on the mass storage device. The file's name is a 10-character identifier (the first character is an alpha character, the rest are digits) derived from the value of the workstation's real-time clock when the TIMEOUT occurred. You may wish to check the contents of any such file before purging.
Timeout values apply to an entire I/O request, not on a byte-per-byte handshake. Setting timeout values in the range of 5 to 10 seconds lets you avoid figuring out I/O request sizes and data rates.
If the interface is a MUX, the interface select code must be a device selector with channel number included. For example,
On HP BASIC/UX 300/400, you cannot set up an ON TIMEOUT for an HP-IB or GPIO interface when using burst I/O mode (CONTROL Sc,255;3).
Resolution is limited to 20 milliseconds for Series 300/400, and 10 milliseconds for Series 700. Accuracy depends on system load and real time priority, but is generally 40 milliseconds.
Delay time for select codes 9, 15, 19, 23, 24, 25, and 26 for the measurement coprocessor is device dependent and is usually longer than for Series 200/300. Also, the delay may differ between the HP 82300 and HP 82324 coprocessors.
Supported On | UX WS DOS |
Option Required | None |
Keyboard Executable | No |
Programmable | Yes |
In an IF ... THEN ... | No |
OPTION BASE specifies the default lower bound of arrays.
OPTION BASE 0
OPTION BASE 1
OPTION BASE determines the default lower bound for arrays that you declare without specifying a lower bound. If you specify an explicit upper and lower bound, it takes precedence over the OPTION BASE specification. The following code segment illustrates this behavior:
100 OPTION BASE 1
110 DIM Var(5:10) ! The lower bound of Var is 5.
OPTION BASE can occur only once in each context. If used, OPTION BASE must precede any explicit variable declarations in a context. Since arrays are passed to subprograms by reference, they maintain their original lower bound, even if the new context has a different OPTION BASE. Any context that does not contain an OPTION BASE statement assumes default lower bounds of zero.
The OPTION BASE value is determined at prerun, and is used with all arrays declared without explicit lower bounds in COM, DIM, INTEGER, and REAL statements as well as with all implicitly dimensioned arrays. OPTION BASE is also used at run time for any arrays declared without lower bounds in ALLOCATE.
See DEF FN and SUB.
Supported On | UX WS DOS IN |
Option Required | None |
Keyboard Executable | Yes |
Programmable | Yes |
In an IF ... THEN ... | Yes |
OR returns a 1 or a 0 based on the logical inclusive OR of the arguments.
X=Y OR Z
IF File_type OR Device THEN Process
An expression that evaluates to a non-zero value is treated as a logical 1. An expression must evaluate to zero to be treated as a logical 0.
The truth table is:
A | B | A OR B |
---|---|---|
0 | 0 | 0 |
0 | 1 | 1 |
1 | 0 | 1 |
1 | 1 | 1 |
See SHIFT IN...OUT option of ASSIGN, DUMP DEVICE IS, PRINTALL IS, and PRINTER IS.
Supported On | UX* WS DOS IN |
Option Required | None |
Keyboard Executable | Yes |
Programmable | Yes |
In an IF ... THEN ... | Yes |
OUTPUT outputs items to the specified destination.
OUTPUT 701;Number,String$;
OUTPUT @File;Array(*),END
OUTPUT @Random,Record USING Fmt1;Item(5)
OUTPUT 12 USING "#,6A";B$[2;6]
OUTPUT Dest$ USING 110;A/1000,VAL$(Res)
OUTPUT @Printer;Rank;Id;Name$
Item | Description | Range |
---|---|---|
I/O path name | name assigned to a device, devices, mass storage file, buffer, or pipe | any valid name |
record number | numeric expression, rounded to an integer | 1 through 231-1 |
device selector | numeric expression, rounded to an integer | (see Glossary) |
destination string name | name of a string variable | any valid name |
subscript | numeric expression, rounded to an integer | -32 767 through +32 767 (see array in Glossary) |
image line number | integer constant identifying an IMAGE statement | 1 through 32 766 (1 through 2 147 483 646 for HP BASIC/UX 700) |
image line label | name identifying an IMAGE statement | any valid name |
image specifier | string expression | (see drawing) |
string array name | name of a string array | any valid name |
numeric array name | name of a numeric array | any valid name |
image specifier list | literal | (see next drawing) |
repeat factor | integer constant | 1 through 32 767 |
literal | string constant composed of characters from the keyboard, including those generated using the ANY CHAR key | quote mark not allowed |
The standard numeric format depends on the value of the number being displayed. If the absolute value of the number is greater than or equal to 1E-4 and less than 1E+6, it is rounded to 12 digits and displayed in floating point notation. If it is not within these limits, it is displayed in scientific notation. The standard numeric format is used unless USING is selected, and may be specified by using K in an image specifier.
COMPLEX numbers are treated like two REAL numbers. The separator following the item is also used as the separator between the real and imaginary parts.
Entire arrays may be output by using the asterisk specifier. Each element in an array is treated as an item by the OUTPUT statement, as if the items were listed separately, separated by the punctuation following the array specifier. If no punctation follows the array specifier, a comma is assumed. The array is output in row major order (rightmost subscript varies fastest). COMPLEX arrays are treated as if they were REAL arrays with twice as many elements.
If an I/O path has been assigned to a file, the file may be written to with OUTPUT statements. The file must be an ASCII, BDAT, DFS, or HP-UX file. The attributes specified in the ASSIGN statement are used if the file is a BDAT, DFS, or HP-UX file. LIF ASCII files (files created by CREATE ASCII are always assigned a special case of the FORMAT ON attribute.
Serial access is available for ASCII, BDAT, DFS, and HP-UX files. Random access is available for BDAT, DFS, and HP-UX files. The end-of-file marker (EOF) and the file pointer are important to both serial and random access. The file pointer is set to the beginning of the file when the file is opened by an ASSIGN. It is updated by OUTPUT operations so that it always points to the next byte to be written.
The EOF pointer is read from the media when the file is opened by an ASSIGN. On a newly created file, EOF is set to the beginning of the file. After each OUTPUT operation, the EOF pointer in the I/O path table is updated to the maximum of the file pointer or the previous EOF value. The EOF pointer on the volume is updated at the following times:
Random access uses the record number parameter to write items to a specific location in a file. The OUTPUT begins at the start of the specified record and must fit into one record. The record specified cannot be beyond the record containing the EOF, if EOF is at the first byte of a record. The record specified can be one record beyond the record containing the EOF, if EOF is not at the first byte of a record. Random access is always allowed to records preceding the EOF record. If you wish to write randomly to a newly created file, either use a CONTROL statement to position the EOF in the last record, or write some "dummy" data into every record.
When data is written to a LIF ASCII file (a file created with CREATE ASCII), each item is sent as an ASCII representation with a 2-byte length header. You cannot use OUTPUT with USING to LIF ASCII files; see the following section, "OUTPUT with USING" for details.
Data sent to a BDAT, DFS, or HP-UX file is sent in internal format if FORMAT OFF is currently assigned to the I/O path (this is the default FORMAT attribute for these file types), and is sent as ASCII characters if FORMAT ON has been explicitly assigned. (See "Devices as Destination" for a description of these formats.)
You must have W (write) permission on a DFS or HFS file, as well as X (search) permission on all superior directories, to output data to the file. If you do not have these permissions, error 183 is reported.
DFS and HFS files are extensible. If the data output to the file with this statement would overflow the file's space allocation, the file is extended. The HP BASIC system allocates the additional space needed to store the data being output, provided the disk contains enough unused storage space.
You must have W (write) access capability on an SRM file, as well as R (read) capability on all superior directories, to output data to the file. If this capability is not public or if a password protecting this capability was not used at the time the file was assigned an I/O path name (with ASSIGN), error 62 is reported.
SRM files are extensible. If the data output to the file with this statement would overflow the file's space allocation, the file is extended. The HP BASIC system allocates an additional "extent size" amount of space, provided the disk contains enough unused storage space; see one of the CREATE statements for a description of "extent size".
An I/O path or a device selector may be used to direct OUTPUT to a device. If a device selector is used, the default system attributes are used (see ASSIGN). If an I/O path is used, the ASSIGN statement used to associate the I/O path with the device also determines the attributes used. If multiple listeners were specified in the ASSIGN, the OUTPUT is directed to all of them. If FORMAT ON is the current attribute, the items are sent in ASCII. Items followed by a semicolon are sent with nothing following them. Numeric items followed by a comma are sent with a comma following them. String items followed by a comma are sent with a CR/LF following them. If the last item in the OUTPUT statement has no punctuation following it, the current end-of-line (EOL) sequence is sent after it. Trailing punctuation eliminates the automatic EOL.
If FORMAT OFF is the current attribute, items are sent to the device in internal format. Punctuation following items has no effect on the OUTPUT. Two bytes are sent for each INTEGER, eight bytes for each REAL, and sixteen bytes for each COMPLEX value. Each string output consists of a four byte header containing the length of the string, followed by the actual string characters. If the number of characters is odd, an additional byte containing a blank is sent after the last character.
If the device selector is 1, the OUTPUT is directed to the CRT. OUTPUT 1 and PRINT differ in their treatment of separators and print fields. The OUTPUT format is described under "Devices as Destination." See the PRINT keyword for a discussion of that format. OUTPUT 1 USING and PRINT USING to the CRT produce similar actions.
Outputs to device selector 2 may be used to simulate keystrokes. ASCII characters can be sent directly (i.e. "hello"). Non-ASCII keys (such as [EXECUTE]) are simulated by a two-byte sequence. The first byte is CHR$(255), and the second byte can be found in the "Second Byte of Non-ASCII Key Sequences" table in the back of this book.
When simulating keystrokes, unwanted characters (such as the EOL sequence) can be avoided with an image specifier (such as "#,B" or "#,K"). See "OUTPUT with USING."
If a string is used for the destination, the string is treated similarly to a file. However, there is no file pointer; each OUTPUT begins at the beginning of the string, and writes serially within the string.
When the destination is an I/O path name assigned to a buffer, data is placed in the buffer beginning at the location indicated by the buffer's fill pointer. As data is sent, the current number-of-bytes register and fill pointer are adjusted accordingly. Encountering the empty pointer (buffer full) produces an error unless a continuous outbound TRANSFER is emptying the buffer. In this case, the OUTPUT will wait until there is more room in the buffer for data.
If an I/O path is currently being used in an inbound TRANSFER, and an OUTPUT statement uses it as a destination, execution of the OUTPUT is deferred until the completion of the TRANSFER. An OUTPUT can be concurrent with an outbound TRANSFER only if the destination is the I/O path assigned to the buffer.
An OUTPUT to a string variable that is also a buffer will not update the buffer's pointers and will probably corrupt the data in the buffer.
If an I/O path has been assigned to a pipe, the pipe may be written to with OUTPUT statements. The attributes specified in the ASSIGN statement are used. Data is sent in internal format if FORMAT OFF is currently assigned to the I/O path, and is sent as ASCII characters if FORMAT ON has been explicitly assigned (this is the default FORMAT attribute for pipes). (See "Devices as Destination" for a description of these formats.)
The secondary keyword END may be specified following the last item in an OUTPUT statement. The result, when USING is not specified, is to suppress the EOL (End-of-Line) sequence that would otherwise be output after the last byte of the last item. If a comma is used to separate the last item from the END keyword, the corresponding item terminator is output (CR/LF for string items or comma for numeric items).
With HP-IB interfaces, END specifies an EOI signal to be sent with the last data byte of the last item. However, if no data is sent from the last output item, EOI is not sent. With Data Communications interfaces, END specifies an end-of-data indication to be sent with the last byte of the last output item.
When the computer executes an OUTPUT USING statement, it reads the image specifier, acting on each field specifier (field specifiers are separated from each other by commas) as it is encountered. If nothing is required from the output items, the field specifier is acted upon without accessing the output list. When the field specifier requires characters, it accesses the next item in the output list, using the entire item. Each element in an array is considered a separate item.
The processing of image specifiers stops when there is no matching display item (and the specifier requires a display item). If the image specifiers are exhausted before the display items, they are reused, starting at the beginning.
COMPLEX values require two REAL image specifiers (i.e. each COMPLEX value is treated like two REAL values).
If a numeric item requires more decimal places to the left of the decimal point than are provided by the field specifier, an error is generated. A minus sign takes a digit place if M or S is not used, and can generate unexpected overflows of the image field. If the number contains more digits to the right of the decimal point than specified, it is rounded to fit the specifier.
If a string is longer than the field specifier, it is truncated, and the right-most characters are lost. If it is shorter than the specifier, trailing blanks are used to fill out the field.
OUTPUT with USING cannot be used with output to LIF ASCII files (files created by CREATE ASCII). Instead, direct the OUTPUT with USING to a string variable, and then OUTPUT this variable to the file.
100 OUTPUT String$ USING "5A,X,6D.D";Chars$,Number110 OUTPUT @File;String$
Effects of the image specifiers on the OUTPUT statement are shown in the following table:
Image\Specifier | Meaning |
---|---|
K |
Compact field. Outputs a number or string in standard form with no leading or trailing blanks. |
-K |
Same as K. |
H |
Similar to K, except the number is output using the European number format (comma radix). (Requires IO) |
-H |
Same as H. (Requires IO) |
S |
Outputs the number's sign (= or -). |
M |
Outputs the number's sign if negative, a blank if positive. |
D |
Digit specifier outputs one digit character. A leading zero is replaced by a blank. If the number is negative and no sign image is specified, the minus sign will occupy a leading digit position. If a sign is output, it will float to the left of the left-most digit. |
Z |
Same as D, except that leading zeros are output. |
* |
Like D, except that asterisks are output instead of leading zeros. (Requires IO) |
. |
Outputs a decimal-point radix specifier. |
R |
Outputs a comma radix specifier (European radix). (Requires IO) |
E |
Outputs an E, a sign, and a two-digit exponent. |
ESZ |
Outputs an E, a sign, and a one-digit exponent. |
ESZZ |
Same as E. |
ESZZZ |
Outputs an E, a sign, and a three-digit exponent. |
A |
Outputs a string character. Trailing blanks are output if the number of characters specified is greater than the number available in the corresponding string. If the image specifier is exhausted before the corresponding string, the remaining characters are ignored. Use AA or 2A for two-byte globalization characters. |
X |
Outputs a blank. |
literal |
Outputs the characters contained in the literal. |
B |
Outputs the character represented by one byte of data. This is similar to the CHR$ function. The number is rounded to an INTEGER and the least-significant byte is sent. If the number is greater than 32 767, then 255 is used; if the number is less than -32 768, then 0 is used. |
W |
Outputs a 16-bit word as a two's-complement integer. The corresponding numeric item is rounded to an INTEGER. If it is greater than 32 767, then 32 767 is sent; if it is less than -32 768, then -32 768 is sent. If either an I/O path name with the BYTE attribute or a device selector is used to access an 8-bit interface, two bytes will be output; the most-significant byte is sent first. If an I/O path name with the BYTE attribute is used to access a 16-bit interface, the BYTE attribute is overridden, and one word is output in a single operation. If an I/O path name with the WORD attribute is used to access a 16-bit interface, a null pad byte is output whenever necessary to achieve alignment on a word boundary. If the destination is a BDAT file, string variable, or buffer, the BYTE or WORD attribute is ignored and all data are sent as bytes; however, pad byte(s) will be output when necessary to achieve alignment on a word boundary. The pad character may be changed by using the CONVERT attribute; see the ASSIGN statement for further information. |
Y |
Like W, except that no pad bytes are output to achieve word alignment. If an I/O path with the BYTE attribute is used to access a 16-bit interface, the BYTE attribute is not overridden (as with the W specifier above). (Requires IO) |
# |
Suppresses the automatic output of the EOL (End-Of-Line) sequence following the last output item. |
% |
Ignored in OUTPUT images. |
= |
Changes the automatic EOL sequence that normally follows the last output item to a single carriage-return. (Requires IO) |
- |
Changes the automatic EOL sequence that normally follows the last output item to a single line-feed. (Requires IO) |
/ |
Outputs a carriage-return and a line-feed. |
L |
Outputs the current end-of-line (EOL) sequence. The default EOL characters are CR and LF; see ASSIGN for information on re-defining the EOL sequence. If the destination is an I/O path name with the WORD attribute, a pad byte may be sent after the EOL characters to achieve word alignment. |
@ |
Outputs a form-feed. |
NOTE |
---|
Some localized versions of HP BASIC, such as Japanese localized HP BASIC, support two-byte characters. When using this localized language remember that the IMAGE, ENTER USING, OUTPUT USING, and PRINT USING statements define a one-byte ASCII character image with A. Use the image AA to designate a two-byte character. For a general discussion of globalization and localization, refer to the &port; manual. For LANGUAGE specific details, refer to Using LanguageX With HP BASIC, where LanguageX is your local language. |
Using the optional secondary keyword END in an OUTPUT...USING statement produces results which differ from those in an OUTPUT statement without USING. Instead of always suppressing the EOL sequence, the END keyword only suppresses the EOL sequence when no data is output from the last output item. Thus, the # image specifier generally controls the suppression of the otherwise automatic EOL sequence.
With HP-IB interfaces, END specifies an EOI signal to be sent with the last byte output. However, no EOI is sent if no data is sent from the last output item or the EOL sequence is suppressed. With Data Communications interfaces, END specifies an end-of-data indication to be sent at the same times an EOI would be sent on HP-IB interfaces.
You can specify a window number or pipe (named or unnamed) as the output destination to OUTPUT. When you name a device as the destination, you can improve performance for some interfaces on Series 300/400 computers by enabling io_burst. See the HP BASIC Interface Reference for information about using io_burst.