DATA - DVAL$

DATA

Supported On UX WS DOS IN
Option Required None
Keyboard Executable No
Programmable Yes
In an IF ... THEN ... No

DATA statements contain in-line data that is read by READ statements. (For information about DATA as a secondary keyword, see the SEND statement.)

Example Statements

DATA 1,1.414,1.732,2
DATA word1,word2,word3
DATA"ex-point(!)","quote("")","comma(,)"

Syntax

Item Description Range
numeric constant numeric quantity expressed using numerals, and optionally a sign, decimal point, or exponent notation --
literal string constant composed of characters from the keyboard, including those generated using the [ANY CHAR] key ([f7] in the system menu of an ITF keyboard) --

Semantics

A program or subprogram can contain any number of DATA statements at any location. When a program runs, the first item in the lowest numbered DATA statement is read by the first READ statement encountered. When a subprogram is called, the location of the next item to be read in the calling context is remembered in anticipation of returning from the subprogram. Within the subprogram, the first item read is the first item in the lowest numbered DATA statement within the subprogram. When program execution returns to the calling context, the READ operations pick up where they left off in the DATA items.

A numeric constant must be read into a variable which can store the value it represents. The computer cannot determine the intent of the programmer; although attempting to read a string value into a numeric variable will generate an error, numeric constants will be read into string variables with no complaint. In fact, the computer considers the contents of all DATA statements to be literals, and processes items to be read into numeric variables with a function similar to VAL. Error 32 results if the numeric data is not of the proper form (see VAL).

Unquoted literals must not contain quote marks (which delimit strings), commas (which delimit data items), or exclamation marks (which indicate the start of a comment). Leading and trailing blanks are deleted from unquoted literals. Enclosing a literal in double quotes enables you to include any punctuation you wish, including embedded double quotes, which are represented by a set of two adjacent double quotes.

DATA "Say ""Hello"" to him." ! Embedded quotes.
DATA "Danger, power ON!" ! Space, comma, and ! in the data.

DATE

Supported On UX WS DOS
Option Required CLOCK
Keyboard Executable Yes
Programmable Yes
In an IF ... THEN ... Yes

DATE converts a formatted date string (DD MMM YYYY) into a numeric value (in seconds).

Example Statements

PRINT DATE("30 MAY 1987")
Days=(DATE(Day1$)-DATE(Day2$)) DIV 86400

Syntax

Item Description Range
formatted date string expression (see drawing and text)
day integer constant 1 through end-of-month
month literal (lettercase ignored) JAN, FEB, MAR, APR, MAY, JUN, JUL, AUG, SEP, OCT, NOV, DEC
year integer constant 1900 through 2079

Semantics

Using a value from the DATE function as the argument for SET TIMEDATE will set the clock to midnight on the date specified. Results from the DATE and TIME functions must be combined to set the date and time of day.

If the DATE function is used as an argument for SET TIMEDATE to set the clock, the date must be in the range: 1 Mar 1900 through 4 Aug 2079.

Specifying an invalid date, such as the thirty-first of February, will result in an error.

Leading blanks or non-numeric characters are ignored. ASCII spaces are recommended as delimiters between the day, month and year. However, any non-alphanumeric character, except the negative sign (minus sign), may be used as the delimiter.

DATE$

Supported On UX WS DOS
Option Required CLOCK
Keyboard Executable Yes
Programmable Yes
In an IF ... THEN ... Yes

DATE$ formats a number of seconds into a string representing the formatted date (DD MMM YYYY).

Example Statements

PRINT DATE$(TIMEDATE)
Day1$=DATE$(Event1)

Syntax

Item Description Range
seconds numeric expression -4.623 683 256 E+13 through

4.653 426 335 039 9 E+13

Semantics

The date returned is in the form: DD MMM YYYY, where DD is the day of the month, MMM is the month mnemonic, and YYYY is the year.

The day is blank filled to two character positions. Single ASCII spaces delimit the day, month, and year.

The first letter of the month is capitalized and the rest are lowercase characters.

Years less than the year 0 are expressed as negative years.

DEALLOCATE

Supported On UX WS DOS
Option Required None
Keyboard Executable Yes
Programmable Yes
In an IF ... THEN ... Yes

DEALLOCATE deallocates memory space reserved by the ALLOCATE statement.

Example Statements

DEALLOCATE A$,B$,C$
DEALLOCATE Text$(*)
DEALLOCATE Array(*)

Syntax

Item Description Range
variable name name of an array or string variable any valid name

Semantics

Memory space reserved by ALLOCATE exists in the same section of memory as that used by ON-event statements. Since entries in this area are "stacked" as they come in, space for variables which have been DEALLOCATED may not be available immediately. It will not be available until all the space "above it" is freed. This includes variables allocated after it, as well as ON-event entries. Exiting a subprogram automatically deallocates space for variables which were allocated in that subprogram.

Strings and arrays must be deallocated completely. Deallocation of an array is requested by the (*) specifier.

Attempting to DEALLOCATE a variable which is not allocated in the current context results in an error. When DEALLOCATE is executed from the keyboard, deallocation occurs within the current context.

DEF FN

Supported On UX WS DOS IN
Option Required None
Keyboard Executable No
Programmable Yes
In an IF ... THEN ... No

DEF FN indicates the beginning of a function subprogram. It also indicates whether the function is string or numeric and defines the formal parameter list.

Example Statements


970  ! main program here.
980  END
990  !
1000 DEF FNNew$(String$)
1010 ! Additional statements
1020  RETURN Result$
1030  FNEND

DEF FNXform(@Ptr,INTEGER A(*), OPTIONAL Text$)
DEF FNExtract(Buf$ BUFFER,Pointer)

Item Description Range
function name name of the user-defined function any valid name
numeric name name of a numeric variable any valid name
string name name of a string variable any valid name
I/O path name name assigned to a device, devices, or mass storage file any valid name (see ASSIGN)
program segment any number of contiguous program lines not containing the beginning or end of a main program or subprogram --

Semantics

User-defined functions must appear after the main program. The first line of the function must be a DEF FN statement. The last line must be an FNEND statement. Comments after the FNEND are considered to be part of the function.

Parameters to the left of the keyword OPTIONAL are required and must be supplied whenever the user-defined function is invoked (see FN). Parameters to the right of OPTIONAL are optional, and only need to be supplied if they are needed for a specific operation. Optional parameters are associated from left to right with any remaining pass parameters until the pass parameter list is exhausted. An error is generated if the function tries to use an optional parameter which did not have a value passed to it. The function NPAR can be used to determine the number of parameters supplied by the function call.

Variables in a function's formal parameter list may not be declared in COM or other declaratory statements within the function. A user-defined function may not contain any SUB statements or DEF FN statements. User-defined functions can be called recursively and may contain local variables. A unique labeled COM must be used if the local variables are to preserve their values between invocations of the user-defined function.

The RETURN statement is important in a user-defined function. If the program actually encounters an FNEND during execution (which can only happen if the RETURN is missing or misplaced), error 5 is generated. The expression in the RETURN statement must be numeric for numeric functions, and string for string functions. A string function is indicated by the dollar sign suffix on the function name. If RETURN specifies a numeric expression, the value returned by the function is always a real number, never an integer. RETURN complex expression yields a complex function result.

The purpose of a user-defined function is to compute a single value. While it is possible to alter variables passed by reference and variables in COM, this can produce undesirable side effects, and should be avoided. If more than one value needs to be passed back to the program, SUB subprograms should be used.

If you want to use a formal parameter as a BUFFER, it must be declared as a BUFFER in both the formal parameter list and the calling context.

DEG

Supported On UX WS DOS IN
Option Required None
Keyboard Executable Yes
Programmable Yes
In an IF ... THEN ... Yes

DEG selects degrees as the current angle mode (unit of measure for angles).

Example Statements

DEG

Syntax

Semantics

Unless you set the angle mode to degrees, it is radians. HP BASIC sets the angle mode to radians when you do one of the following:

Executing DEG sets the current angle mode to degrees. All functions which return an angle will return an angle in degrees. All operations with parameters representing angles will interpret the angle in degrees.

To set the angle mode to radians, use RAD.

A subprogram "inherits" the angle mode of the calling context. If the angle mode is changed in a subprogram, the mode of the calling context is restored when execution returns to the calling context.

DEL

Supported On UX WS DOS IN
Option Required None
Keyboard Executable Yes
Programmable No
In an IF ... THEN ... No

DEL deletes one or more program lines from memory.

Example Statements

DEL 15

DEL Start,Last

DEL Sort,32000

Syntax

Item Description Range
beginning line number integer constant identifying a 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 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

Semantics

DEL cannot be executed while a program is running. If DEL is executed while a program is paused, HP BASIC changes to the stopped state.

When a line is specified by a line label, the computer uses the lowest numbered line which has the label. If the label does not exist, error 3 is generated. An attempt to delete a non-existent program line is ignored when the line is specified by a line number. An error results if the ending line number is less than the beginning line number. If only one line is specified, only that line is deleted.

When deleting SUB and FN subprograms, the range of lines specified must include the statements delimiting the beginning and ending of the subprogram (DEF FN and FNEND for user-defined function subprograms; SUB and SUBEND for SUB subprograms), as well as all comments following the delimiting statement for the end of the subprogram. Contiguous subprograms may be deleted in one operation.

DELAY

See ASSIGN, OFF DELAY, ON DELAY, PRINTALL IS, and PRINTER IS.

DELIM

See TRANSFER.

DELSUB

Supported On UX WS DOS
Option Required None
Keyboard Executable Yes
Programmable Yes
In an IF ... THEN ... Yes

DELSUB deletes one or more subprograms or user-defined functions from memory.

Example Statements

DELSUB FNTrim$
DELSUB Mysub
DELSUB Process TO END
DELSUB Special1,Special3

Syntax

Item Description Range
subprogram name name of a SUB or CSUB subprogram any valid name
function name name of a user-defined function any valid name

Semantics

Subprograms being deleted do not need to be contiguous in memory. The order of the names in the deletion list does not have to agree with the order of the subprograms in memory. If there are subprograms with the same name, the one occurring first (lowest line number) is deleted.

The lines deleted begin with the line delimiting the beginning of the subprogram (SUB or DEF FN) and include the comments following the line delimiting the end of the subprogram (SUBEND or FNEND). If TO END is included, all subprograms following the specified subprogram are also deleted.

You cannot delete:

If an error occurs while attempting to delete a subprogram, the subprogram is not deleted, and neither are any subprograms listed to the right of that subprogram in the DELSUB statement.

DESTROY WINDOW

Supported On UX WS*
Option Required RMBUX
Keyboard Executable Yes
Programmable Yes
In an IF ... THEN ... Yes

DESTROY WINDOW deletes a window created by HP BASIC/UX and removes its contents from the display. This statement can be entered in the HP BASIC/UX/WS ; editor, but executes only in HP BASIC/UX in X.

Example Statements

DESTROY WINDOW 604
DESTROY WINDOW Fred

Syntax

Item Description Range
window number numeric expression, rounded to integer 601 through 699

Semantics

This statement is only valid when running under X Windows. When not in X Windows, this statement will cause an error. It deletes the window specified by the window number. The specified window can only be a window created with the CREATE WINDOW statement. Thus the root HP BASIC window (number 600) cannot be deleted.

When a window is deleted, the contents of any windows it overlays are exposed.

DET

Supported On UX WS DOS
Option Required MAT
Keyboard Executable Yes
Programmable Yes
In an IF ... THEN ... Yes

DET returns the determinant of a matrix.

Example Statements

Last_det=DET
PRINT DET(Matrix)

Syntax

Item Description Range
matrix name name of a square, two-dimensional numeric array; Default = (see text) any valid name

Semantics

If you do not specify a matrix, DET returns the determinant of the most recently inverted matrix. This value is not affected by context switching. If no matrix has been inverted since power-on, pre-run, SCRATCH or SCRATCH A, 0 is returned.

The determinant provides an indication of whether an inverse is valid. If the determinant of a matrix equals 0, then the matrix has no inverse. If the determinant is very small compared with the elements of its matrix, then the inverse may be invalid and should be checked.

If the matrix is COMPLEX, the value returned is COMPLEX. Otherwise, the value returned is REAL.

DICTIONARY IS

Supported On UX WS
Option Required INPUT
Keyboard Executable Yes
Programmable Yes
In an IF ... THEN ... Yes

DICTIONARY IS specifies the file containing the language dictionaries. It is useful for localized versions of HP BASIC that support certain local languages, such as Japanese.

Example Statements

DICTIONARY IS "JPN_SYSDCT","SYSTEM"
DICTIONARY IS "JPN_USRDCT","USER"
DICTIONARY IS "","USER"  ! Closes USER dictionary

Syntax

Item Description Range
type string expression depends on INPUT

Semantics

Certain localized versions of HP BASIC , such as Japanese localized HP BASIC , use input methods that allow keyboard input translation. The translations are carried out by the INPUT binary according to the definitions in dictionary files. Before a word or phrase can be translated, the dictionaries must be specified using DICTIONARY IS.

For a general discussion of globalization and localization, refer to the HP BASIC Porting and Globalization manual. For INPUT specific details, refer to Using LanguageX with HP BASIC , where LanguageX is your local language.

If you are using a version of HP BASIC that supports wildcards, you can use them in file specifiers with DICTIONARY IS. You must first enable wildcard recognition using WILDCARDS. Refer to the keyword entry for WILDCARDS for details. Wildcard file specifiers used with DICTIONARY IS must match one and only one file name.

If the file specifier does not include a complete path or volume specifier, the current MASS STORAGE IS volume and path are used.

DIGITIZE

Supported On UX* WS DOS
Option Required GRAPHX
Keyboard Executable Yes
Programmable Yes
In an IF ... THEN ... Yes

DIGITIZE inputs the X and Y coordinates of a digitized point from the locator specified by GRAPHICS INPUT IS.

Example Statements

DIGITIZE Xpos,Ypos,Status$
IF Flag THEN DIGITIZE X,Y

Syntax

Item Description Range
x coordinate name name of a numeric variable any valid name
y coordinate name name of a numeric variable any valid name string
string name name of a string variable any valid name string

Semantics

The returned coordinates are in the unit-of-measure currently defined for the PLOTTER IS and GRAPHICS INPUT IS devices. The unit-of-measure may be default units or those defined by either the WINDOW or SHOW statement. If an INTEGER numeric variable is specified and the value entered is out of range, error 20 is reported.

If graphics input is from the keyboard, DIGITIZE is satisfied by pressing any of the following keys:

[Return], [Enter], [ENTER], [EXECUTE], [PAUSE], [STEP], [CONTINUE], [ENTER], [EXEC], [PSE], [STEP], and [CONT].

Note that if ON KBD is in effect while executing DIGITIZE when the keyboard or mouse or knob is the GRAPHICS INPUT IS device, the keys listed above will not be placed into KBD$. Once the DIGITIZE is complete, these keys will be placed into KBD$.

The optional string variable is used to input the device status of the GRAPHICS INPUT IS device. This status string contains eight bytes, defined as follows.

Byte 1 2 3 4 5 6 7 8
Meaning Digitize Status ,     Point Significance ,     Tracking On/Off ,     Button Number

Byte 1 Digitize status; If the locator device supports only single point digitizing, this byte is always a "1". If the locator device supports continuous digitizing, this byte is a "1" for all points in a stream of continuous points except the last point, which will be returned with a "0". The method of indicating the beginning and ending of a continuous point stream is device dependent. If the numeric value represented by this byte is used as the pen control value for a PLOT statement, continuous digitizing will be copied to the display device.
Bytes 2, 4, & 6 Commas; used as delimiters.
Byte 3 Significance of digitized point; "0" indicates that the point is outside the P1, P2 limits; "1" indicates that the point is outside the viewport, but inside the P1, P2 limits; "2" indicates that the point is inside the current viewport limits.
Byte 5 Tracking status; "0" indicates off, "1" indicates on.
Byte 7 and 8 The number of the buttons which are currently down. To interpret the ASCII number returned, change the number to its binary form and look at each bit. If the bit is "1", the corresponding button is down. If the bit is "0", the corresponding button is not down.

If the locator device (e.g., stylus or puck) goes out of proximity, a "button 7" is indicated in the "button number" bytes. Bytes 7 and 8 will be exactly "64" regardless of whether any actual buttons are being held down at the time. Proximity is reported only from HP-HIL locators; the HP 9111A always returns "00" in bytes 7 and 8. On a 35723A TouchScreen, going out of proximity (i.e., removing your finger from the screen) will trigger a digitize. Coming into proximity on a tablet with a button pressed will also trigger a digitize, even if the button was originally pressed while in proximity.

HP BASIC/UX Specifics

When running in X Windows:

When running on a terminal:

DIM

Supported On UX WS DOS IN*
Option Required None
Keyboard Executable No
Programmable Yes
In an IF ... THEN ... No

DIM dimensions and reserves memory for REAL numeric arrays, strings, and string arrays.

Example Statements

DIM String$[100],Name$(12)[32]
DIM Param(48,8,8,2,2,2)
DIM Array(-128:127,16)
DIM Buff$[512] BUFFER,Array(500) BUFFER

Syntax

Item Description Range
numeric array name name of a numeric array any valid name
string name name of a string variable any valid name
lower bound integer constant; Default = OPTION BASE value (0 or 1) -32 767 through +32 767 (see array in Glossary)
upper bound integer constant -32 767 through +32 767 (see array in Glossary)
string length integer constant 1 through 32 767

Semantics

A program can have any number of DIM statements. The same variable cannot be declared twice within a program (variables declared in a subprogram are distinct from those declared in a main program, except those declared in COM). The DIM statements can appear anywhere within a program, as long as they do not precede an OPTION BASE statement. Dimensioning occurs at pre-run or subprogram entry time. Dynamic run-time allocation of memory is provided by the ALLOCATE statement.

No array can have more than six dimensions. Each dimension can have a maximum of 32 767 elements.

The total number of variables is limited by the fact that the maximum memory usage for all variables--numeric and string--within any context is 16 777 215 bytes (or limited by the amount of available memory, whichever is less).

All numeric arrays declared in a DIM statement are REAL, and each element of type REAL requires 8 bytes of storage. A string requires one byte of storage per character, plus two bytes of overhead on Series 200/300/400 or four bytes on Series 700.

An undeclared array is given as many dimensions as it has subscripts in its lowest-numbered occurrence. Each dimension of an undeclared array has an upper bound of ten. Space for these elements is reserved whether you use them or not. Any time a lower bound is not specified, it defaults to the OPTION BASE value.

Declaring Buffers

To declare variables to be buffers, each variable's name must be followed by a keyword BUFFER; the designation BUFFER applies only to the variable which it follows.

String arrays cannot be declared to be buffers.

DISABLE

Supported On UX WS DOS IN
Option Required None
Keyboard Executable Yes
Programmable Yes
In an IF ... THEN ... Yes

DISABLE disables all event-initiated branches currently defined, except ON END, ON ERROR, and ON TIMEOUT.

Example Statements

DISABLE

Syntax

Semantics

If an event occurs while the event-initiated branches are disabled, only the first occurrence of each event is logged; there is no record of how many of each type of event has occurred.

If event-initiated branches are enabled after being disabled, all logged events will initiate their respective branches if and when system priority permits. ON ERROR, ON END, and ON TIMEOUT branches are not disabled by DISABLE.

DISABLE EXT SIGNAL

Supported On UX WS*
Option Required RMBUX
Keyboard Executable Yes
Programmable Yes
In an IF ... THEN ... Yes

DISABLE EXT SIGNAL disables system-generated signals by causing them to be ignored by HP BASIC . This statement can be entered in the HP BASIC/UX/WS ; editor, but executes only in HP BASIC/UX .

Example Statements

DISABLE EXT SIGNAL 4
DISABLE EXT SIGNAL Sigsys

Syntax

Item Description Range
signal number numeric expression, rounded to integer 1 through 32 (see ON EXT SIGNAL)

Semantics

This statement causes the specified EXT SIGNAL to be ignored by HP BASIC . This does not allow an ON EXT SIGNAL to trigger, nor does it allow the default action to take place. Also, it does not cause the EXT SIGNAL action (default or user specified) to change.

Only supported system signals may be specified. See ON EXT SIGNAL for a list of valid signal numbers.

DISABLE INTR

Supported On UX WS DOS IN
Option Required IO
Keyboard Executable Yes
Programmable Yes
In an IF ... THEN ... Yes

DISABLE INTR disables interrupts from an interface by turning off the interrupt-generating mechanism on the interface.

Example Statements

DISABLE INTR 7
DISABLE INTR Isc

Syntax

DISP

Supported On UX WS DOS IN
Option Required None
Keyboard Executable Yes
Programmable Yes
In an IF ... THEN ... Yes

DISP prints the specified items on the display line. The display line is a single line near the bottom of the alphanumeric display.

Example Statements

DISP Prompt$;
DISP TAB(5),First,TAB(20),Second
DISP
DISP Name$,Id;Code
DISP USING Form3;Item(1),Item(2)
DISP USING "5Z.DD";Money

Syntax

Item Description Range
image line label name identifying an IMAGE statement any valid name
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 specifier string expression (see diagram)
string array name name of a string array any valid name
numeric array name name of a numeric array any valid name
column numeric expression, rounded to an integer 1 through screenwidth
image specifier list literal (see diagram)
repeat factor integer constant 1 through 32 767
literal string constant composed of characters entered from the keyboard, including those generated using the [ANY CHAR] key quote mark not allowed

Semantics

Standard Numeric Format

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 separated by a semicolon.

Automatic End-Of-Line Sequence

After the display list is exhausted, an End Of Line (EOL) sequence is sent to the display line, unless it is suppressed by trailing punctuation or a pound-sign image specifier.

Control Codes

Some ASCII control codes have a special effect in DISP statements:

Character Keystroke Name Action
CHR$(7) CTRL-G bell Sound the beeper
CHR$(8) CTRL-H backspace Move the cursor back one character.
CHR$(12) CTRL-L form-feed Clear the display line.
CHR$(13) CTRL-M carriage-return Move the cursor to column 1. The next character sent to the display clears the display line, unless it is a carriage-return.

CRT Enhancements

There are several character enhancements (such as inverse and underlining) available on some CRTs. They are accessed through characters with decimal values above 127. For a list of the characters and their effects, see the "Display Enhancement Characters" table in "Useful Tables" at the back of this book.

Arrays

Entire arrays may be displayed using the asterisk specifier. Each element in an array is treated as a separate item by the DISP 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. COMPLEX array elements are treated as if the real and imaginary parts are separated by a semicolon. The array is output in row major order (rightmost subscript varies fastest).

Display Without USING

If DISP is used without USING, the punctuation following an item determines the width of the item's display field; a semicolon selects the compact field, and a comma selects the default display field. When the display item is an array with the asterisk array specifier, each array element is considered a separate display item. Any trailing punctation will suppress the automatic EOL sequence, in addition to selecting the display field to be used for the display item preceding it.

The compact field is slightly different for numeric and string items. Numeric items are displayed with one trailing blank. String items are displayed with no leading or trailing blanks.

The default display field displays items with trailing blanks to fill to the beginning of the next 10-character field.

Numeric data is displayed with one leading blank if the number is positive, or with a minus sign if the number is negative, whether in compact or default field.

In the TAB function, a column parameter less than one is treated as one. A column parameter greater than the screen width (in characters) is treated as equal to the screen width.

Display With USING

When the computer executes a DISP 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 display items, the field specifier is acted upon without accessing the display list. When the field specifier requires characters, it accesses the next item in the display list, using the entire item. Each element in an array is considered a separate item.

The processing of image specifiers stops when a specifier is encountered that has no matching display item (and the specifier requires a display specifier). If the image specifiers are exhausted before the display items, they are reused, starting at the beginning.

COMPLEX values require 2 REAL image specifiers (i.e. each COMPLEX value is treated like 2 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 rightmost characters are lost. If it is shorter than the specifier, trailing blanks are used to fill out the field.

Effects of the image specifiers on the DISP statement are shown in the following table:

Image \Specifier Meaning

K

Compact field. Displays 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 displayed using the European number format (comma radix). (Requires IO)

-H

Same as H. (Requires IO)

S

Displays the number's sign (= or -).

M

Displays the number's sign if negative, a blank if positive.

D

Digit specifier displays 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 displayed, it will float to the left of the left-most digit.

Z

Same as D, except that leading zeros are displayed.

*

Same as Z, except that asterisks are displayed instead of leading zeros. (Requires IO)

.

Displays a decimal-point radix specifier.

R

Displays a comma radix specifier (European radix). (Requires IO)

E

Displays an E, a sign, and a two-digit exponent.

ESZ

Displays an E, a sign, and a one-digit exponent.

ESZZ

Same as E.

ESZZZ

Displays an E, a sign, and a three-digit exponent.

A

Displays 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

Displays a blank.

literal

Displays the characters contained in the literal.

B

Displays 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

Displays two characters represented by the two bytes of a 16-bit, two's-complement integer. The corresponding numeric item is rounded to an INTEGER. If it is greater than 32 767, then 32 767 is used; if it is less than -32 768, then -32 768 is used. The most-significant byte is sent first.

Y

Same as W. (Requires IO)

#

Suppresses the automatic output of an EOL (End-Of-Line) sequence following the last display item.

%

Ignored in DISP images.

=

Changes the automatic EOL sequence that normally follows the last display item to a single carriage-return. (Requires IO)

-

Changes the EOL automatic sequence that normally follows the last display item to a single line-feed. (Requires IO)

/

Sends a carriage-return and a line-feed to the display line.

L

Same as /.

@

Sends a form-feed to the display line.

DISPLAY FUNCTIONS

Supported On UX* WS DOS IN
Option Required CRTX
Keyboard Executable Yes
Programmable Yes
In an IF ... THEN ... Yes

DISPLAY FUNCTIONS enables and disables the display functions mode. This mode causes control characters sent to the CRT to be displayed.

Example Statements

DISPLAY FUNCTIONS ON
DISPLAY FUNCTIONS OFF
IF No_ctrl_char THEN DISPLAY FUNCTIONS OFF

Syntax

Semantics

Except for the carriage-return character, all subsequent control characters sent to the display (while in the display functions mode) do not invoke their defined function, but are only displayed. The carriage-return is both displayed and causes the print position to move to the beginning of the next line (both CR and LF functions invoked).

Also available as CRT CONTROL register 4.

HP BASIC/UX Specifics

To enable and disable the display function mode while running HP BASIC/UX in the X11 Window environment, use CRT Control Register 4. For example, the following command will allow you to turn on the display functions mode for HP BASIC/UX window number 601:

CONTROL 601,4;1

If you specify a font that does not have the control character you are printing, a space will be displayed instead.

DIV

Supported On UX WS DOS IN
Option Required None
Keyboard Executable Yes
Programmable Yes
In an IF ... THEN ... Yes

DIV returns the integer portion of the quotient of the dividend and the divisor.

Example Statements

Quotient=Dividend DIV Divisor
PRINT "Hours =";Minutes DIV 60

Syntax

Item Description Range
dividend numeric expression --
divisor numeric expression not equal to 0

Semantics

DIV returns a REAL value unless both arguments are INTEGER. In the latter case, the returned value is INTEGER.

DIV is not defined for COMPLEX arguments.

See the discussion "Precision and Accuracy" in the section "Numeric Computation" of the HP BASIC Programming Guide for detailed information on the effects of the computer's internal numeric representation.

DOT

Supported On UX WS DOS
Option Required MAT
Keyboard Executable Yes
Programmable Yes
In an IF ... THEN ... Yes

DOT returns the inner (dot) product of two numeric vectors.

Example Statements

Res=DOT(Vec1,Vec2)
PRINT DOT(A,B)

Syntax

Item Description Range
vector name name of a one-dimensional numeric array any valid name

Semantics

The dot product is calculated by multiplying corresponding elements of the two vectors and then summing the products. The two vectors must be the same current size. If both vectors are INTEGER, the product will be an INTEGER. If either vector is COMPLEX, the product will be COMPLEX. Otherwise, the product will be of type REAL.

DRAW

Supported On UX WS DOS IN
Option Required GRAPH
Keyboard Executable Yes
Programmable Yes
In an IF ... THEN ... Yes

DRAW draws a line from the pen's current position to the specified X and Y coordinate position using the current line type and pen number.

Example Statements

DRAW 10,90
DRAW Next_x,Next_y

Syntax

Item Description Range
x coordinate numeric expression, in current units
y coordinate numeric expression, in current units

Semantics

The X and Y coordinate information is interpreted according to the current unit-of-measure.

A DRAW to the current position generates a point. DRAW updates the logical pen position at the completion of the DRAW statement and leaves the pen down. The line is clipped at the current clipping boundary.

If none of the line is inside the current clipping limits, the pen is not moved, but the logical pen position is updated.

Applicable Graphics Transformations
Scaling PIVOT CSIZE LDIR PDIR
Lines (generated by moves and draws) X X [4]
Polygons and rectangles X X X
Characters (generated by LABEL) X X
Axes (generated by AXES and GRID) X
Location of labels [1] [3] [2]

1The starting point for labels drawn after lines or axes is affected by scaling.

2The starting point for labels drawn after other labels is affected by LDIR.

3The starting point for labels drawn after lines or axes is affected by PIVOT.

4RPLOT and IPLOT are affected by PDIR.

DROUND

Supported On UX WS DOS IN
Option Required None
Keyboard Executable Yes
Programmable Yes
In an IF ... THEN ... Yes

DROUND rounds a numeric expression to the specified number of digits. If the specified number of digits is greater than 15, no rounding takes place. If the number of digits specified is less than 1, zero is returned.

Example Statements

Test_real=DROUND(True_real,12)
PRINT "Approx. Volts =";DROUND(Volts,3)

Syntax

Item Description Range
argument numeric expression --
number of digits numeric expression, rounded to an integer --

Semantics

COMPLEX numbers are not allowed as arguments to this function.

DUMP

Supported On UX* WS DOS
Option Required None
Keyboard Executable Yes
Programmable Yes
In an IF ... THEN ... Yes

DUMP ALPHA copies the contents of the alphanumeric display to a printer.

DUMP GRAPHICS copies the contents of the graphics display to an output device.

Example Statements

DUMP ALPHA
DUMP ALPHA #701
DUMP ALPHA 602 !  HP BASIC/UX in X only
DUMP ALPHA 602 TO #604 ! HP BASIC/UX in X only
DUMP ALPHA 1 TO #701 ! HP BASIC/UX/WS only
DUMP GRAPHICS
DUMP GRAPHICS 602 !   HP BASIC/UX in X only
DUMP GRAPHICS #Device
DUMP GRAPHICS Color_source
DUMP GRAPHICS 28 TO #702

Syntax

Item Description Range
source device selector numeric expression, rounded to an integer; Default = last CRT plotting device (see Glossary)
destination device selector numeric expression, rounded to an integer; Default = DUMP DEVICE IS device external interfaces and windows only (see Glossary)

Semantics

DUMP ALPHA copies the contents of the alphanumeric display to an output device. With a bit-mapped alpha display, the alpha buffer is sent to the printer as alphanumeric characters.

DUMP GRAPHICS copies the entire contents of the CRT or window, which may contain bit-mapped alpha, to the current DUMP DEVICE IS device (usually a printer). Performing DUMP GRAPHICS to a device which does not support the HP Raster Interface Standard will produce unpredictable results. The HP 2631G, HP 9876, and the ThinkJet printers are among devices that support this standard. Windows do not support this standard. (See the Configuration Reference for a complete list of supported HP devices.)

If the destination device is not explicitly specified, it is assumed to be the current DUMP DEVICE IS device.

If EXPANDED is specified in the DUMP DEVICE IS statement, the source graphics image is doubled in both X and Y directions before being sent to the destination device. However, if both source and destination devices are explicitly specified, the image is sent without being expanded.

If a DUMP GRAPHICS operation is stopped by pressing the [Break] ([CLR I/O]) key, the printer may or may not terminate its graphics mode. Sending the printer up to 192 null characters [CHR$(0)] can be used to terminate the graphics mode on a printer such as the HP 9876.

If the source has multiple planes of graphics memory associated with a pixel, an inclusive-OR is performed on all the bits corresponding to the pixel. This determines whether to print it as black or white.

If a currently active CRT or window is explicitly specified as the source, the CRT's contents are dumped to the printer. However, if the specified CRT has not been "activated" (see following description), error 708 is reported.

Plotters are de-activated by power-up, GINIT, SCRATCH A, or [Reset]. A plotting device is activated when it is specified in a PLOTTER IS statement. In addition, the internal CRT or window is also (implicitly) activated by any of the following operations after de-activation: any pen movement; GCLEAR; GLOAD (to the current default destination); GSTORE (from the current default source); and DUMP GRAPHICS (from the current default source).

If a non-CRT source which is the current PLOTTER IS device is explicitly specified, the DUMP GRAPHICS is not performed; however, if an non-CRT source which is not the current PLOTTER IS device is explicitly specified, error 708 is reported.

On multi-plane bit-mapped display devices, which use a graphics write-enable mask, only the bits indicated by 1's will be OR'ed together and dumped.

HP BASIC/UX Specifics

DUMP GRAPHICS from a window dumps the raster image, which includes the displayed alpha text. DUMP ALPHA from a window dumps only the ASCII text contained in the window. There is no special case for non-square pixels (i.e. DUMP GRAPHICS with alpha on the display matches the image on the CRT). DUMP GRAPHICS on a terminal is not performed. DUMP GRAPHICS to a window is not permitted.

Both DUMP ALPHA and DUMP GRAPHICS are extended to support output to unnamed pipes. DUMP ALPHA supports output only to windows.

Displays with Non-Square Pixels ( HP BASIC/WS Only)

For machines which have a display with non-square pixels (such as the HP 98542A and the HP 98543A), a non-expanded DUMP GRAPHICS will produce an image that matches the CRT or window only if no alpha appears in the graphics planes. Since most printers print square pixels, this routine treats graphics pixel pairs as single elements and prints one square for each pixel pair in the frame buffer. Because alpha works with individual pixels, and not with pixel pairs, mixed alpha and graphics will appear blurred on a DUMP GRAPHICS non-expanded output. Using the EXPANDED option causes the vertical length (the height on the CRT or window) to be doubled as before, but dumps each separate pixel. In this mode, mixed alpha and graphics will appear the same on the dump as on the CRT or window.

NOTE
Some printers are not capable of printing 1024 graphics dots per line, so images dumped will be truncated to fit the printer.

DUMP DEVICE IS

Supported On UX* WS DOS
Option Required GRAPH
Keyboard Executable Yes
Programmable Yes
In an IF ... THEN ... Yes

DUMP DEVICE IS specifies which device receives the data when either DUMP ALPHA or DUMP GRAPHICS is executed without a device selector.

Example Statements

DUMP DEVICE IS 721
DUMP DEVICE IS Printer,EXPANDED
DUMP DEVICE IS 614 !HP BASIC/UX in X only
DUMP DEVICE IS "plot.out" ! HP BASIC/UX/WS only

DUMP DEVICE IS " | conv |  lp",EXPANDED !  HP BASIC/UX  only

The following example is valid on HP BASIC/WS only. It requires the MS binary.

DUMP DEVICE IS 721;APPEND

The following examples require the LANGUAGE binary.

DUMP DEVICE IS 721;EXCHANGE "HP16"
DUMP DEVICE IS 701;EXCHANGE "JIS" SHIFT IN In$ OUT Out$

Item Description Range
file specifier string expression (See MASS STORAGE IS)
device selector numeric expression, rounded to an integer; Default = 701 external interfaces or windows only (see Glossary)
exchange string string expression choices depend on LANGUAGE
shift in string string expression depends on printer used; six bytes maximum
shift out string string expression depends on printer used; six bytes maximum

Semantics

Doing a DUMP GRAPHICS to a printer which does not support the HP Raster Interface Standard will produce unpredictable results. The HP 9876 and the HP 2631G are among the devices or files which support the standard. (See the Configuration Reference for a complete list of supported HP devices or files.)

Specifying EXPANDED results in graphics dumps that are twice as big on each axis (except for displays with non-square pixels -- see DUMP GRAPHICS for details) and turned sideways. This gives four dots on the printer for each dot on the display. The resulting picture does not fit on one page of an HP 9876 or HP 2631G printer.

DUMP DEVICE IS file

The file must be a BDAT or HP-UX file.

The DUMP DEVICE IS file statement positions the file pointer to the beginning of the file unless you specify the APPEND option. Thus, DUMP DEVICE IS overwrites existing files unless you specify APPEND.

The file is closed when another DUMP DEVICE IS statement is executed and at SCRATCH A.

You can read the file with ENTER if it is ASSIGNed with FORMAT ON.

An end-of-file error occurs when the end of a LIF file is reached.

If you are using a version of HP BASIC that supports wildcards, you can use them in file specifiers with DUMP DEVICE IS. You must first enable wildcard recognition using WILDCARDS. Refer to the keyword entry for WILDCARDS for details. Wildcard file specifiers used with DUMP DEVICE IS must match one and only one file name.

HP BASIC/UX Specifics

DUMP DEVICE IS supports output to windows or unnamed pipes. HP BASIC/UX treats output to a pipe as it would output to a file. The pipe must be explicitly closed before any output becomes permanent (or takes place). Output to a spooled device will not be sent to the spooler until the pipe has been closed. The closing of pipes can be achieved with a subsequent DUMP DEVICE IS, QUIT, or SCRATCH A command.

For example:


   DUMP DEVICE IS " |expand|fold|sort|pr|lp -s"

No output takes place until another DUMP DEVICE IS statement is specified, a SCRATCH A command is executed, or HP BASIC is exited.

GRAPHICS data is in raw mode, therefore be sure to specify the "raw" mode option when piping to the printer spooler, for example:

DUMP DEVICE IS " |lp -oraw"

otherwise the printer hangs. Also, it is advisable to use the -s option of lp to suppress any messages to stdout (standard output).

Using EXCHANGE and SHIFT IN...OUT (Requires LANGUAGE)

Some localized versions of HP BASIC , such as Japanese localized HP BASIC , support two-byte characters. The secondary keyword EXCHANGE allows you to automatically convert internal HP-15 character codes to the codes supported by your two-byte printer. The available choices and default values for the exchange string depend on the particular LANGUAGE localization binary that you are using. EXCHANGE affects DUMP ALPHA only. If your specify EXCHANGE without an exchange string, "HP-16" is assumed.

The secondary keywords SHIFT IN and OUT are useful with certain printers that use special control strings to turn two-byte printing on and off. HP BASIC automatically sends the specified shift in string before two-byte characters. HP BASIC also sends the specified shift out string before one-byte characters that follow two-byte characters.

NOTE
SHIFT IN and SHIFT OUT cause Error 257 if used with HP-15 characters. Use EXCHANGE to convert HP-15 characters to your LANGUAGE two-byte characters.

Also note that when the LANGUAGE binary is loaded, HP-16 Code Conversion is the default mode for the DUMP DEVICE IS device.

For a general discussion of globalization and localization including printers, refer to HP BASIC Porting and Globalization. For LANGUAGE specific details, refer to Using LanguageX with HP BASIC , where LanguageX is your local language.

DVAL

Supported On UX WS DOS IN
Option Required None
Keyboard Executable Yes
Programmable Yes
In an IF ... THEN ... Yes

DVAL converts a binary, octal, decimal, or hexadecimal character representation to a numeric value. The digits to be converted must be one-byte ASCII characters.

Example Statements

Number=DVAL(String$,Radix)
PRINT DVAL("FF5900",16)

Syntax

Item Description Range
string argument string expression, containing digits valid for the specified base (see tables)
radix numeric expression, rounded to an integer 2, 8, 10, or 16

Semantics

The radix is a numeric expression that will be rounded to an integer and must evaluate to 2, 8, 10, or 16.

The string expression must contain only the characters allowed for the particular number base indicated by the radix. ASCII spaces are not allowed. Only one-byte ASCII characters can be used as digits.

Binary strings are presumed to be in two's-complement form. If all 32 digits are specified and the leading digit is a 1, the returned value is negative.

Octal strings are presumed to be in the octal representation of two's-complement form. If all 11 digits are specified, and the leading digit is a 2 or a 3, the returned value is negative.

Decimal strings containing a leading minus sign will return a negative value.

Hex strings are presumed to be in the hex representation of the two's-complement binary form. The letters A through F may be specified in either uppercase or lowercase letters. If all 8 digits are specified and the leading digit is 8 through F, the returned value is negative.

Radix Base String Range String Length
2 binary 0 through

11111111111111111111111111111111

1 to 32 characters
8 octal 0 through 37777777777 1 to 11 characters
10 decimal -2 147 483 648 through 2 147 483 647 1 to 11 characters
16 hexadecimal 0 through FFFFFFFF 1 to 8 characters

Radix Legal Characters Comments
2 +,0,1 --
8 +,0,1,2,3,4,5,6,7 Range restricts the leading character. Sign, if used, must be a leading character.
10 +,-,0,1,2,3,4,5,6,7,8,9 Sign, if used, must be a leading character.
16 +,0,1,2,3,4,5,6,7,8,9, A,B,C,D,E,F,a,b,c,d,e,f A/a = 10, B/b = 11, C/c = 12,

D/d = 13, E/e = 14, F/f = 15

Two-Byte Language Specifics

Certain localized versions of HP BASIC , such as Japanese localized HP BASIC , support two-byte characters. DVAL does not allow two-byte characters. The string digits to be converted must be one-byte ASCII characters. For more information about two-byte characters, refer to the globalization chapters of HP BASIC Porting and Globalization.

DVAL$

Supported On UX WS DOS IN
Option Required None
Keyboard Executable Yes
Programmable Yes
In an IF ... THEN ... Yes

DVAL$ converts a numeric value to a string of binary, octal, decimal, or hexadecimal digits. The resulting string contains digits that are one-byte ASCII characters.

Example Statements

String$=DVAL$(Number,Radix)
PRINT DVAL$(Count MOD 256,2)

Syntax

Item Description Range
32-bit argument numeric expression, rounded to an integer -231through 231-1
radix numeric expression, rounded to an integer 2, 8, 10, or 16

Semantics

The rounded argument must be a value that can be expressed (in binary) using 32 bits or less. The string digits returned are one-byte ASCII characters.

The radix must evaluate to be 2, 8, 10, or 16--representing binary, octal, decimal, or hexadecimal notation, respectively.

If the radix is 2, the returned string is in two's-complement form and contains 32 characters. If the numeric expression is negative, the leading digit will be 1. If the value is zero or positive, there will be leading zeros.

If the radix is 8, the returned string is the octal representation of the two's-complement binary form and contains 11 digits. Negative values return a leading digit of 2 or 3.

If the radix is 10, the returned string contains 11 characters. Leading zeros are added to the string if necessary. Negative values have a leading minus sign.

If the radix is 16, the returned string is the hexadecimal representation of the two's-complement binary form and contains 8 characters. Negative values return with the leading digit in the range 8 through F.

Radix Base Range of Returned String String Length
2 binary 00000000000000000000000000000000

through

11111111111111111111111111111111

32 characters
8 octal 00000000000 through 37777777777 11 characters
10 decimal -2 147 483 648 through 2 147 483 647 11 characters
16 hexadecimal 00000000 through FFFFFFFF 8 characters