IDN - IVAL

IDN

See MAT.

IDRAW

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

IDRAW draws a line from the current pen position to a position calculated by adding the X and Y displacements to the current pen position.

Example Statements

IDRAW X=50,0
IDRAW Delta_x,Delta_y

Syntax

Item Description Range
x displacement numeric expression in current units --
y displacement numeric expression in current units --

Semantics

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

The line drawn by IDRAW is clipped at the current clipping boundary.

An IDRAW 0,0 generates a point. IDRAW updates the logical pen position at the completion of the IDRAW statement and leaves the pen down.

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 & GRID) X
Location of Labels [1] [3] [2]

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

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

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

[4]RPLOT and IPLOT are affected by PDIR.

IF...THEN

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

IF...THEN provides conditional branching.

Example Statements


150  IF Flag THEN Next_file
160  IF Pointer<1 THEN Pointer=1

580 IF First_pass THEN 
590     Flag=0 
600 INPUT "Command?",Cmd$ 
610 IF LEN(Cmd$) THEN GOSUB Parse 
620 END IF 

1000 IF X 0 THEN 
1010    BEEP 
1020    DISP "Improper Argument" 
1030 ELSE 
1040    Root=SQR(X) 
1050 END IF 

Item Description Range
boolean expression numeric expression; evaluated as true if non-zero and false if zero --
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)
statement a programmable statement (see following list)
program segment any number of contiguous program lines not containing the beginning or end of a main program or subprogram. --

Semantics

If the boolean expression evaluates to 0, it is considered false; if the evaluation is non-zero, it is considered true. Note that a boolean expression can be constructed with numeric or string expressions separated by relational operators, as well as with a numeric expression.

Single Line IF...THEN

If the conditional statement is a GOTO, execution is transferred to the specified line. The specified line must exist in the current context. A line number or line label by itself is considered an implied GOTO. For any other statement, the statement is executed, then program execution resumes at the line following the IF...THEN statement. If the tested condition is false, program execution resumes at the line following the IF...THEN statement, and the conditional statement is not executed.

Prohibited Statements

The following statements must be identified at prerun time or are not executed during normal program flow. Therefore, they are not allowed as the statement in a single line IF...THEN construct.

CASE               END                     IF                           REM
CASE ELSE END IF IMAGE REPEAT
COM END LOOP INTEGER SELECT
COMPLEX END SELECT LOOP SUB
DATA END WHILE NEXT SUBEND
DEF FN EXIT IF OPTION BASE UNTIL
DIM FNEND REAL WHILE
ELSE FOR

When ELSE is specified, only one of the program segments will be executed. When the condition is true, the segment between IF...THEN and ELSE is executed. When the condition is false, the segment between ELSE and END IF is executed. In either case, when the construct is exited, program execution continues with the statement after the END IF.

Branching into an IF...THEN construct (such as with a GOTO) results in a branch to the program line following the END IF when the ELSE statement is executed.

The prohibited statements listed above are allowed in multiple-line IF...THEN constructs. However, these statements are not executed conditionally. The exceptions are other IF...THEN statements or constructs such as FOR...NEXT, REPEAT...UNTIL, etc. These are executed conditionally, but need to be properly nested. To be properly nested, the entire construct must be contained in one program segment.

IMAG

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

IMAG returns the imaginary part of a COMPLEX number.

Example Statements

X=IMAG(Complex_expr)
Y=IMAG(Real_expr)
Z=IMAG(Integer_expr)
Result=IMAG(CMPLX(2.1,-8))

Syntax

Item Description/Default Range\Restrictions
argument numeric expression any valid INTEGER, REAL, or COMPLEX value

Semantics

If the argument is not a COMPLEX value, the result is 0.

IMAGE

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

IMAGE statements specify special codes (image specifiers) for formatting data for use with various I/O statements such as ENTER, OUTPUT, DISP, LABEL, and PRINT. These image specifiers can also be included after the secondary keyword USING within the I/O statements.

Example Statements

IMAGE 4Z.DD,3X,K,/
IMAGE "Result = ",SDDDE,3(XX,ZZ)
IMAGE #,B

Syntax

Item Description Range
IMAGE statement items literal (see drawing)
repeat factor integer constant 1 through 32 767
literal string composed of characters from the keyboard, including those generated using the ANY CHAR key. quote mark not allowed

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 HP BASIC Porting and Globalization manual. For LANGUAGE specific details, refer to Using LanguageX With HP BASIC, where LanguageX is your local language.

IMOVE

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

IMOVE lifts and moves the graphics pen from the current pen position to a position calculated by adding the specified X and Y displacements to the current pen position.

Example Statements

IMOVE X=50,0
IMOVE Delta_x,Delta_y

Syntax

Item Description Range
x displacement numeric expression in current units --
y displacement numeric expression in current units --

Semantics

IMOVE updates the logical position of the graphics pen, by adding the X and Y displacements to the current logical pen position. The pen is raised before it moves and remains up after the move. The X and Y displacements are interpreted according to the current unit-of-measure.

If both current physical pen position and specified pen position are outside current clip limits, no physical pen movement is made; however, the logical pen is moved the specified displacement.

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 & GRID) X
Location of Labels [1] [3] [2]

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

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

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

[4]RPLOT and IPLOT are affected by PDIR.

INDENT

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

INDENT indents program lines in the editor to reflect the program's structure and nesting.

Example Statements


  INDENT
  
  INDENT 8,4

Syntax

Item Description Range
starting column integer constant; Default = 7 0 through Screen Width-8
increment integer constant; Default = 2 0 through Screen Width-8

Semantics

The starting column specifies the column in which the first character of the first statement of each context appears. The increment specifies the number of spaces that the beginning of the lines move to the left or right when the nesting level of the program changes. Note that a line label may override the indentation computed for a particular line. The INDENT command does not move comments which start with an exclamation point, but it does move comments starting with REM. However, if a program line is moved to the right a comment after it may have to be moved to make room for it. In both of these cases (line labels and comments), the text moves only as far as is necessary; no extra blanks are generated.

Indenting a program may cause the length of some of its lines to become longer than the machine can list. This condition is indicated by the presence of an asterisk after the line numbers of the lines which are overlength. If this occurs, the program will run properly, STORE properly and LOAD properly. If the total length of a line exceeds 256 characters, you cannot do a SAVE, then a GET. Doing an INDENT with smaller values will alleviate this problem.

Indentation occurs after the following statements:

FOR                   REPEAT
LOOP WHILE
SUB SELECT
IF...THEN1 DEF FN

1This is only true for IF..THEN statements where the THEN is followed by an end-of-line or an exclamation point.

The following statements cause a one-line indentation reversal; that is, indentation is reversed for these statements but re-indented immediately after them:

CASE EXIT IF
CASE ELSE       FNEND
ELSE SUBEND

Indentation is reversed before the following statements:

END IF END WHILE
END LOOP NEXT
END SELECT       UNTIL

Indentation remains the same from line to line for all other statements.

Improperly matched nesting will cause improper indentation. Deeply nested constructs may cause indentation to exceed screen width-8. However, visible indentation is bounded by starting column and screen width-8. If a large Increment is used, indentation may attempt to go beyond screen width-8. This will not be allowed to occur, but an internal indentation counter is maintained, so construct-forming statements will have matching indentation.

INITIALIZE

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

INITIALIZE prepares mass storage media for use by the computer. When INITIALIZE is executed, any data on the media is lost. INITIALIZE may not be used to create HFS volumes; to format an HFS volume, use the DISC_UTIL program. Only an unmounted disk may be initialized LIF format in HP BASIC/UX .

Example Statements

INITIALIZE ":INTERNAL" ! HP BASIC/WS only
INITIALIZE ":HP9133,702,0"
INITIALIZE Disc$,2
INITIALIZE Disc$,Interleave
INITIALIZE ":MEMORY,0,2",Sectors
INITIALIZE DISC$,Interleave,Format

Item Description Range
volume specifier string expression (see MASS STORAGE IS)
interleave factor numeric expression, rounded to an integer; Default = device dependent (see table) 0 through 15
format option numeric expression Default = 0 device dependent
RAM volume specifier string expression (see drawing)
RAM unit size numeric expression, rounded to an integer; specifies number of 256-byte sectors; Default = 1056 (size of a 5 1/4 -inch or single-sided 3 1/2 -inch disk) 4 through 32 767 memory-dependent

Semantics

Any media used by the computer must be initialized before its first use. Initialization creates a new LIF directory, eliminating any access to old data. The media is partitioned into physical records. The quality of the media is checked during initialization. Defective tracks are "spared" (marked so that they will not be used subsequently).

Note that when executing INITIALIZE from the keyboard, HP BASIC prompts you to continue, thus ensuring safe initialization. HP BASIC does not prompt you to continue when executing INITIALIZE from a program.

Interleave Factor

The interleave factor establishes the distance (in physical sectors) between consecutively numbered sectors. The interleave factor is ignored if the mass storage device is not a disk. If you specify 0 for the interleave factor, the default for the device is used.

Device Type Default\Interleave
INTERNAL

1

CS80

[a]

HP 9121

2

HP 913X (floppy)

4

HP 913X (hard)

9

HP 9895

3

HP 8290X

4

aCS80 disks use the current interleave as the default. If the disk is uninitialized, the interleave recommended for that disk is used. Factory-shipped interleave is 1 for the HP 7908, HP 7911, HP 7912 and HP 7914 disks. An uninitialized HP 9122 disk has a default interleave of 2.

Format Option

Some mass storage devices allow you to select the sector or volume size with which the disk is initialized. Omitting this parameter or specifying 0 initializes the disk to the default sizes. Refer to the disk drive manual for options available with your disk drive. For example, when initializing a single-sided flexible disk on the HP 9122 double-sided flexible disk drive, use a value of 4 (256-byte sectors, and 270K bytes total volume size).

Initializing EPROM (Requires EPROM)

In order to initialize an EPROM unit, it must be completely erased. The select code specified in the INITIALIZE statement must be the select code of the EPROM Programmer card currently connected to the EPROM memory card; if not, error 72 is reported.

The unit number must be one greater than the greatest unit number of any initialized EPROM unit currently in the system. For example, if the greatest unit number of an EPROM unit in the system is 3, then the unit to be initialized must be unit number 4.

INITIALIZE and HFS Volumes

Since INITIALIZE creates a LIF directory, it cannot alone be used to format an HFS disk; it will still, however, scan the volume for bad sectors. To format an HFS volume on the HP BASIC/WS|, use the System Disk Utility (DISC_UTIL, which calls the "Mkhfs" compiled subprogram to place an HFS-format directory on the disk volume). See the "BASIC Utilities Library" chapter of Installing and Maintaining HP BASIC/WS 6.2 or Installing and Maintaining HP BASIC/UX for instructions on using this utility.

On HP BASIC/UX , use the HP-UX command newfs command. See the HP-UX Reference, newfs(1m) entry.

INITIALIZE and SRM Volumes

Since INITIALIZE creates a LIF directory, it cannot be used with SRM (which uses the Structured Directory Format, SDF). An error will be reported if you attempt to initialize a REMOTE volume from a workstation.

Recovering MEMORY Volume Space

RAM disk memory can be reclaimed if no binaries have been loaded after initializing the memory volume. To recover this memory, you would execute a line similar to the following:

INITIALIZE ":,0, unit number ",0

Initializing the volume to 0 sectors removes it from memory.

Memory volumes are allocated in a mark and release stack. What this means is, you get the memory back only when other subsequently created memory volumes have been reclaimed. You can re-initialize a removed memory volume in its original space provided the newly allocated space is no larger than the original space that was allocated. Otherwise, new space will be allocated for it.

HP BASIC/UX Specifics

Only an unmounted disk may be initialized, in LIF format.

HP BASIC/DOS Specifics

For LIF media in external HP-IB disk drives, INITIALIZE works the same as for Series 200/300.

INITIALIZE cannot be used to format LIF media in internal PC drives (use the LIFINIT utility). In internal drives, INITIALIZE formats an HPW (virtual-LIF) disk through select code 15.

INITIALIZE cannot be used to format a DFS disk (use the MS-DOS "FORMAT" command).

INMEM

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

INMEM checks for the presence of a user subprogram (SUB) or function (FN) in memory.

Example Statements

IF NOT INMEM("Mysub")THEN LOADSUB ALL FROM "MYSUBS"
IF NOT INMEM("FNMyfunc$")THEN LOADSUB ALL FROM "MYFUNCS"

Syntax

Item Description Range
name string name of string variable any valid name

Semantics

This function works for subprograms (SUBs) and functions (FNs), both compiled and non-compiled. It is particularly useful when you want to conserve memory by programmatically loading and deleting subprograms.

INPUT

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

INPUT is used to assign keyboard input to program variables.

Example Statements

INPUT "Name?",N$,"ID Number?",Id
INPUT "Enter 3 numbers",V(1),V(2),V(3)
INPUT "",String$[1;10]
INPUT Array(*)

Item Description/Default Range\Restrictions
prompt a literal composed of characters from the keyboard, including those generated using the ANY CHAR key;Default = question mark --
string name name of a string variable any valid name
subscript numeric expression, rounded to an integer -32 768 through +32 767 (see array in Glossary)
beginning position numeric expression, rounded to an integer 1 through +32 767 (see substring in Glossary)
ending position numeric expression, rounded to an integer 0 through +32 767 (see substring in Glossary)
substring length numeric expression, rounded to an integer 0 through +32 767 (see substring in Glossary)
numeric name name of a numeric variable any valid name

Semantics

Values can be assigned through the keyboard for any numeric or string variable, substring, array, or array element.

A prompt, which is allowed for each item in the input list, appears on the display line. If the last DISP or DISP USING statement suppressed its EOL sequence, the prompt is appended to the current display line contents. If the last DISP or DISP USING did not suppress the EOL sequence, the prompt replaces the current display line contents.

Not specifying a prompt results in a question mark being used as the prompt. Specifying the null string for the prompt suppresses the question mark.

To respond to the prompt, the operator enters a number or a string. Leading and trailing blank characters are deleted. Unquoted strings may not contain commas or quotation marks. Placing quotes around an input string allows any character(s) to be used as input. If " is intended to be a character in a quoted string, use "". Note that when you are prompted to input a COMPLEX value, you must input two REAL values (one representing the real part and another representing the imaginary part) separated by a comma or a [Return] or [ENTER]. Multiple values can be entered individually or separated by commas. Press the [CONTINUE], [Return], [EXECUTE], [ENTER] or [STEP] after typing the final data item. Two consecutive commas cause the corresponding variable to retain its original value. Terminating an input line with a comma retains the old values for all remaining variables in the list.

The assignment of a value to a variable in the INPUT list is done as soon as the terminator (comma or key) is encountered. Entering no data items and pressing [CONTINUE], [ENTER], [EXECUTE], [Return], or [STEP] retains the old values for all remaining variables in the list.

If you press [CONTINUE], [ENTER], [EXECUTE], or [Return] to end the data input, program execution continues at the next program line. If [STEP] is pressed, the program execution continues at the next program line in single step mode. (If the INPUT was stepped into, it is stepped out of, even if [CONTINUE], [ENTER], [EXECUTE], or [Return] is pressed.)

If too many values are supplied for an INPUT list, the extra values are ignored.

An entire array may be specified by the asterisk specifier. Inputs for the array are accepted in row major order (right-most subscript varies most rapidly).

Live keyboard operations are not allowed while an INPUT is awaiting data entry. [PAUSE] or [STOP] on an HP 46020 keyboard can be pressed so live keyboard operations can be performed. The INPUT statement is re-executed, beginning with the first item, when [CONTINUE] or [STEP] is pressed. All values for that particular INPUT statement must be re-entered.

Keyboard-initiated events are deactivated during an INPUT statement. Errors do not cause an ON ERROR branch. If an input response results in an error, re-entry begins with the variable which would have received the erroneous response.

INT

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

INT returns the greatest integer which is less than or equal to its argument. The result will be of the same numeric type (REAL or INTEGER) as the argument.

Example Statements

Whole=INT(Number)
PRINT "Integer portion =";INT(X)

Syntax

Semantics

COMPLEX arguments are not allowed with this function.

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.

INTEGER

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

INTEGER declares integer variables, dimensions integer arrays, and allocates memory for the variables and arrays. For information about INTEGER as a secondary keyword, see ALLOCATE, COM, DEF FN, or SUB.

Example Statements

INTEGER I,J,K
INTEGER Array(-128:255,4)
INTEGER Buf(2000) BUFFER

Syntax

Item Description Range
numeric name name of a numeric 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)

Semantics

An INTEGER variable (or an element of an INTEGER array) uses two bytes of storage space. An INTEGER array can have a maximum of six dimensions. No single dimension can have more than 32 767 total elements.

The total number of INTEGER elements 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).

Declaring Buffers

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

INTENSITY

See AREA and SET PEN.

INTERACTIVE

See RESUME INTERACTIVE and SUSPEND INTERACTIVE.

INTR

See OFF INTR and ON INTR.

INV

See MAT.

IPLOT

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

IPLOT moves the graphics pen from the current pen position to the point specified by adding the X and Y displacements to the current pen position. Plotting action is determined by the current line type and the optional pen control parameter.

Example Statements

IPLOT 0,5
IPLOT Delta_x,Delta_y,Pen_control

The following examples require the GRAPHX binary.

IPLOT Array(*)
IPLOT Shape(*),FILL,EDGE

Syntax

Item Description Range
x displacement numeric expression, in current units --
y displacement numeric expression, in current units --
pen control numeric expression, rounded to an

integer; Default = (down after move)

-32 768 through +32 767
array name name of two-dimensional, two-column

or three-column numeric array. Requires GRAPHX.

any valid name

Semantics

Non-Array Parameters

The specified X and Y displacement information is interpreted according to the current unit-of-measure. Lines are drawn using the current pen color and line type.

The line is clipped at the current clipping boundary. If none of the line is inside the current clip limits, the pen is not moved, but the logical pen position is updated.

The optional pen control parameter specifies the following plotting actions; the default value is +1 (down after move). Zero is considered positive.

Pen Control Parameter
Pen Control Resultant Action
-Even Pen up before move
-Odd Pen down before move
+Even Pen up after move
+Odd Pen down after move

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 & GRID) X
Location of Labels [1] [3] [2]

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

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

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

[4]RPLOT and IPLOT are affected by PDIR.

Summary of Array Parameter Effects

When using an IPLOT statement with an array, the following table of operation selectors applies. An operation selector is the value in the third column of a row of the array to be plotted. The array must be a two-dimensional, two-column or three-column array. If the third column exists, it will contain operation selectors which instruct the computer to carry out certain operations. Polygons may be defined, edged (using the current pen), filled (using the current fill color), pen and line type may be selected, and so forth.

IPLOT Array Parameter Effects
Column 1 Column 2 Operation\Selector Meaning
X Y -2 Pen up before moving
X Y -1 Pen down before moving
X Y 0 Pen up after moving (Same as =2)
X Y 1 Pen down after moving
X Y 2 Pen up after moving
pen number ignored 3 Select pen
line type repeat value 4 Select line type
color ignored 5 Color value
ignored ignored 6 Start polygon mode with FILL
ignored ignored 7 End polygon mode
ignored ignored 8 End of data for array
ignored ignored 9 NOP (no operation)
ignored ignored 10 Start polygon mode with EDGE
ignored ignored 11 Start polygon mode with FILL and EDGE
ignored ignored 12 Draw a FRAME
pen number ignored 13 Area pen value
red value green value 14 Color
blue value ignored 15 Value
ignored ignored >15 Ignored

FILL and EDGE

When FILL or EDGE is specified, each sequence of two or more lines forms a polygon. The polygon begins at the first point on the sequence, includes each successive point, and the final point is connected or closed back to the first point. A polygon is closed when the end of the array is reached, or when the value in the third column is an even number less than three, or in the range 5 to 8 or 10 to 15. Unexpected results can occur in attempts to FILL a polygon of zero area.

If FILL and/or EDGE are specified on the IPLOT statement itself, it causes the polygons defined within it to be filled with the current fill color and/or edged with the current pen color. If polygon mode is entered from within the array, and the FILL/EDGE directive for that series of polygons differs from the FILL/EDGE directive on the IPLOT statement itself, the directive in the array replaces the directive on the statement. In other words, if a "start polygon mode" operation selector (a 6, 10, or 11) is encountered, any current FILL/EDGE directive (whether specified by a keyword or an operation selector) is replaced by the new FILL/EDGE directive.

If FILL and EDGE are both declared on the IPLOT statement, FILL must occur first. If neither one is specified, simple line drawing mode is assumed; that is, polygon closure does not take place.

If you attempt to fill a figure on an HPGL plotter, the figure will not be filled, but will be edged, regardless of the directives on the statement.

Moving and Drawing

If the operation selector is less than or equal to two, it is interpreted in exactly the same manner as the third parameter in a non-array IPLOT statement. As mentioned above, even means lift the pen up, odd means put the pen down, positive means act after pen motion, negative means act before pen motion. Zero is considered positive.

Selecting Pens

The operation selector of 3 is used to select pens. The value in column one is the pen number desired. The value in column two is ignored.

Selecting Line Types

The operation selector of 4 is used to select line types. The line type (column one) selects the pattern, and the repeat value (column two) is the length in GDUs that the line extends before a single occurrence of the pattern is finished and it starts over. On the CRT, the repeat value is evaluated and rounded down to the next multiple of 5, with 5 as the minimum.

Selecting a Fill Color

Operation selector 13 selects a pen from the color map with which to do area fills. This works identically to the AREA PEN statement. Column one contains the pen number.

Defining a Fill Color

Operation Selector 14 is used in conjunction with Operation Selector 15. Red and green are specified in columns one and two, respectively, and column three has the value 14. Following this row in the array (not necessarily immediately), is a row whose operation selector in column three has the value of 15. The first column in that row contains the blue value. These numbers range from 0 to 32,767, where 0 is no color and 32,767 is full intensity. Operation selectors 14 and 15 together comprise the equivalent of an AREA INTENSITY statement, which means it can be used on a monochromatic, gray scale, or a color display.

Operation Selector 15 actually puts the area intensity into effect, but only if an operation selector 14 has already been received.

Operation selector 5 is another way to select a fill color. The color selection is through a Red-Green-Blue (RGB) color model. The first column is encoded in the following manner. There are three groups of five bits right-justified in the word; that is, the most significant bit in the word is ignored. Each group of five bits contains a number which determines the intensity of the corresponding color component, which ranges from zero to sixteen. The value in each field will be sixteen minus the intensity of the color component. For example, if the value in the first column of the array is zero, all three five-bit values would thus be zero. Sixteen minus zero in all three cases would turn on all three color components to full intensity, and the resultant color would be a bright white.

Assuming you have the desired intensities for red, green, and blue ranging from zero to one in the variables R, G, and B, respectively, the value for the first column in the array could be defined thus:

     Array(Row,1)=SHIFT(16*(1-B),-10)=SHIFT(16*(1-G),-5)=16*(1-R)

If there is a pen color in the color map identical to that which you request here, that non-dithered color will be used. If there is not a similar color, you will get a dithered pattern.

If you are using a gray scale display, Operation selector 5 uses the five bit values of the RGB color specified to calculate luminosity. The resulting gray luminosity is then used as the area fill. For detailed information on gray scale calculations, see the chapter "More About Color Displays" in the HP BASIC Advanced Programming Techniques manual.

Polygons

A six, ten, or eleven in the third column of the array begins a "polygon mode". If the operation selector is 6, the polygon will be filled with the current fill color. If the operation selector is 10, the polygon will be edged with the current pen number and line type. If the operation selector is 11, the polygon will be both filled and edged. Many individual polygons (series of draws separated by moves) can be filled without terminating the mode with an operation selector 7. The first and second columns are ignored; therefore they should not contain the X and Y values of the first point of a polygon.

Operation selector 7 in the third column of a plotted array terminates definition of a polygon to be edged and/or filled and also terminates the polygon mode (entered by operation selectors 6, 10, or 11). The values in the first and second columns are ignored, and the X and Y values of the last data point should not be in them. Edging and/or filling will begin immediately upon encountering this operation selector.

Drawing a FRAME

Operation selector 12 does a FRAME around the current soft-clip limits. Soft clip limits cannot be changed from within the IPLOT statement, so one probably would not have more than one operation selector 12 in an array to IPLOT, since the last FRAME will overwrite all the previous ones.

Premature Termination

Operation selector 8 causes the IPLOT statement to be terminated. The IPLOT statement will successfully terminate if the actual end of the array has been reached, so the use of operation selector 8 is optional.

Ignoring Selected Rows in the Array

Operation selector 9 causes the row of the array it is in to be ignored. Any operation selector greater that fifteen is also ignored, but operation selector 9 is retained for compatibility reasons. Operation selectors less than -2 are not ignored. If the value in the third column is less than zero, only evenness/oddness is considered.

IVAL

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

IVAL converts a binary, octal, decimal, or hexadecimal string expression into an INTEGER.

Example Statements

Number=IVAL(String$,Radix)
PRINT IVAL("FE56",16)

Syntax

Item Description Range
string argument string expression, containing digits valid for the specified base (see table)
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 16 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 6 digits are specified, and the leading digit is a 1, 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 upper or lower case. If all 4 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 1111111111111111 1 to 16 characters
8 octal 0 through 177777 1 to 6 characters
10 decimal -32 768 through =32 768 1 to 6 characters
16 hexadecimal 0 through FFFF 1 to 4 characters

Radix Legal Characters Comments
2 +,0,1 --
8 +,0,1,2,3,4,5,6,7 Range restricts the leading character. Sign must be a leading character.
10 +,-,0,1,2,3,4,5, 6,7,8,9 Sign 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. IVAL 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 the HP BASIC Porting and Globalization manual.

IVAL$

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

IVAL$ converts an integer value into a binary, octal, decimal, or hexadecimal string.

Example Statements

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

Syntax

Item Description Range
16-bit argument numeric expression, rounded to an integer (see table)
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 16 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.

If the radix is 2, the returned string is in two's-complement form and contains 16 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 6 digits. Negative values return a leading digit of 1.

If the radix is 10, the returned string contains 6 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 4 characters. Negative values return a leading digit in the range 8 through F.

Radix Base Range of Returned String String Length
2 binary 0000000000000000 through 1111111111111111 16 characters
8 octal 000000 through 177777 6 characters
10 decimal -32 768 through =32 768 6 characters
16 hexadecimal 0000 through FFFF 4 characters