See PRINT and DISP.
See PRINT.
See SEND.
Supported On | UX WS DOS IN |
Option Required | None |
Keyboard Executable | Yes |
Programmable | Yes |
In an IF ... THEN ... | Yes |
TAN returns the tangent of the specified angle.
Tangent=TAN(Angle)
PRINT "Tangent of";Z;"=";TAN(Z)
Item | Description/Default | Range\Restrictions |
---|---|---|
argument | numeric expression in the current units of angle when arguments are INTEGER or REAL. numeric expression in radians when the argument is COMPLEX. | absolute values less than: 8.541 563 906 E9 deg. or 1.490 784 13 E+8 rad. for INTEGER and REAL arguments; see Range Restriction Specifics for COMPLEX arguments and underflow conditions |
Error 31 is reported for INTEGER and REAL arguments when trying to compute the TAN of an odd multiple of 90 degrees. If the argument is REAL or INTEGER, the value returned is REAL.
If the argument is COMPLEX, the value returned is COMPLEX.
To compute the TAN of a COMPLEX value, the COMPLEX binary must be loaded.
The formula used for computing the TAN of a COMPLEX argument is illustrated by the following code segment:
100 Factor=COS(2*Real_arg)=COSH(2*Imag_arg)
110 !
120 Real_result=SIN(2*Real_arg)/Factor
130 Imag_result=SINH(2*Imag_arg)/Factor
where Real_arg is the real part the COMPLEX argument and Imag_arg is the imaginary part of the COMPLEX argument. Some values of a COMPLEX argument may cause errors in this computation. For example, TAN(CMPLX(0,710))
will cause error 22 (error 21 in HP BASIC/UX 700) due to the COSH(2*Imag_part) calculation.
Note that any COMPLEX function whose definition includes a sine or cosine function will be evaluated in the radian mode regardless of the current angle mode (i.e. RAD or DEG).
The following range restrictions apply in HP BASIC/UX 700 when underflow mode (CONTROL 32,7;mode) is set to Error or Ignore.
Range | Underflow Mode\Error | Underflow Mode\Ignore |
---|---|---|
Positive Maximum | +1.34217728000000E=008 | +1.34217728000000E+008 |
Negative Minimum | -1.34217728000000E=008 | -1.34217728000000E+008 |
Positive Minimum | +1.02907134889717E-076 | +4.94065645841247E-324 1 |
Negative Maximum | -1.02907134889717E-076 | -4.94065645841247E-324 2 |
1 An underflow in Ignore mode results in a denormalized number that is less than the value for +MINREAL.
2 An underflow in Ignore mode results in a denormalized number that is greater than the value for -MINREAL.
Supported On | UX WS DOS |
Option Required | COMPLEX |
Keyboard Executable | Yes |
Programmable | Yes |
In an IF ... THEN ... | Yes |
TANH returns the hyperbolic tangent of a numeric expression.
Result=TANH(-5.7723)
PRINT "Hyperbolic Tangent = ";TANH(Expression)
Item | Description | Range\Restrictions |
---|---|---|
argument | numeric expression | any value for INTEGER or REAL arguments; see Range Restriction Specifics for COMPLEX arguments and underflow conditions |
If an INTEGER or REAL argument is given, this function returns a REAL value. If a COMPLEX argument is given, this function returns a COMPLEX value.
For COMPLEX arguments, the formula for computing TANH is:
100 Factor=COSH(2*Real_arg)=COS(2*Imag_arg)
110 !
120 Real_result=SINH(2*Real_arg)/Factor
130 Imag_result=SIN(2*Imag_arg)/Factor
where Real_part is the real part of the COMPLEX argument and Imag_part is the imaginary part. Some values of the argument may cause errors in this computation. For example:
TANH(CMPLX(710,3))
will cause error 22 REAL overflow (error 21 in HP BASIC/UX 700) due to the SINH(2*Real_part) calculation.
The following range restrictions apply in HP BASIC/UX 700 when underflow mode (CONTROL 32,7;mode) is set to Error or Ignore.
Range | Underflow Mode\Error | Underflow Mode\Ignore |
---|---|---|
Positive Maximum | +1.79769313486232E+308 | +1.79769313486232E+308 |
Negative Minimum | -1.79769313486232E+308 | -1.79769313486232E+308 |
Positive Minimum | +1.22133866975546E-077 | +4.94065645841247E-324 1 |
Negative Maximum | -1.22133866975546E-077 | -4.94065645841247E-3242 |
1An underflow in Ignore mode results in a denormalized number that is less than the value for +MINREAL.
2 An underflow in Ignore mode results in a denormalized number that is greater than the value for -MINREAL.
Supported On | UX WS DOS |
Option Required | CLOCK |
Keyboard Executable | Yes |
Programmable | Yes |
In an IF ... THEN ... | Yes |
TIME converts the formatted time-of-day string (HH:MM:SS) into the number of seconds past midnight. For information on using TIME as a secondary keyword, see the OFF TIME, ON TIME, and SET TIME statements.
Seconds=TIME(T$)
SET TIME TIME("8:37:30")
Item | Description | Range |
---|---|---|
time of day | string expression representing the time in 24-hour format | (see drawing) |
hours | literal | 0 through 23 |
minutes | literal | 0 through 59 |
seconds | literal; default=0 | 0 through 59.99 |
delimiter | literal; single character | (see text) |
TIME returns a REAL whole number, in the range 0 through 86 399, equivalent to the number of seconds past midnight.
While any number of non-numeric characters may be used as a delimiter, a single colon is recommended. Leading blanks and non-numeric characters are ignored.
Supported On | UX WS DOS |
Option Required | CLOCK |
Keyboard Executable | Yes |
Programmable | Yes |
In an IF ... THEN ... | Yes |
TIME$ converts the number of seconds past midnight into a string representing the formatted time of day (HH:MM:SS).
PRINT "It is ";TIME$(TIMEDATE)
IF VAL(TIME$(T1))>17 THEN Overtime
Item | Description | Range |
---|---|---|
seconds | numeric expression, truncated to the nearest second; seconds past midnight | 0 through 86 399 |
TIME$ takes time (in seconds) and returns the time of day in the form HH:MM:SS, where HH represents hours, MM represents minutes, and SS represents seconds. A modulo 86 400 is performed on the parameter before it is formatted as a time of day.
Supported On | UX* WS DOS* IN |
Option Required | None |
Keyboard Executable | Yes |
Programmable | Yes |
In an IF ... THEN ... | Yes |
TIMEDATE returns the current value of the real-time clock. See also SET TIMEDATE, and TIMEZONE IS.
DISP TIME$(TIMEDATE),DATE$(TIMEDATE)
Elapsed=TIMEDATE-T1
DISP "Seconds since midnight = ";TIMEDATE MOD 86400
The value returned by TIMEDATE represents the sum of the last time setting and the number of seconds that have elapsed since that setting was made. The volatile clock value set at power-on is 2.086 629 12 E+11, which represents midnight March 1, 1900. For HP BASIC/UX, the power-on value was the HP-UX time). If there is a battery-backed (non-volatile) clock, then the volatile clock is synchronized with it at power-up. If the computer is on an SRM system (and has no battery-backed clock), then the volatile clock is synchronized with the SRM clock when the SRM and DCOMM binaries are loaded. The clock values represent Julian time, expressed in seconds. The time value accumulates from that setting unless it is reset by SET TIME or SET TIMEDATE . The resolution of the TIMEDATE function is .01 seconds. If the clock is properly set, this expression equals the number of seconds since midnight:
TIMEDATE MOD 86400
Resolution is limited to 20 milliseconds for HP BASIC/UX 300/400 and 10 milliseconds for HP BASIC/UX 700.
Resolution is limited to approximately 10 milliseconds.
See OFF TIMEOUT and ON TIMEOUT.
Supported On | UX* WS DOS* |
Option Required | None |
Keyboard Executable | Yes |
Programmable | Yes |
In an IF ... THEN ... | Yes |
TIMEZONE IS specifies the offset from Greenwich Mean Time.
TIMEZONE IS Hours_from_GMT*60*60
TIMEZONE IS -7*3600 ! Mountain Standard Time
TIMEZONE IS ! HP BASIC/UX only
Item | Description | Range |
---|---|---|
seconds from GMT | numeric expression rounded to the nearest hundredth | 0 through + 86 399.99 (=24*60*60-0.01) |
TIMEZONE specifies the number of seconds that will be added to the clock to calculate the "local" time (when it is set to Greenwich Mean Time, or GMT). Therefore TIMEZONE IS parameter's value for the GMT timezone is 0. The TIMEZONE IS parameter's value for the Mountain Standard timezone is -7×60×60, because it is 7 hours behind GMT. For each one-hour timezone to the east, add 3600 seconds to the parameter's value; for each timezone to the west, subtract 3600 seconds.
You can determine the current value of the TIMEZONE IS parameter by executing SYSTEM$("TIMEZONE IS"). See SYSTEM$ for details.
NOTE |
---|
If you have a battery-backed (non-volatile) clock, then you may need
to first use SET TIMEDATE before using TIMEZONE IS and SET TIMEDATE as described
above. Otherwise, the clock may initially be set to 1 March 1900, and SET
TIMEDATE could generate a "parameter out of range" error (when it
subtracts the TIMEZONE's "offset from GMT" parameter from the specified
clock value while calculating the GMT value to put into the clock register.)
You can use STATUS register 4 of select code 32 to determine whether or not you have a battery-backed clock. |
This statement provides compatibility with HP-UX time stamps on files when switching back and forth between the HP BASIC/UX and HP-UX operating systems. (If you will not be doing that, you do not need to use the TIMEZONE statement.) TIMEZONE is required for HP-UX compatibility when:
An HP-UX environment variable called TZ is used to calculate "local time", which is an offset from GMT. Thus, when a time stamp (in GMT) is put on a file by HP-UX, the time value (printed in a directory listing) is derived with this formula:
Local_time = HP-UX clock value (GMT)> = TZ
When using TIMEZONE for HP-UX compatibility, you can set the non-volatile (battery-backed) clock to GMT by the following sequence of commands:
Note also that LIF volumes have "local time" stamps, while HFS volumes have GMT time stamps.
The TIMEZONE is set to the current HP-UX timezone in effect at the start of HP BASIC/UX. Daylight savings time is automatically included. Any changes in timezone that occur after HP BASIC/UX has started must be accounted for by the user with the TIMEZONE IS statement.
Note that this statement does NOT reset the HP-UX timezone, even if the user is super-user. Instead it resets the timezone which HP BASIC/UX keeps for itself.
TIMEZONE IS without a parameter resynchronizes the timezone with the current HP-UX timezone in effect (this does take into account Daylight Savings Time changes). This command will affect any previous SET TIME or SET TIMEDATE statements. The proper way to resynchronize the time, date, and timezone is to do the timezone first as in:
TIMEZONE IS
SET TIMEDATE
You can determine the current value of the TIMEZONE IS parameter by executing SYSTEM$("TIMEZONE IS"). See SYSTEM$ for details.
This statement provides backward compatibility to the HP BASIC workstation. It is intended to provide compatibility with HP-UX time stamps on files when switching back and forth between the HP BASIC/WS and HP-UX operating systems. Since the HP BASIC Workstation default timezone is synchronized with HP-UX at start-up time, this statement is generally NOT needed when working with HP BASIC Workstation.
Supported On | UX WS DOS |
Option Required | PDEV |
Keyboard Executable | Yes |
Programmable | Yes |
In an IF ... THEN ... | Yes |
TRACE ALL allows tracing program flow and variable assignments during program execution.
TRACE ALL Sort
TRACE ALL Label1,Label2
TRACE ALL 1500,2450
Item | Description | Range |
---|---|---|
beginning line number | integer constant identifying a program line; Default=first program line | 1 through 32 766 (1 through 2 147 483 646 for HP BASIC/UX 700) |
beginning line label | name of a program line | any valid name |
ending line number | integer constant identifying a program line; Default=last program line | 1 through 32 766 (1 through 2 147 483 646 for HP BASIC/UX 700) |
ending line label | name of a program line | any valid name |
The entire program, or any part delimited by beginning and (if needed) ending line numbers or labels, may be traced.
Tracing starts when the beginning line is first executed and continues until the ending line is executed.
The ending line is not included in the trace output. The trace output stops immediately before the ending line is executed. When a line is traced, the line number and any variable which receives a new value is output to the system message line of the CRT. Any type of variable (string, numeric or array) can be displayed. For simple string and numeric variables, the name and the new value are displayed. For arrays, a message is displayed stating that the array has a new value rather than outputting the entire array contents.
TRACE ALL output can also be printed on the PRINTALL device or file, if PRINTALL is ON. TRACE ALL is disabled by TRACE OFF.
The line numbers specified for TRACE ALL are not affected by REN.
Supported On | UX WS DOS |
Option Required | PDEV |
Keyboard Executable | Yes |
Programmable | Yes |
In an IF ... THEN ... | Yes |
TRACE OFF turns off all tracing activity.
TRACE OFF
Supported On | UX WS DOS |
Option Required | PDEV |
Keyboard Executable | Yes |
Programmable | Yes |
In an IF ... THEN ... | Yes |
TRACE PAUSE causes program execution to pause before executing the specified line, and displays the next line to be executed on the CRT.
TRACE PAUSE
TRACE PAUSE 530
TRACE PAUSE Loop_end
Item | Description | Range |
---|---|---|
paused line number | integer constant identifying a program line; Default=next program line | 1 through 32 766 (1 through 2 147 483 646 for HP BASIC/UX 700) |
paused line label | name of a program line | any valid name |
Not specifying a line for TRACE PAUSE results in the pause occurring before the next line is executed. Only one TRACE PAUSE can be active at a time. TRACE PAUSE is canceled by TRACE OFF.
Supported On | UX WS DOS |
Option Required | GRAPHX |
Keyboard Executable | Yes |
Programmable | Yes |
In an IF ... THEN ... | Yes |
TRACK enables or disables tracking of the current locator position on the current display device.
TRACK Display IS ON
TRACK 709 IS OFF
Item | Description | Range |
---|---|---|
display device selector | numeric expression, rounded to an integer | (see Glossary) |
The current locator is defined by a GRAPHICS INPUT IS statement, and the current display device is defined by a PLOTTER IS statement. If TRACK...IS ON is executed, an echo on the current display device tracks the locator position during DIGITIZE statements. On a CRT, the echo is a 9-by-9-dot crosshair. On a plotter, the pen position tracks the locator. When a point is digitized, the echo is left at the location of the digitized point and tracking ceases. The display device selector must match that used in the most recently executed PLOTTER IS statement, or error 708 results. Executing TRACK...IS OFF disables tracking.
Supported On | UX* WS DOS* |
Option Required | TRANS |
Keyboard Executable | Yes |
Programmable | Yes |
In an IF ... THEN ... | Yes |
TRANSFER initiates unformatted I/O transfers.
TRANSFER @Device TO @Buff
TRANSFER @Buff TO @File;CONT
TRANSFER @Path TO @Destination;COUNT 256
TRANSFER @Source TO @Buffer;DELIM "/",END
TRANSFER @Path TO @Buffer;RECORDS 12,EOR(COUNT 8)
Item | Description | Range |
---|---|---|
source name | I/O path name assigned to a device, a group of devices,
a mass storage file, pipe, or a buffer |
any valid name |
destination name | I/O path name assigned to a device, a group of devices,
a mass storage file, pipe, or a buffer |
any valid name |
number of bytes | numeric expression, rounded to an integer | 1 through 231-1 |
character | string expression with a length of zero or one | -- |
number of records | numeric expression, rounded to an integer | 1 through 231-1 |
The TRANSFER statement allows unformatted data transfers between~~ the computer and devices (mass storage drives are considered devices for this operation). Whenever possible, a TRANSFER takes place concurrently with continued program execution. Since no formatting is performed and the TRANSFER statement executes concurrently (overlapped) with regular program execution, the highest possible data transfer rate is achieved.
Before a data transfer can take place, a buffer must be declared. Every TRANSFER will need a buffer as either its source or its destination. An outbound TRANSFER empties the buffer (source) while an inbound TRANSFER fills the buffer (destination). Device to device transfers and buffer to buffer transfers are not allowed.
Two types of buffers are available; named and unnamed. A named buffer is a REAL array, INTEGER array, COMPLEX array, or a string scalar declared with the keyword BUFFER. See ASSIGN, COM, DIM, INTEGER, COMPLEX, and REAL. Unnamed buffers are created in the ASSIGN statement by specifying the keyword BUFFER and the number of bytes to be reserved for the buffer. See ASSIGN.
Every buffer has two pointers associated with it. The fill pointer indicates the next available location in the buffer for data. The empty pointer indicates the next item to be removed from the buffer. This allows an inbound TRANSFER and an outbound TRANSFER to access the same buffer simultaneously.
BDAT and HP-UX files are the only file types allowed in a TRANSFER. An end-of-file error will prematurely terminate a TRANSFER, thus triggering an end-of-transfer condition. If an end-of-record condition was satisfied when the end-of-file was reached, the EOR event will also be true.
I/O path names should be used to access the contents of the buffer. This ensures the automatic updating of the fill and empty pointers during a transfer. For named buffers, the contents of the buffer can also be accessed by the buffer's variable name. However, accessing the contents of the buffer by the variable name does not update the fill and empty pointers and is likely to corrupt the data in the buffer.
With files on HFS and SRM volumes, the TRANSFER statement runs in overlapped mode until the HP BASIC encounters a statement that accesses the same volume (such as CAT or ASSIGN); at such times, HP BASIC performs an implicit WAIT FOR EOT.
SRM and LIF are not supported for TRANSFER in HP BASIC/UX.
When no parameters are specified for a TRANSFER, an inbound TRANSFER will fill the buffer with data and then terminate. An outbound transfer will empty the buffer and then terminate. Both inbound and outbound transfers execute in overlapped mode when possible.
The CONT parameter specifies that the TRANSFER is to continue indefinitely. Instead of terminating on buffer full or buffer empty conditions, the TRANSFER will be temporarily suspended until there is space available in the buffer (for inbound transfers) or until there is data available in the buffer (for outbound transfers).
The WAIT parameter specifies that the TRANSFER is to take place serially (non-overlapped). Program execution will not leave the TRANSFER statement until the data transfer is completed. This is the only type of TRANSFER that can use or is affected by ON TIMEOUT.
A TRANSFER can be specified to terminate when a device dependent signal is received (END), after a specified number of bytes has been transferred (COUNT), or after a specific character is detected (DELIM). The DELIM parameter can only be used with inbound transfers.
If END is included on a TRANSFER to a file, the end-of-file pointer is updated when the TRANSFER terminates; including EOR(END) causes the end-of-file pointer to be updated at the end of each record.
When the RECORD parameter is specified, the end-of-record parameter must also be specified (EOR). The end-of-record condition can be either COUNT, DELIM, END or any combination of conditions.
Overlapped execution of the TRANSFER statement can be deferred until a record has been transferred or until the entire TRANSFER has completed. See WAIT FOR EOR and WAIT FOR EOT.
The TRANSFER statement supports data transfers to and from the following devices.
HP-IB | HP 98624 (and built-in HP-IB on Measurement Coprocessors) |
GPIO | HP 98622 |
Serial | HP 98626 |
Datacomm | HP 98628 |
MUX | HP 98642 (HP BASIC/UX only) |
TRANSFER can also be used with BDAT and HP-UX files on any of the mass storage devices or pipes supported by HP BASIC. However, TRANSFER cannot be used with LIF and SRM file systems in HP BASIC/UX.
The transfer method is device dependent and chosen by the computer. The three possible transfer modes are:
INT | interrupt mode |
FHS | fast handshake |
DMA | direct memory access |
The DMA mode will be used whenever possible. If the DMA mode cannot be used (DMA card is not installed, both channels are busy, DELIM is specified, or the interface does not support DMA) then the INT mode will be used. FHS is used with the HP-IB or GPIO interfaces only when DMA cannot be used and the WAIT parameter is specified.
When the computer tries to move into the stopped state, it will wait for any transfer to complete. Therefore, operations which would cause a stopped state will make the computer unresponsive (or "hung") if a TRANSFER is in progress. Operations in this category include a programmed GET, modifying a paused program, and STOP. Also, the computer will not exit a context until any TRANSFER in that context is complete. This will cause the program to wait at a SUBEXIT, ERROR SUBEXIT, SUBEND, or RETURN <expression> statement while a TRANSFER is in progress. If the program is paused, but a TRANSFER is still active, the run-light will be an "Io" character and the system status Indicator (if present) will say "Transfer."
To terminate a transfer before it has finished (and free the computer), execute an ABORTIO (or, as a last resort, press [RESET]).
See also: ASSIGN, WAIT FOR EOT, WAIT FOR EOR, ABORTIO, RESET and the "Advanced Transfer Techniques" chapter of the HP BASIC Interface Reference.
The EOR(COUNT N) can be used to control the maximum I/O request size. This may be useful in determining a timeout value if using the WAIT parameter for non-overlapped TRANSFER with ON TIMEOUT.
On Series 300/400 computers, either io_burst is used (if specified with CONTROL isc,255;3) or else DMA allocation is managed by the HP-UX kernel and may be used for some or all of the TRANSFER segments.
Overlapped transfers on DFS or HPW disks are not supported. Serial transfers are not supported for the COM1 or COM2 serial port.
Supported On | UX WS DOS IN |
Option Required | IO |
Keyboard Executable | Yes |
Programmable | Yes |
In an IF ... THEN ... | Yes |
TRIGGER sends a trigger message to a selected device, or to all devices addressed to listen, on the HP-IB.
TRIGGER 712
TRIGGER Device
TRIGGER @Hpib
Item | Description | Range |
---|---|---|
I/O path name | name assigned to a device or devices | any valid name (see ASSIGN) |
device selector | numeric expression, rounded to an integer | (see Glossary) |
The computer must be the active controller to execute this statement. If only the interface select code is specified, all devices on that interface which are addressed to listen are triggered. If a primary address is given, the bus is reconfigured and only the addressed device is triggered.
System Controller | Not System Controller | |||
---|---|---|---|---|
Interface Select Code Only | Primary Address Specified | Interface Select Code Only | Primary Address Specified | |
Active Controller | ATN
GET |
ATN
MTA UNL LAG GET |
ATN
GET |
ATN
MTA UNL LAG GET |
Not Active Controller | Error | Error | Error | Error |
Supported On | UX WS DOS IN |
Option Required | None |
Keyboard Executable | Yes |
Programmable | Yes |
In an IF ... THEN ... | Yes |
TRIM$ returns a string formed by stripping all leading and trailing ASCII spaces from its argument.
Left$=TRIM$(" center ")
Clean$=TRIM$(User_input$)
Only CHR$(32) (the space character) is trimmed. Only leading and trailing ASCII spaces are removed; embedded spaces are not affected.
Certain localized versions of HP BASIC, such as Japanese localized HP BASIC, support two-byte characters. The TRIM$ function does not affect two-byte characters, including two-byte blanks. Only CHR$(32) (ASCII space) is trimmed from the string. For more information about two-byte characters, refer to the globalization chapters of HP BASIC Porting and Globalization.
See MAT.