HP Business BASIC/XL Reference Manual HP 3000 MPE/iX Computer Systems Edition 1 Manufacturing Part Number: 32715-90001 E1187 U.S.A.
Notice The information contained in this document is subject to change without notice. Hewlett-Packard makes no warranty of any kind with regard to this material, including, but not limited to, the implied warranties of merchantability or fitness for a particular purpose. Hewlett-Packard shall not be liable for errors contained herein or for direct, indirect, special, incidental or consequential damages in connection with the furnishing or use of this material.
Chapter 1 Introductions HP Business BASIC/XL is a high level programming language implemented on the 900 Series HP 3000. The BASIC language was developed to teach beginners about computer programming. HP Business BASIC/XL takes advantage of that ease of use, yet also provides a full interface to the powerful MPE XL operating system. HP Business BASIC/XL contains built-in interfaces to the IMAGE database management system, VPLUS screen handler, and terminal softkeys.
1-2
Chapter 2 Program Development Environment Introduction HP Business BASIC/XL's program development environment is a line editor and program interpreter that aids in program development and manages program files. HP Business BASIC/XL also has a compiler to compile programs. Compiled programs run faster than interpreted ones, so it is often a good idea to develop a program in the interpreter and compile it once it is running correctly. The compiler is explained in chapter 9.
NOTE In the examples in this chapter, user input is underlined. User input ends with RETURN unless otherwise specified. In some examples, RETURN is shown to clarify that example. The Interpreter Typing the command BBXL in response to the operating system prompt will run the interpreter. You can use options to specify a file from which input will be read or a file to which output will be written or both.
BBXL ,Infil,Outfil HP Business BASIC/XL can also be run as a program using the following syntax: RUN HPBBXL.PUB.SYS [;PARM=n ] The PARM option is used to specify two things to the interpreter: 1. How much space the interpreter should reserve for representing the currently-executing subunit. 2. Which of the BASCOM, BASIN, or BASOUT files has been respecified using a file equate. n specifies which of the parameters have been redefined. The following are the values of n: 0 No redefinition of the files.
The commands in the RUNHELLO file are executed by HP Business BASIC/XL's interpreter. In response to the RUN command, "HELLO" is printed on the terminal's screen. Incorporating the command into a stream job has the same effect. Redirecting BASCOM, BASIN, and BASOUT is useful when running stream jobs. Any of the file parameters can be specified by a local file equate statement.
[SUB] FNfunc_id Range is all of FNfunc_id, which must exist. MAIN Range is all of the main program, which must exist. ln_spec1 First line in range, specified by one of the following: line_num line_num If line_num does not exist, line_range is null (see Table 2-1 and Table 2-2). {+|-} offset The line that is offset lines from the line numbered line_num (see offset, below). The line numbered line_num must exist in the program.
ln_spec2 Last line in range. The line_num through line_label {+|-} offset are the same as specified for ln_spec1. MAIN, SUB and FN change to the corresponding last line in each. MAIN Last line in main program. default is ln_spec1. SUB sub_id Last line in sub_id. [SUB] FNfunc_id Last line in FNfunc_id. The Examples The following shows examples of specifying line ranges.
| | | | | | | | | is before first | | | | | program line, range | | | | | begins with first | | | | | program line. | | | | | | | | | | If | | | | | line_num {+|-}offset | | | | | | | | | | is after last program | | | | | line, range begins | | | | | with last program | | | | | line. | | | | | | --------------------------------------------------------------------------------------------- Table 2-2.
100+2/140 100+2/145 100+2/150-1 200-3 100/200-3 110-3/140-1 130+5 Add Add-1/Add+1 MAIN FNTwo 120/140 120/140 120/140 Error Error 100/130 180 130 If the main unit is currently executing, otherwise an error results. 120/140 If the main unit is currently executing, otherwise an error results. 100/150 160/190 Halt Key Pressing CONTROL Y while a program is executing suspends the program. Any I/O (Input or Output) operation that is in process finishes before program execution is suspended.
exceptions: * If the label or colon occupies the specified column, then the rest of the line begins in the next available column. * If the specified column is beyond 72, then the rest of the line begins in column 72. A comment (beginning with "!") is listed in the column originally entered (relative to the line number), if possible. If this is not possible because the statement occupies that column, then the comment begins in the next available column.
50 NEXT I 60 Loop2: FOR I=1 TO 2 !Fill B 70 FOR J=1 TO 4 75 REM INNER LOOP 80 B$(I,J)=CHR$(I)+CHR$(J) 85 PRINT I,J 90 NEXT J 100 NEXT I 999 END >indent 3,5 >list ! exam217 5 ! BEGIN PROGRAM 10 DIM A(5),B$(2,4)[2] 20 INTEGER X,Y,Z 30 Loop1: FOR I=1 TO 5 !Fill A 40 A(I)=I 45 PRINT I 50 NEXT I 60 Loop2: FOR I=1 TO 2 !Fill B 70 FOR J=1 TO 4 75 REM INNER LOOP 80 B$(I,J)=CHR$(I)+CHR$(J) 85 PRINT I,J 90 NEXT J 100 NEXT I 999 END > LIST Command The LIST command lists all or part of a program to the destination spec
specified. This is relevant only when the program has a name, that is, if it was retrieved by the GET command or named with the NAME command. If you have just typed in the program, and have not used the NAME command, the program will not have a name. FORMATTED FORMAT The listing is formatted using a set of the compiler listing options that appear in the program if this parameter is specified.
The LIST SUBS command prints the name and starting line number of every subunit in the program, and indicates the currently executing program unit with an asterisk (*). The LIST SUBS command is a command-only statement. That is, it can only be issued at the interpreter prompt and cannot be placed in a program. Syntax LIST SUBS Example The following example shows the use of the LIST SUBS command. When you type LIST SUBS, the first line and subunit name are displayed for each subunit in the program.
After editing the line, press RETURN. The MODIFY command displays the modified line for further modification. When you are finished with the modifications, type RETURN after the modified line is displayed. HP Business BASIC/XL modifies the line and, if it is correct, incorporates the modified line into the program. Then the next line in the line_range_list is displayed for modification.
If a modified line is too long, the MODIFY command displays the following: * * The line, except characters beyond the maximum line length. An asterisk (*) in the last column (the asterisk is character 500). To cancel modifications on a line, type "//" or CONTROL Y. The original line will be displayed for modification. To stop the MODIFY command, type "//" or CONTROL Y before modifying the currently displayed line, or type "//" or CONTROL Y immediately followed by "//" or CONTROL Y.
RETURN 100 PRINT "A,B,E,F" IC,D, RETURN 100 PRINT "A,B,C,D,E,F" RETURN 110 PRINT A,B,E,F RC,D,E,F RETURN 110 PRINT A,B,C,D,E,F RETURN 120 PRINT G,H,I B,C,D,E,F,A RETURN 120 PRINT B,C,D,E,F,A RETURN 130 PRINT A,B,H,I IC,D,E,F, RETURN 130 PRINT C,D,E,F,A,B,H,I DE RETURN 130 PRINT C,D,E,F,A,B RETURN 140 PRINT I,H,G,A,B,C D DID,E,F RETURN 140 PRINT D,E,F,A,B,C RETURN 150 PRINT E,F,G,H DE RETURN 150 PRINT // RETURN 150 PRINT E,F,G,H RA,B,C,D RETURN 150 PRINT E,F,A,B,C,D RETURN 160 PRINT F,A,B,C,D,E // RETURN >LI
180 PRINT "END" 999 END > NAME Command The NAME command names or renames the current program. The NAME command is a command-only statement. That is, it can only be issued at the interpreter prompt and cannot be placed in a program. Syntax NAME [fname ] Parameters fname A name for the current program. fname is a valid MPE file name that conforms to MPE file name rules. If fname is not specified, the program has no name. Therefore, the NAME command can be used to delete a program's name.
^ Syntax error at character 12 Statement needs = >REDO RETURN 20 INTGGER N,P,R E 20 INTEGER N,P,R Iumber RETURN 20 INTEGER Number,P,R RETURN >LIST 20 RETURN 20 INTEGER Number,P,R > RENUMBER Command The RENUMBER command renumbers one range of program lines. The range can be the whole program. The RENUMBER command is a command-only statement. That is, it can only be issued at the interpreter prompt, and cannot be placed in a program.
Examples >LIST 100 GOTO 200 120 RESTORE 190 190 GOTO 110 200 DATA ABC >RENUMBER >LIST 10 GOTO 40 20 RESTORE 30 30 GOTO 110 40 DATA ABC >RENUM 20/40 TO 100 BY 5 >LIST 10 GOTO 110 100 RESTORE 105 105 GOTO 110 110 DATA ABC >REN TO 500 >LIST 500 GOTO 530 510 RESTORE 520 520 GOTO 530 530 DATA ABC !(Line 110 does not exist) !(110 does not change) !(110 does not change, but now exists) !(110 becomes 530) SCRATCH Statement The SCRATCH statement can be used to reset variables to their default values, erase the
features listed below the heading in the following list. SCRATCH COM reinitializes the common area variables as well as resetting the features performed in a SCRATCH VARS. Likewise, SCRATCH PROG resets the SCRATCH PROG, SCRATCH COM and SCRATCH VARS features. Using SCRATCH ALL resets all the features indicated for each of the SCRATCH options and resets the interpreter back to its initial state. The following list summarizes the features reset with each option level: SCRATCH ALL.
* BREAK key enabled. * Response function return value set to 0. * CURKEY function return value set to 0. * DBASE is reset. * WORKFILE is reset. * Form filename reset. SCRATCH VARS. * Non-COMMON area variables reset according to INIT option specified. * Any Tracing is turned off. * ERRL return value set to 0. * ERRN return value set to 0. * All open files that have been opened with the HP Business BASIC/XL ASSIGN statement that are not in a common area are closed.
130 LET C=3 140 PRINT A+B+C 999 END >SECURE 110/130 >LIST 100 INTEGER A,B,C 110 * 120 * 130 * 140 PRINT A+B+C 999 END >MODIFY 120 Line 120 secured and cannot be modified. In the above example, lines 110 through 130 were secured. XREF Command XREF is an interpreter command that generates a cross reference of the entire current program, just the main program unit, or any procedure or function of the current program.
numeric and string variables, usage is also characterized by the location of the declaration of the variable in the program, PARAMETER, or COMMON. If neither of those is specified, the variable is local. Identifiers that are not variables are characterized by their usage in the program as SUBPROGRAM, FUNCTION, EXTERNAL, or LABEL. Type The data type of the identifier: SHORT REAL, REAL, SHORT INTEGER, INTEGER, SHORT DECIMAL, DECIMAL, or STRING.
260@ B2 SIMPLE SHORT INTEGER 260@ I1 220@ 2890 3210 1920* 2910* 3280* 1930 2920 3290 SIMPLE COMMON 1940 2800* 2930 2940 3670* 3680 2810 2950 3750 SHORT INTEGER 2820 2850* 2970 3190* 2880 3200 220@ 2220* 1270* 2240 1280 2760* SIMPLE COMMON 1630* 1640 2770 3160* SHORT INTEGER 1800* 1810 2080* 3680 3700 3720 2090 Z Examples >XREF >XREF TO Printer >XREF WITH LIST >XREF MAIN,Sub1,FNX TO Display >XREF SUB Sub2 WITH LIST !Default parameters !Listing to Printer !Cross reference will follow the sou
BASIC DATA A BASIC DATA file has fixed length 128-word records. In an ASCII or BASIC DATA file, a line that exceeds 500 characters is truncated and an asterisk is substituted for the 500th character. An error occurs when the line is accessed. Table 2-5 explains the program file management commands and statements and shows which of them are compilable. Table 2-5.
| | | | existing or new disk | | | | | file. | | | | | | --------------------------------------------------------------------------------------------| | | | | | RUN | No | Any | Executes current or | | | | | specified program, | | | | | beginning at first or | | | | | specified line.
| | | | --------------------------------------------------------------------------------------------| | | | | line_num | Ignored. | Current program lines from | | | | line_num to the end of the program | | | | are deleted. Default for line_num | | | | is one. Lines before line_num are | | | | not affected.
! FileA 10 PRINT "Program A" 20 CALL A_sub 30 PRINT "End of Program A" 40 PRINT "Program B" 50 CALL B_sub 60 PRINT "End of Program B" 70 STOP 130 SUB B_sub 140 PRINT "In subprogram B_sub" 150 SUBEND > Example 2 The following example shows the effect of a programmatic GET of an ASCII file. Because the GET specifies line 120, Program A is left intact, and Program B becomes part of A_sub.
> GET SUB Statement The GET SUB statement retrieves specified subunits from a BASIC SAVE file and adds them to the current program. Current program lines are not affected. If the current program executed the GET SUB statement, execution continues at the line following the GET SUB statement. The GET SUB statement retrieves subunits from BASIC SAVE files only. Use the MERGE statement to retrieve subunits from ASCII and BASIC DATA files.
The following program statement retrieves Subunit_1 through Subunit_4. Numbering of the first line of Subunit_1 begins at the highest line number in the current program + 1. The line numbers of subsequent lines are incremented by 10.
MERGE Statement The MERGE statement is identical to the LINK statement, except in the following ways: * A current line is replaced only if its line number belongs to a retrieved line. The retrieved line may have the same line number if it has been renumbered. * If a subunit header (a SUB or DEF statement) is inserted anywhere except immediately before another subunit header, it becomes a comment and a warning is issued.
If neither LIST nor BDATA is specified, the program is stored in the format of the existing file if the file already exists. If fname refers to a new file, and neither LIST nor BDATA is specified, the default is type BASIC SAVE. Parameters LIST Stores program in ASCII format. must be an ASCII file. If the file exists, it BDATA Stores program in BASIC DATA format. If the file exists, it must be a BASIC DATA file. fname This specifies a new or existing file. RESAVE overwrites an existing file.
Parameters fname The name of the disk file containing the program to be retrieved and executed. This program replaces the program that is in the interpreter when the RUN command is issued. The current program in the interpreter's workspace is executed if fname is not specified. If fname specifies a nonexistent file, an error occurs, and the current program is not overwritten. line_id The line number or line label in the main program at which to begin execution. The default is the first program line.
Consider the execution of the following program sequence with and without the INFO option: 1000 ! 1010 IF INFO$="DEBUG" THEN 1020 PRINT "Just before assignment to Sum" 1030 PRINT " Subtotal_1 = ";Subtotal_1 1040 PRINT " Subtotal_2 = ";Subtotal_2 1050 ENDIF 1060 ! 1070 Sum=Subtotal_1+Subtotal_2 1080 PRINT "The total is: ";Sum >RUN The total is: 1169.04 >RUN;INFO="DEBUG" Just before assignment to Sum Subtotal_1 = 475.53 Subtotal_2 = 693.51 The total is: 1169.
If neither LIST nor BASIC DATA is specified, the program is stored in the BASIC SAVE format. Parameters LIST Stores program in ASCII format. BDATA Stores program in BASIC DATA format. fname This must specify a new file. fname defaults to the file name of the current program as determined by the most recent GET or NAME command if this parameter is not specified.
When program execution is suspended, control returns to the terminal keyboard. From the keyboard, you can do any of the following: * Variable values can be displayed (type the variable name and press RETURN ). * Commands can be executed. * Variable values can be changed (with the LET command). * Program lines can be modified (with the MODIFY command). * Program lines can be inserted. * Program lines can be deleted (with the DELETE command or as explained in "Creating and Modifying a Program").
| | | | | STEP | Command | Executes next line of suspended program and | | | | suspends program at line following it. | | | | | --------------------------------------------------------------------------------------------| | | | | Trace Statements | Either | See Table 2-8. | | | | | --------------------------------------------------------------------------------------------| | | | | Untrace Statements | Either | See Table 2-9.
Syntax CALLS Example If the program is not running: >CALLS MAIN Not executing. If the program has paused at line 10: >CALLS MAIN @ 10 Suppose that the following are true: Line 10 of the main program calls subunit FNBeep$. Line 40 of FNBeep$ calls subunit FNBeep. Line 50 of FNBeep calls subunit B. The program pauses at line 100 in subunit B. Then: >CALLS SUB B @ 100 FNBeep @ 50 FNBeep$ @ 40 MAIN @ 10 CONTINUE Command The CONTINUE command restarts a suspended program.
An error occurs if the CONTINUE command is executed and there is no current program in the work space. Examples The following shows examples of the CONTINUE command: CONTINUE CONT CONTINUE 100 CONT Label5 CONT * !Continues the program at line 100 !Continues the program at the line number in Label5 !Continues the program at the last line executed FILES Command The FILES command prints the file numbers of the files that have been declared in the currently executing subunit.
* Does a CONTINUE. The HOP command is a command-only statement. That is, it can only be issued at the interpreter prompt and cannot be placed in a program. Syntax HOP The HOP command is useful for the following: * Hopping through a GOSUB or CALL. * Hopping through a loop (when executed on the last line of the loop). The breakpoint that the HOP statement sets is reset by the next HOP statement (only one HOP breakpoint per program). Example The following shows an example of the HOP command.
The STEP command is a command-only statement. That is, it can only be issued at the interpreter prompt and cannot be placed in a program. Pressing CONTROL E also issues the STEP command. Syntax STEP Examples The following shows an example of the STEP command. The program pauses at line 110, and the STEP command is issued during that pause.
For an array element: TRACE IN LINE line_num; array_name (Subscript_of_element ) = new_value TRACE IN LINE line_num; ELEMENT n IN ARRAY var_name = new_value Trace statements print their output on the system printer. (The system printer is specified by the SEND SYSTEM OUTPUT TO statement. The default is the standard list device, that is, the terminal if HP Business BASIC/XL is running interactively.) Every trace and untrace statement can also be a command.
Table 2-9.
TRACE EXEC and UNTRACE EXEC The TRACE EXEC statement traces lines, beginning when the first specified line executes and ending when the last specified line executes. If lines are not specified, TRACE EXEC applies to the entire program. If the first specified line does not exist or is not executed, TRACE EXEC does not trace lines. If the last specified line does not exist or is not executed, the TRACE EXEC statement does not stop tracing lines (unless an UNTRACE EXEC or TRACE OFF statement executes).
UNTRACE {EXEC }{VAR } Parameters line_id1 Variable tracing begins when this line executes. If this line does not execute, variable tracing never begins. The default is the first program line. line_id2 Variable tracing ends when this line executes. If this line is not specified or does not execute, variable tracing does not end until an UNTRACE EXEC VARS or an TRACE OFF statement executes. TRACE LINES and UNTRACE LINES The TRACE LINES statement traces specified lines.
Parameters line_range_ list1 line_range_ list2 Lines to be traced with pause. program lines. The default is all Lines for which TRACE PAUSE is to be canceled (can be a subset of line_range_list1 ). The default is all program lines. TRACE VARS and UNTRACE VARS The TRACE VARS statement traces specified variables. The UNTRACE VARS statement cancels TRACE VARS for specified variables (not necessarily for every variable that TRACE VARS traces). Syntax {VARS} TRACE {VAR } [var_name1 [, var_name2 ]...
Parameters sub_id1 sub_id1 specifies a subunit that variables will be traced in. sub_id1 is specified by [SUB] sub_id or MAIN. sub_id3 Each sub_id3 specifies an additional subunit that variables will be traced in. Each sub_id3 is specified by [SUB] sub_id or MAIN. sub_id2 sub_id2 specifies a subunit that variables will no longer be traced in. sub_id is specified by [SUB] sub_id or MAIN. sub_id4 Each sub_id4 specifies an addition subunit that variables will no longer be traced in.
unit that contains it. The OPTION NOTRACE statement disables the trace statements in the program unit that contains it. If a program unit contains neither an OPTION TRACE nor an OPTION NOTRACE statement, the global option applies (its default is GLOBAL OPTION TRACE). Syntax OPTION TRACE {NO TRACE} OPTION {NOTRACE } The OPTION TRACE and OPTION NOTRACE statements can appear anywhere in a program unit.
* * * * * * The terminal fully supports the terminal-specific features of HP Business BASIC/XL. The interpreter is running in a session, rather than a batch job. There is at least one program line in the current program. The program is not running or paused. The program has no VERIFY errors. The destination for OUTPUT and SYSTEM OUTPUT is the display. Syntax ANALYST [screen_argument ] Parameters screen_argument An argument that specifies which screen to enter.
The user interface capabilities used in the Program Analyst are available in HP Business BASIC/XL applications through the following statements and functions: ON KEY ON HALT CURSOR RESPONSE ACCEPT TINPUT NOTE The features of the Program Analyst can change from one release to the next. Whenever you receive a new version of HP Business BASIC/XL, check the NEWS category in the HELP facility for information on changes and enhancements.
| | current subunit. | | | | --------------------------------------------------------------------------------------------| | | | Subunit Name | Entering a subunit name moves to that subunit. If the name entered | | | matches a subunit in the program, that subunit is the current subunit | | | and its first eight lines are displayed.
Software Metrics This section provides statistics about the program. Many techniques exist for measuring the size and complexity of software and the amount of structure it contains. The Program Analyst can measure these features quickly and accurately. The significance of the numbers is left up to the programmer. The fact that the numbers are generated should not be considered an endorsement of a particular technique, nor is it the intent to pass judgement on the user's code.
the conversion only once. If the Program Analyst finds a control variable that is a floating-point type, or a default REAL or DECIMAL type and the Program Analyst can determine that the starting value, limit, and step (if present) are all integers, the line number of the FOR loop is reported. A FOR loop that meets those criteria is very inefficient because the control variable has to be converted. In addition, the FOR loop can produce incorrect results.
overhead associated with them becomes noticeable. The Replace GOSUBs screen can, with certain restrictions, be used to replace a GOSUB with the body of the referenced subroutine. This is possible when there are enough available line numbers after the GOSUB to insert the entire subroutine before the next line, and the subroutine does not contain and GOTO statements or any lines that are targets of branches. The Replace GOSUBs screen prompts you for a line range to use to search for eligible GOSUBs.
item and generates a SKIP. If adjacent items can be skipped, the Program Analyst creates only one SKIP clause to cover those items. The items that can be skipped are highlighted. If skippable items are found, pressing RETURN will cause the Program Analyst to create an ASCII file containing the following statements: * * The original PACKFMT line with the actual statement commented out with a !. The new PACKFMT statement with a line number one greater than the original.
NOTE The Program Analyst allows you to extract a subunit even if there are broken branches. Manual editing may be required before the new program can run. Factors Affecting Extraction. The following factors that can affect extraction cannot be fully analyzed: * * * * * * DATA, READ, and RESTORE statements. Report Writer usage. SORT USING statements. THREAD statements. RETURN statements. ON ERROR, ON KEY, ON HALT, etc.
numbers. 4. When you enter a line range, the Program Analyst displays information about branches, structured statement, variables, and detectable problem conditions. Try different line ranges until you find one that will not cause many broken branches. 5. Press the softkey labeled Extract. Use any legal HP Business BASIC/XL identifier. The Program Analyst creates the two files used to produce the altered program.
HELP Command The HELP command displays information about one or more HP Business BASIC/XL commands, statements, and errors. Because a HELP command can end in an unquoted string literal, it cannot be followed by a comment. The HELP command is a command-only statement. Syntax [unquoted_str_lit ] ] HELP [str_lit Parameters unquoted_str_lit String of the form topic,subtopic where topic and subtopic are unquoted string literals (for example, AUTO,SYNTAX). Characters beyond the fortieth are ignored.
Type N over the last Y and press RETURN. To exit the HELP subsystem, type one of the following in uppercase, lowercase, or a combination of uppercase and lowercase: EXIT EXI EX E Accessing the Operating System The operating system can be accessed from HP Business BASIC/XL with the SYSTEM, SYSTEMRUN, or EXIT commands as follows: SYSTEM Executes an operating system command, a UDC, a program, or a command file from HP Business BASIC/XL (and returns to HP Business BASIC/XL).
Example EXIT :: The Calculator The HP Business BASIC/XL interpreter can be used as a calculator. If you type in a numeric expression without a line number, HP Business BASIC/XL will return the value of that expression. Table 2-12 summarizes the what happens with each response to the interpreter prompt. Note that at the end of each line, you can type either RETURN or CONTROL E. Table 2-12.
36 >10 PRINT RETURN >10 >Index1*Index2 RETURN 36 >Index1=12 RETURN 12 >Index2=Index1 RETURN 12 >10 PRNIT RETURN Error 2-: 60 (program line) (line number with nothing else deletes line) (numeric expression) (assignment) (assignment) (syntax error)
Chapter 3 Language Elements Introduction This chapter describes elements of the HP Business BASIC/XL language. It covers executable input, statements, variables, operators, and subunits. Executable Input Units An executable input unit can be input and executed without being part of a larger structure. The following are the three executable input units in HP Business BASIC/XL: * * * Expressions. Commands. Programs. Table 3-1 compares them. Table 3-1.
* * * * * * Gives the syntax of the general statement and briefly explains each statement element. Explains the different types of statements. Provides further information on the statement elements keyword and identifier. Lists the places in a program where spaces are required or are illegal. Compares remarks and comments. Explains how statements form a program.
comment Any character string, including the null string. A comment cannot follow a HELP command or an IMAGE or DATA statement. Statement Types The HP Business BASIC/XL statement types and their relations are shown in Figure 3-1. Figure 3-1 also lists the characteristics of each statement type. Figure 3-1.
The following are command-only statements: ANALYST CONTINUE HOP NAME AUTO COPY INFO REDO CALLS CWARNINGS LIST RENUMBER CHANGE EXIT(or ::) LIST SUBS RUN COMPGO FILES MODIFY STEP COMPILE FIND MOVE VERIFY COMPLINK HELP XREF A command-only statement cannot be a program line. Every other Business BASIC\XL statement can be a command or a program line. There are also some statements that cannot be a command. That is, they can only appear in program lines.
Examples 10 20 30 LET B$="Chocolate" PRINT X ON I GOTO 100,200,300 !LET is a keyword !PRINT is a keyword !ON and GOTO are keywords Identifiers An identifier is a character string that has the following characteristics: * * * Begins with a letter. Contains any combination of letters, digits, and underscores (_). Has 63 or fewer characters. HP Business BASIC/XL uses identifiers for several purposes. shows those uses. Table 3-3.
In general, identifiers should not have the same name and spelling as keywords. This can be very confusing, especially when attempting to debug a program. Regardless of how an identifier is entered, HP Business BASIC/XL prints it with the first character upshifted and the others downshifted. For example, "NAMes" and "NAMES" become "Names", and both refer to the same entity. Examples Table 3-4.
Spaces One of the following must separate a keyword and an identifier: * * * * Space. Comma. Parenthesis. Operator. With few exceptions, spaces can appear anywhere in a program. Table 3-6 lists the places where spaces cannot appear and gives examples. Table 3-6.
Table 3-7.
300 400 500 REM This is a remark. !This comment follows an empty statement. PRINT "Hello" !This comment is part of an executable program line. HP Business BASIC/XL lists a remark with one blank between the keyword REM and the text of the remark, as in line 300 above. HP Business BASIC/XL lists a comment with one space before the exclamation point, as in line 400 above. A comment cannot follow a HELP command. Program Structure A program is a sequence of program lines.
* Whether program main is the outer block for a multiprogram application. The OPTION and GLOBAL OPTION statements are explained in chapter 4. Variable Declaration A variable can be declared as local to one program unit or common to two or more program units. A local variable can be accessed only by the program unit in which it is declared, whereas a common variable can be accessed by every program unit that declares it.
| DEC | | | | | --------------------------------------------------------------------------------------------- Variable declaration statements can appear anywhere in a program. In the interpreter, before the main procedure or function is executed, HP Business BASIC/XL allocates space for both explicitly and implicitly declared variables. A variable cannot be explicitly declared more than once in a program unit.
100 110 120 130 140 150 160 170 180 190 999 INTEGER B INTEGER B(5) DIM B$[15] DIM B$(3)[15] B: STOP PRINT B PRINT B(1) PRINT B$ PRINT B$(3) GOTO B END !Declares scalar numeric variable B !Declares numeric array variable B !Declares scalar string variable B$ !Declares string array variable B$ !This line has a label, line label B !B refers to scalar numeric variable !B refers to numeric array variable !B$ refers to scalar string variable !B$ refers to string array variable !B refers to line label Numeric V
Array Variables. An array is an ordered collection of variables of the same type. If the array elements are string variables, they have the same maximum length. An array element is legal wherever a scalar variable is legal. An array variable is declared with a DIM, COM, or numeric declaration statement. The syntax for each of these is in chapter 4. Implicit Declaration.
Table 3-13. Variable Initialization --------------------------------------------------------------------------------------------| | | | | | Local Variable | Common Variable | | | | | --------------------------------------------------------------------------------------------| | | | | Initialized to | Numeric: zero. | Numeric:zero. | | | | | | | String: null string. | String: null string.
| Substring * | str_name [num_expr1,num_expr2 ] | A$[1,5] | | | | | | | str_name [num_expr1;num_expr2 ] | A$[5;3] | | | | | | | str_name [num_expr1 ] | S$[5] | | | | | --------------------------------------------------------------------------------------------- Table 3-14 Note * If the substring reference belongs to a string array variable, str_name must be an array element reference.
Numeric Literals Numeric literals are real numbers or integers. Syntax For literal integers (lit_integer ): digit [digit ] For literal real numbers: lit_integer [.[lit_integer ]][E[+,-]lit_integer ] .lit_integer [E[+,-]lit_integer ] Parameters digit A single digit 0..9. lit_integer A number consisting of any combination of the digits 0..9. Examples Table 3-16.
{nonquote } "{"" }..." Special character string literal: 'integer Parameters nonquote Nonquoted string literal. quote("). integer Special character string literal. Must be in the range [0,255]. Represents an ASCII character. Any character except a double Examples The quoted string literals in the left column below are printed as shown in the right column. The fourth example is the null string. Table 3-17.
| | | | --------------------------------------------------------------------------------------------| | | | | '7 | BEL | entry rings terminal's bell | | | | | --------------------------------------------------------------------------------------------| | | | | '13 | CR | carriage return | | | | | --------------------------------------------------------------------------------------------| | | | | '48 | 0 | zero | | | | | ---------------------------------------------------------------------------------------
140 150 999 C$="Elephants" !Current length of C$ is 9, implicit definition A$="Caterpillar" !Now the current length of A$ is 11 END Substrings Substring Operations. Substring operations are classified into two types; references and assignments. Substring references are specifications of a string of characters that are to be extracted from a string variable. The value of the string with the substring reference is never changed.
dex Start in the string, A$. If LEN(A$) = 0 then the value is a null string. Otherwise, it is that string beginning at character index start of A$ and ending at character index LEN(A$). (LEN is a function that returns the length of a string. It is described in chapter 5.) If start = (LEN(A$)+1) then the value is the null string. Start Index and End Index or Length.
20 30 40 50 60 70 B$=A$[1] B$=A$[2,3] B$=A$[2;3] B$=A$[4,7] B$=A$[6;2] B$=A$[7,10] !Assigns "basic" to B$ - characters 1 to LEN(B$) !Assigns "as" to B$ - characters 2,3 !Assigns "asi" to B$ - characters 2,3,4 !Assigns "ic " to B$ - characters 4,5 + 2 spaces !Assigns " " to B$ - a null string + 2 spaces !Range error because 7 > LEN(A$)+1 Substring Assignment. A substring assignment begins at a user-specified index corresponding to a character position in a string variable and has a length.
Syntax str_var [start,end ] str_var [start;length ] Parameters str_var A valid string variable name or string variable array element reference. start A numeric literal or expression that evaluates to a value between 1 and LEN(str_var )+1, inclusive. end A numeric literal or expression that evaluates to a value between start -1 and 32767, inclusive. length A numeric literal or expression that evaluates to a value between 0- and 32767, inclusive.
Syntax {operand {func_name [operand ] operator [(parameter } [,parameter ]...)]} Parameters operand First operand is required if operator is binary and not allowed if operator is unary. Each operand is one of the following: * * * A literal. A variable name. An expression. Operand type restriction depends on the operator. operator Determines how the value(s) of the operands(s) produce(s) the result. func_name Function name.
| | | | --------------------------------------------------------------------------------------------| | | | | Arithmetic | Numeric | Numeric | | | | | --------------------------------------------------------------------------------------------| | | | | Relational | Numeric or string | Boolean* | | | | | --------------------------------------------------------------------------------------------| | | | | Boolean | Boolean* | Boolean* | | | | | -----------------------------------------------------------------
| MOD | Binary | Modulus | 37 MOD 4=1 | | | | | | --------------------------------------------------------------------------------------------| | | | | | ^ | Binary | Exponentiation | 2^3=8 | | | | | | --------------------------------------------------------------------------------------------| | | | | | ** | Binary | Exponentiation | 2**3=8 | | | | | | --------------------------------------------------------------------------------------------| | | | | | MIN | Binary | Minimum | 5 MIN 4=4 | | | | | | -----
= -13 - (-14) = -13 + 14 = 1 -13 MOD -2 = = = = = 3 MOD 5 = = = = -13 -13 -13 -13 -1 3 3 3 3 - (-2*INT(-13/-2)) - (-2*6) - (-12) +12 (5*INT(3/5)) (5*0) 0 Relational Operators A relational operator has either two numeric operands, two ASCII string operands, or the result of another relational expression and a Boolean result. Every relational operator is binary. Table 3-21 gives the name and an example of each relational operator. Table 3-21.
The null string ("") is less than every string except itself, to which it is equal. The following explanation does not apply to the null string. HP Business BASIC/XL compares the strings S1$ and S2$ as follows (S1$[c;1] and S2$[c;1] are corresponding characters). 1. c =1 2. If CHR$(S1$[c;1])CHR$(S2$[c;1]), then S1$ is greater than S2$. Stop. 4. CHR$(S1$[c;1])=CHR$(S2$[c;1]).
numeric constant of short integer type equal to zero. Depending on the operator, HP Business BASIC/XL evaluates a Boolean expression either completely or partially. Logical evaluation HP Business BASIC/XL always evaluates both operands. Partial evaluation HP Business BASIC/XL always evaluates the first operand, but evaluates the second operand only if its value could change the value of the expression.
Examples These expressions are TRUE: NOT 0 NOT (X-X) NOT (5 = 3) NOT ("HP" < "Competitors) These expressions are FALSE: NOT 1 NOT 3600 NOT (5 > 3) NOT("HP" # "Hewlett Packard") Table 3-24 is the truth table for the LAND and AND operators. The AND operator evaluates the first operand, and if it is FALSE the result is FALSE and the second operand is not evaluated. The LAND operator evaluates both operands regardless of the value of the first one. Table 3-24.
99 END 99 END If array A has Maxindex elements, and Index is greater than Maxindex, then the statement 100 IF (Index <= Maxindex) AND (A(Index) =5) THEN GOTO 500 does not evaluate A(Index), and an error does not occur. The statement 200 IF (Index <= Maxindex) LAND (A(Index) = 5) THEN GOTO 600 does evaluate A(Index), and an error occurs (subscript out of range). Table 3-25 is the truth table for the LOR and OR operators.
10 I=1 20 PRINT (I LOR FNI(I)); I 99 END 10 I=1 20 PRINT (I OR FNI(I)); I 99 END If array A has Maxindex elements, and Index is greater than Maxindex, then the statement 100 IF (Index &> Maxindex) OR (A(Index) =5) THEN GOTO 500 does not evaluate A(Index), and an error does not occur. The statement 200 IF (Index &> Maxindex) LOR (A(Index) =5) THEN GOTO 600 does evaluate A(Index), and an error occurs (subscript out of range). Table 3-26 is the truth table for the XOR operator.
Syntax str_expr1 + str_expr2 The resulting string is the value of str_expr1 with the value of str_expr2 appended to it. The length of the resulting string is the sum of the two lengths.
(4*5), where the expressions in parentheses are evaluated first. Operator Hierarchy When an expression contains several operators, operator precedence is used to determine the evaluation order. The operator hierarchy establishes the precedence relationship among the HP Business BASIC/XL operators. Expressions with operators of equal precedence are evaluated from left to right. Table 3-27 shows the HP Business BASIC/XL operator hierarchy. An operator takes precedence over those below it in the table.
Examples 4+7*2 = 4+(7*2) = 4+14 = 18 (4+7)*2 = 11*2 = 22 3-2+1 = (3-2)+1 = 1+1 = 2 3-(2+1) = 3-3 = 0 NOT A**3 MOD 12 + 75 = B AND C OR D = (((((NOT(A**3)) MOD 12) + 75) = B) AND C) OR D Result Type If an arithmetic operation has two operands of the same type, the operation is performed using that type. The intermediate result is of that type, and an error occurs if the intermediate result is out of the range of the final result type.
A subunit can contain any program lines that are valid in a main program, including variable declaration statements. Except for common variables, the variables that are defined in a subunit, including formal parameters, are local to that subunit. All variable names in the subunit represent variables that are distinct from variables with the same names in other program units.
Syntax SUB_stmt [stmt ]...SUBEND_stmt Parameters SUB_stmt SUBPROGRAM or SUB statement. Not executable. that the lines that follow are a subprogram. stmt Can be a SUBEXIT statement that returns control to the calling program unit before the SUBEND statement is executed, or can be any executable statement. These statements constitute the body of the subprogram. SUBEND_stmt SUBEND statement. Indicates Indicates the end of the subprogram.
A function is edited using the procedures described in chapter 2. A program unit calls a multi-line function the same way it calls a predefined or single-line function: by its name, followed by an actual parameter list if it has one. The list of actual parameters is enclosed in parentheses, and the individual parameters are separated by commas.
| change actual | parameter. | | | parameter | | | | | | | --------------------------------------------------------------------------------------------| | | | | Variables Passed | File designators*. | All not mentioned to the left. | | This Way | | | | | Arrays. | Scalar variables enclosed in | | | | parentheses. | | | Array elements. | | | | | String literals. | | | Scalar numeric variables. | | | | | Numeric literals. | | | Unsubscripted scalar string | | | | variables.
BASIC/XL enters a subprogram, it initializes the environment. When control returns to the calling program unit, HP Business BASIC/XL reinstates the environment of the calling program unit. Table 3-30 lists the characteristics that define the operating environment of a program unit and explains how each characteristic is initialized. Table 3-30.
99 100 110 199 200 210 299 . . . END SUB Payroll COM X(*,*), Y, INTEGER Z,Q() . . . SUBEND DEF FNAccounts (X,Y,Z) COM I() . . . FNEND The following table shows the correspondence between common variable names in the above program. Table 3-31.
* function). No undeclared variables under OPTION DECLARE. Syntax [ALL ] VERIFY [ [{,} ] ] [progunit [{;} progunit ]...] Parameters ALL Specifies all program units in the program, including the main program unit. ALL is the default. progunit One of the following: [SUB]subunit_name. [SUB]function_name. [SUB]MAIN. A program unit cannot execute unless it is well-formed.
An external routine is called with the CALL statement. An external function can be called with either the CALL statement or the FNCALL function; the method depends on the function name and whether its result can be discarded. Table 3-32 tells how to call each type of external subunit. Table 3-32.
External Parameter Type Correspondence When a program calls an external routine, the types of the actual parameters must correspond to the types of the formal parameters. When a program declares an external function that is not declared as INTRINSIC, the return type in the EXTERNAL statement must correspond to the return type in the function's original definition. Table 3-33 shows the correspondence between parameter types in HP Business BASIC/XL, HP Pascal/XL, and HP C/XL. Table 3-33.
Parameter type correspondence for numeric arrays is the same as that for scalar numeric parameters. The corresponding formal parameter for string array parameters in the procedure or function header for the procedure or function must be a string array that conforms to the type expected by An HP Business BASIC/XL procedure or function. All arrays are passed by reference.
Chapter 4 Statements Introduction This chapter contains descriptions of each statement that can be used to form programs in HP Business BASIC/XL. The statements are arranged in alphabetical order. Each description contains the complete syntax of the statement, examples, and other necessary information. ACCEPT The ACCEPT statement obtains a string of characters from the designated input device without echoing those characters to the display as they are entered.
time is not measured. chars_num_expr A numeric expression that evaluates to the maximum number of characters that can be input. Typing this number of characters causes the generation of a carriage return and assignment of the value to the specified str_var. Then the program begins execution of the next statement in the program. separator One of the following: {WITH} {, } {; } Each option_clause can occur only once in an ACCEPT statement.
past the beginning of file marker is negative. Examples The following program shows the use of the ADVANCE statement. Line 15 positions the datum pointer at datum 1, that is, the first datum in the file. Line 20 advances that pointer 6 datums, to datum 7. Lines 30-40 read and print that record. Datum 7 is the first field in record 4. Line 50 positions the back at datum 4. (The READ in line 30 advanced the pointer to datum 8). Lines 60-70 read and print that datum.
A nonzero value represents the file error code returned by the file subsystem of the MPE XL operating system. The error number can be translated to an MPE XL file system error message by looking up the table of file system error codes in the MPE XL Intrinsics Reference Manual under the FCHECK intrinsic. ioaccess useraccess If a file is opened by a program, the ioaccess specification determines how the program can access the file.
SHAREREAD str_expr Other programs can read the file, but cannot write to it. A string expression that evaluates to a string with a length of six characters. The string serves as a mask used to scramble and unscramble file data, excluding format words, EOR marks, and EOF marks. If a mask is specified the first time a file is assigned, the same mask must be specified each time the file is assigned; otherwise, the data cannot be properly unscrambled.
An error occurs if a report is active when BEGIN REPORT executes. This statement searches for a REPORT HEADER statement starting with the line indicated. Only comments can occur between the given line and the REPORT HEADER statement. Once the REPORT HEADER is found, the Report Writer scans the report description. The report scan uses two passes. The first pass determines what sections are valid, and then the second pass evaluates necessary expressions.
str_expr A string of ASCII characters of up to 512 characters in length to be written as part of the BEGIN TRANSACTION log record. status_array A 10-element short integer array to which TurboIMAGE returns any error codes or other status information. If an HP Business BASIC/XL database statement specifies the STATUS option, an error does not abort the program. Following execution of the database statement the program can check status_array and handle the error.
the statement. If the break condition is true, all summary levels from the BREAK level and up are triggered. This causes TRAILER and HEADER sections to be printed. The BREAK WHEN statement can occur anywhere in the report description. There can only be one BREAK statement per summary level, either BREAK IF or BREAK WHEN. There is no BREAK statement for the report level.
expression. The statements differ in what changes can be specified for the control expression. String Control Variables. When the report is activated via BEGIN REPORT, the value of the control expression is recorded. With each DETAIL LINE, the current value of the control expression is compared to the recorded value in OLDCV$. If the two values are not the same, the break level is triggered.
negative. If SALES has an initial value of 480, the break limit is set to 450 (not 430). If SALES gets larger, no break ever occurs. Only when SALES becomes 450 or less does the break occur. For example, if SALES drops to 220, a break occurs and the new limit is set to 200. It is important to remember that this is the multiple of a BY clause. Control Expression Storage Requirements The control expression for BREAK WHEN statements is kept by the OLDCV function.
30 99 100 110 120 130 140 150 PRINT "Done" END SUBPROGRAM Subrtn(Number,String$) IF Number<1 THEN SUBEXIT FOR I=1 TO Number PRINT RPT$(String$,Number) NEXT I SUBEND !Returns control to line 30 If a program has more than one subunit with the same name, the CALL statement calls the first one that it finds. The following is the search order: 1. 2. 3. 4.
Reference Manual under the BUILD command's file code mnemonics. Valid values include "BSVXL", "BDTXL", "JL", or "1200". If the TYPE option is not specified, then TYPE information is not used as a selection criteria for determining which file's directory information is displayed. num_var A numeric variable to which the total number of files found is returned.
30 . !Control transfers to line 200 . . 200 Error handler: !Start of error handling routine . . . CLEAR FORM The CLEAR FORM statement sets the contents of all fields on the currently displayed form to blanks or another default value. This statement is used with JOINFORM as well as VPLUS, but the DEFAULT clause is ignored when using JOINFORM. If there is no active form, executing a CLEAR form causes a run-time error.
screen by placing the cursor at the first line of the form, and clearing display memory from that position to the end. The area of display memory above the form is not affected. REMAIN Specifies that the form should be left on the screen. It is unprotected after it is closed. Examples The following statements show the use of the CLOSE FORM statement.
If a type is not specified, implicit declaration rules apply. After type, each num_com_item is of that type until another type or a non_num_com_item appears. num_com_item Numeric variable declaration (for a scalar or array variable). If the COM statement is in a subunit, num_com_item must represent a numeric array with the abbreviation identifier ([*[,*]...]) with one asterisk per dimension or without asterisks. Not using asterisks specifies any number of dimensions.
A,B C,D A$ P,Q X,Y,Z #2 Integer Real String with maximum length of 7 characters Default numeric type Decimal File designator 100 COM N,S$,N_array(1:5),S_array$(1:2,1:4)[6] Variable(s) N S$ N_array S_array$ Type Default numeric type String with default maximum length (18) Array of default numeric type Array of strings with maximum length of 6 Example 2: Concatenation of Common Variable Lists If two COM statements in the same program unit have the same area name, their variable lists are concatenated.
460 COM /Area4/ Q$, DECIMAL A(*,*), B() The conflict in type and /or dimension for each variable is: Main Program Unit SHORT REAL A INTEGER C #15 DECIMAL E F$(0:4,0:4,0:4)[12] Program Subunit REAL Num SHORT INTEGER D Q$ DECIMAL A(*,*) B() Within a program unit, the following variables cannot have the same name: * * A common scalar variable and a local scalar variable. A common array variable and a local array variable.
Parameters str_expr Its value must be an executable statement with 500 or fewer characters. If it is not, an error occurs. The executable statement cannot be any of the following: * A command-only statement (for example, LIST). * A program-only statement (for example, INPUT). * The COMMAND statement. * Any statement that defines a construct (for example: WHILE, END WHILE, or REPEAT). The statement cannot be a declaration statement, because declaration statements are not executable.
assigned to num_var is the value converted immediately prior to the syntax error. An HP Business BASIC/XL error number is not generated for this condition. The string is deblanked before it is converted. num_var A numeric variable. line_ref A line label or line number that is in the same procedure as the CONVERT statement. Specification of a line_ref supersedes the error handling action specified in an ON ERROR statement.
Parameters fname1 fname fname2 of the file to be copied. fname of the copy of the file that is to be created. The name must not be the name of a file that already exists, otherwise a duplicate file name error occurs. The COPYFILE statement creates a file with this name and gives it the attributes of the original file.
RECSIZE FILESIZE STATUS These clauses can be in any order. num_expr1 Record length. If positive, each record has r words. If r is negative, each record has r bytes. If not specified, and file is type BASIC DATA, each record has 256 bytes (128 words). num_expr2 File size; maximum number of records in file. Cannot change after the file is created. The default is established by the operating system.
* u or U: Underline num_chars A numeric expression, variable, or constant that specifies the length of the display enhancement. IFLD This function moves the cursor to the field output field in a JOINFORM. The current input field number is set to field. OFLD This function moves the cursor to the field output field in a JOINFORM. The current output field number is set to field. CFLD This function moves the cursor to the field input field in a JOINFORM.
* num_chars evaluates to a positive value; num_chars characters are set to the specified enhancement one character at a time. Each of the individual characters is prefixed with the appropriate escape sequence required for the enhancement. The escape sequence prefixing the character following the last character to be enhanced contains the enhancement terminator. * num_chars evaluates to zero; the escape characters that turn on the specified enhancement prefix the characters at the current cursor position.
Syntax DATA datum [, datum ]... Parameters datum Numeric or string literal. A string literal can be enclosed in quotes, but doesn't have to be. If it is enclosed in quotes it is called a quoted string literal; if not, it is called an unquoted string literal. Leading and trailing spaces are not part of an unquoted string literal, but embedded spaces are. A DATA statement is not executable. When the program reaches a DATA statement, it proceeds to the next line following it.
name. dbname must be the variable that was passed to a successful DBOPEN. Examples 100 DBASE IS Db_name$ When dbname $ is a null string, the DBASE IS specification is reset to nothing. It is not an error to specify a null string. An error occurs if a string with all blanks is specified. DBCLOSE The DBCLOSE statement terminates database access, makes a data set temporarily or permanently inaccessible, or rewinds a data set.
Syntax DBDELETE dbname $, DATASET[=]dataset [, Status[=]status_array(*) ] Parameters dbname $ A string variable, whose value is a TurboIMAGE database name. dbname must be the variable that was passed to a successful DBOPEN. dataset A string expression with a maximum length of 16 characters. Its value is the name of a data set. The name must be left-justified and if shorter than 16 characters must be terminated by a semicolon or blank.
Syntax DBEXPLAIN STATUS[=]status_array (*) Parameters status_array A 10-element short integer array to which TurboIMAGE returns an error code. If an HP Business BASIC/XL database statement specifies the STATUS option, an error does not abort the program. Following execution of the database statement the program can check status_array and handle the error. The values returned by TurboIMAGE to this array are detailed in the description of the status parameter of the equivalent TurboIMAGE library procedure.
returns an error code. If an HP Business BASIC/XL database statement specifies the STATUS option, an error does not abort the program. Following execution of the database statement the program can check status_array and handle the error. The values returned by TurboIMAGE to this array are detailed in the description of the status parameter of the equivalent TurboIMAGE library procedure.
corresponding to the desired dataset number.
and handle the error. The values returned by TurboIMAGE to this array are detailed in the description of the status parameter of the equivalent TurboIMAGE library procedure. Examples The following examples show the use of the DBGET statement.
mode A numeric expression that evaluates to a short integer indicating the type of information desired. Available modes are detailed in the explanation of the DBINFO library procedure in the TurboIMAGE/XL Database Management System. str_var The name of the string to which the requested information is returned. The required length is dependent on the type of information to be returned as specified by the MODE parameter.
corresponding to the desired dataset number. only if lock_mode is three or four. Required str_expr A string expression that is required only if lock_mode is five or six. Its value is a predicate lock string that describes the locking condition. The PREDICATE statement is used to set up the predicate lock string. The format of the PREDICATE lock descriptors is presented in the description of the DBLOCK library procedure in the TurboIMAGE/XL Database Management System.
class number and access mode for subsequent database operations. first two characters in the dbname variable must be blanks. The Syntax DBOPEN dbname $[, PASSWORD[=]str_expr ] [, MODE[=]open_mode ] [, STATUS[=]status_array (*)] Parameters dbname $ A string variable whose value is a TurboIMAGE database name. The first two characters in the string must be blanks followed immediately by the actual database name. This variable must be used in all other statements that call this database.
| 8 | Read | Read | 6, 8 | | | | | | --------------------------------------------------------------------------------------------- Examples The following statements show the use of the DBOPEN statement.
in the corresponding position in the ordered set of values contained in str_var. Any search or sort items defined for the entry must be included in item_list. Fields of unreferenced items are filled with binary zeros. If the item_list is a string variable, the list of data item names must be left justified in the string. Individual data item names are separated by commas and the last is followed by a semicolon or blank. Embedded blanks are not allowed and no name can appear more than once.
returns an error code. If an HP Business BASIC/XL database statement specifies the STATUS option, an error does not abort the program. Following execution of the database statement the program can check status_array and handle the error. The values returned by TurboIMAGE to this array are detailed in the description of the status parameter of the equivalent TurboIMAGE library procedure. Redundant DBUNLOCK statements are ignored. Examples The following example shows the use of the DBUNLOCK statement.
in the corresponding position in the ordered set of values contained in str_var. Any search or sort items defined for the entry must be included in item_list. Fields of unreferenced items are filled with binary zeros. If the item_list is a string variable, the list of data item names must be left justified in the string. Individual data item names are separated by commas and the last is followed by a semicolon or blank. Embedded blanks are not allowed and names cannot appear more than once.
The following are examples of declaring variables of types DECIMAL and SHORT DECIMAL. 100 120 130 140 SHORT DECIMAL Price SHORT DECIMAL Cost1,Cost2(7),Cost3 DECIMAL Length DECIMAL D1,D2,D3(6,8),D4(3,5) DEF FN The DEF FN statement defines the beginning of a multi-line function. is not executable. It Syntax Numeric function: DEF [type ] FNidentifier [(f_param [,f_param ]...)] String function: DEF FNidentifier $ [(f_param [,f_param ]...)] Parameters type Numeric type (for example, INTEGER, SHORT REAL).
messages. The DEFAULT OFF statement is used following a DEFAULT ON statement to reinstate those error messages. The DEFAULT OFF value is also set when you initially enter to the interpreter. Syntax DEFAULT OFF If the DEFAULT OFF value is set, program execution is suspended when you encounter one of these errors. DEFAULT ON Values that are out of range cause the arithmetic errors in the following table.
Examples The following examples show the result of using the DEFAULT ON statement. In the first example, the program does not have DEFAULT ON and a short integer precision overflow results. In the second example, there is a DEFAULT ON statement and the default value of 32767 is substituted for the out of range 2*A. >list 10 20 30 40 50 60 SHORT INTEGER A,B A=32767 B=2*A PRINT A PRINT B END >run Error 20 in line 30 SHORT INTEGER precision overflow.
be done. num_lines image The maximum number of lines expected to be needed by this statement. This number reflects ALL output done before the next DETAIL LINE statement executes. An image string or a line reference to an IMAGE line. output_list A list of output items that is identical to the list for the PRINT USING statement. Examples The following examples show the DETAIL LINE statement.
are updated, totals are reset and OLDCV values are reset. process is described under TRIGGER BREAK. This * Accumulate all TOTALS. GRAND TOTALS are evaluated and added first, then TOTALS are done in ascending level number order. * Evaluate the PRINT DETAIL IF statement. If the statement does not occur, or if the expression is true (nonzero), do the following: * Evaluate the WITH clause of DETAIL LINE.
In the first declaration, each element of the array can have a maximum length of 18 characters (default value). In the second declaration, the maximum length of each element is num_expr3 characters. array_subscripts A list specifying each dimension. Each dimension is separated from the next by commas. An array has between one and six dimensions. The default is one dimension.
DISP The DISP statement outputs several values. It can use output functions to output control characters. The DISP statement is similar to the PRINT statement. The only difference between the DISP and PRINT statements is that the DISP statement uses the standard list device, and the PRINT statement uses the output device specified by the most recently executed SEND OUTPUT TO statement.
FOR Clause in Display List The display list of a DISP statement can contain a FOR clause. clause is similar to the FOR NEXT construct. The FOR Syntax (FOR num_var =num_expr1 TO num_expr2 [STEP num_expr3 ], output_item_list ) Parameters num_var A numeric variable assigned the sequence of values: num_expr1, num_expr1 +num_expr3, num_expr1 +(2*num_expr3 ), etc.
| | | | | | 1 | 2 | 2 | B(1,2,2) | | | | | | --------------------------------------------------------------------------------------------| | | | | | 2 | 1 | 1 | B(2,1,1) | | | | | | --------------------------------------------------------------------------------------------| | | | | | 2 | 1 | 2 | B(2,1,2) | | | | | | --------------------------------------------------------------------------------------------| | | | | | 2 | 2 | 1 | B(2,2,1) | | | | | | --------------------------------------------------------
Examples 110 120 125 130 160 200 DISP USING 100 DISP USING Image1 DISP USING Image$ DISP USING "5X" IMAGE1: 2A 4X !Uses the IMAGE statement at line 100 !Uses the IMAGE statement at the line !contained in Image1 !Uses the IMAGE statement in Image$ !Uses the image "5X" ELSE The ELSE statement is used as part of the IF THEN ELSE construct. It is used to indicate what is to be executed if a specified numeric expression is zero or FALSE. Refer to the IF THEN ELSE statement for information.
statement. END REPORT DESCRIPTION This stand-alone statement marks the end of a report description. is no output associated with this statement. There Syntax END REPORT DESCRIPTION Examples The following example shows a line containing the END REPORT DESCRIPTION statement. 100 END REPORT DESCRIPTION The END REPORT DESCRIPTION statement acts as a comment if there is no active report; if BEGIN REPORT has not executed. If a report is active and this statement is executed, two possible actions may occur.
120 END TRANSACTION Db$,MSG M$,MODE 2,STATUS S(*) 130 END TRANSACTION Db$,MSG=M$,STATUS=S(*) END WHILE The END WHILE statement is part of the WHILE construct. It is used to indicate the end of that construct. Refer to the WHILE statement for more information. ENTER The ENTER statement assigns characters that are already present in display memory to HP Business BASIC/XL variables. User input from the keyboard is not accepted.
procedure or function in an executable library so that the procedure can be called from within the HP Business BASIC/XL program. The purpose of the statement is to specify the name of the procedure or function that is called from within the HP Business BASIC/XL program. If the name in the executable library is different from that to be used within HP Business BASIC/XL, the name of the entry point in the executable library can be specified in the alias clause.
to specify the number of parameters actually passed. Refer to the HP PASCAL Reference Manual for additional information. HPC HP C/XL return_type Type of the value returned by the function. Can be any HP Business BASIC/XL type or the type BYTE (see "Calling External Subunits" in chapter 3). identifier The name used within the HP Business BASIC/XL program to call the function or procedure.
an external Pascal program. PASCAL EXTENSIBLE keywords.
condition Examples The following examples show the use of the FILTER statement. 400 410 FILTER USING 300; ALL FILTER USING Thread_list; TRIM$(Name$)="widgets" AND Price < .25 FIXED The FIXED statement sets the default numeric output format to fixed-point and specifies the number of digits to be printed to the right of the decimal point. The FLOAT and STANDARD statements also set the default numeric output format.
Floating-point format is appropriate for very large and very small numbers. Floating-point format is {+} [-]d [[d ]...]E {-}dd [d ] where d is a numeric digit. The leftmost minus sign prints if the number is negative. The decimal point prints unless n is zero, and it is followed by n digits. To express the number in fixed-point format, raise ten to the power of the exponent (represented by {+|-}dd [d ]) and multiply it by the mantissa (represented by [-]d [.d [d ]...]). Examples 10 FLOAT 2 20 PRINT 123;.
end of the multi-line function, but for program documentation purposes it is a good idea to include the FNEND. Example 10 25 20 30 99 100 110 120 999 READ A DATA 3 C= FNMath(A) PRINT C END DEF FNMath(X) Y=X*2 RETURN Y FNEND !Calls the function. !Start of the function. !Return from the function. !Indicates the end of the function. FOR The FOR and NEXT statements define a loop that is repeated until the value of the loop control variable is greater than or less than a specified value.
If num_expr3 is positive, and the first value is greater than the last value, or if num_expr3 is negative, and the first value is less than the last value, then the loop is never executed. 20 FOR I=10 TO 1 30 PRINT I 40 NEXT I !Never executed FOR constructs can be nested.
100 GETKEY 200 GETKEY keydef2 300 GET KEY Filename$ + "." + Groupname$ 310 !Uses file Keydef2 !Uses the file named in !Filename$ in group Groupname$ GLOBAL EXTERNAL The GLOBAL keyword modifier to the EXTERNAL statement. It allows either the main block or any procedure or function within a program to call an external. It's use and syntax are explained in the EXTERNAL statement. GLOBAL INTRINSIC The GLOBAL keyword is a modifier to the INTRINSIC statement.
When the above program is listed, line 70 will list as GOSUB 90. The program prints this square: +----+ | | | | +----+ The GOSUB statement is a local subroutine call. The local subroutine is not a separate program unit (subunit); it belongs to the program unit that contains it. Parameters cannot be passed to it, but it can access all variables declared in that program unit.
12 20 21 22 30 31 32 40 41 42 50 51 52 60 61 62 90 99 RETURN REM Subroutine for I=2 PRINT "I is two" RETURN REM Subroutine for I=3 PRINT "I is three" RETURN REM Subroutine for J=1 PRINT "J is one" RETURN REM Subroutine for J=2 PRINT "J is two" RETURN REM Subroutine for J=3 PRINT "J is three" RETURN DATA 3,2 END !Return to line 3 !Return to line 3 !Return to line 3 !Return to line 4 !Return to line 4 !Return to line 4 In the above program, line 2 will be listed as GOSUB I OF 10,20,30.
{GOTO } {GO TO} num_expr OF line_id [ [, line_id ]... {else_line_id }] [ELSE {CONTINUE }] Parameters num_expr A numeric expression that is evaluated and converted to an integer, n. The integer n must be between one and the number of line_id s, or an error occurs if no ELSE clause is present. Control transfers to the n th line_id. line_id A line number or line label of a line that control can be transferred to. The line specified must be in the same program unit as the GOTO OF statement.
one such statement. Syntax GRAND TOTALS [ON] num_expr [{,} ] [{;} num_expr ]... Parameters num_expr Any numeric expression can be totaled. There can be as many expressions as desired. When referring to a particular total, a sequence number is used. The first expression is sequence number 1, the second is number 2, and so on.
num_lines image The maximum number of lines expected to be needed by the section statement. This number reflects ALL output done by the section. An IMAGE string or a line reference to an IMAGE line. output-list A list of output items. This list is identical to the list used by PRINT USING. Examples 100 HEADER 1 WITH 3 LINES 100 HEADER Order(1) USING Hd_image;Who The HEADER statement generates an error if there is not an active report.
else_clause Executable program statement or line_id. If num_expr FALSE (zero), the IF THEN ELSE statement executes the executable program statement or transfers control to line_id. line_id is the line number or line label to which control transfers.
125 PRINT "NOT OK" 130 GOSUB Error-routine 135 END IF !Control transfers to Error-routine IF THEN ELSE constructs can be nested; that is, the IF or ELSE clause of one IF THEN ELSE structure can contain another IF THEN ELSE construct. The ENDIF is associated with the most recently preceding IF THEN ELSE construct.
110 210 310 410 IMAGE IMAGE IMAGE IMAGE DDD,XX,DDD,XX,DDD,XX 3 (DDD,XX) DDDDD,XX,ZZZ.DD 5D,2X,3Z.DD The format strings of lines 110 and 210 are equivalent, as are the format strings of lines 310 and 410. In line 210, three is the repeat factor represented by num_expr, above. In line 410, the numbers 5, 2, and 3 are also called repeat factors; "Digit Symbols" and "Space Specifications" in chapter 6 explain them. IN DATASET The IN DATASET statement specifies the record format of a particular data set.
The SKIP feature is used to bypass data in a dataset record that is not needed by the program. The numeric constant that immediately follows SKIP specifies the number of bytes to bypass. There must be an IN DATASET statement for each data set defined in the thread list. Refer to the THREAD IS statement description below for details about the thread list. The IN DATASET statement is a nonexecutable statement and is treated internally like a PACKFMT statement.
array can also be input with the MAT INPUT statement). See "FOR Clause in Input List" for more information. Examples The following examples show several ways to use the INPUT statement.
10, 20, 30, 40 Input X: 50 Following execution of line 10, the values assigned to each variable will be: A(1) A(2) A(3) A(4) X = = = = = 10 20 30 40 50 Input list FOR clauses can be nested. 20 INPUT (FOR I=1 TO 3, (FOR J=1 TO 2 (FOR K=1 TO 2, B(I,J,K)))) For each combination of values of I, J, and K, the following table shows the value that the above INPUT state assigns to each variable.
INTEGER This statement defines a variable of type INTEGER. If the SHORT option is included, the variable is of type SHORT INTEGER. Syntax {num_var } [ {num_var }] [SHORT] INT[EGER] {arrayd } [,{arrayd }]... Parameters num_var Name of scalar numeric variable to be declared. arrayd Numeric array description. The syntax for the array is described under the DIM statement.
that is, it must begin with FN, as in FNAdd. The actual name to use for the call is returned from the definition in the intrinsic file. str_lit The alias is the name, if different from the name to be used in the HP Business BASIC/XL program, of the intrinsic in the fname file. The string provided is assumed to be the case-sensitive name of the intrinsic file entry. The actual name to use for the call is returned from the definition in the intrinsic file.
List" in chapter 6. FOR_clause (FOR num_var =num_expr1 TO num_expr2 [STEP num_expr3 ], d_list ) See "FOR Clause in Display List" in the DISP and PRINT statements in this chapter. Examples 10 V$="Hi there." 20 DISP V$ 30 LDISP V$ In the above example, if you type RUN and the screen already has characters on the next two lines: >RUN 12345678901234567890 12345678901234567890 then following program execution, the screen contains >RUN Hi there.01234567890 Hi there.
whenever the right margin changes. When report output is done, all output is preceded by column -1 spaces. However, the left margin only applies if the output device is not a terminal. For terminal devices, the left margin is always 1. The left margin applies to both the standard output file and the COPY ALL OUTPUT file, if output is being copied. If the left margin is too large for the COPY ALL OUTPUT file or for the standard output file, there is an error in BEGIN REPORT.
Examples 10 20 30 40 LET Number=3 Num1, Num2, Num3=4+6 String$="cat" LET Str1$,Str2$= "Ab" + "CdE" !Assignment: !Assignment: !Assignment: !Assignment: 3, to Number 10, to Num1, Num2, and Num3 "cat" to String$ "AbCdE", to Str1$, and Str2$ HP Business BASIC/XL accesses variables in LET statements from left to right. If variables have not been declared, and implicit declaration is illegal, an error occurs.
Parameters LET_stmt A LET statement Example 10 LET A,B=5; C$="HI";D=4+2 LINPUT LINPUT statement execution places the program in the input state and assigns a string value obtained from the terminal or input file to a single string variable. The string value accepted is an unquoted string literal. Double quotes are characters. Unlike the INPUT statement, the LINPUT statement includes the leading and trailing blanks as part of the string value.
140 LINPUT #1,1; C$[1;8] LOCK The LOCK statement requests exclusive access to a file, for the program that executes the lock statement. If the file cannot be accessed at the time the LOCK statement is executed, an option can be specified to delay execution of the LOCK statement until the program has exclusive access. Syntax LOCK #fnum [; WAIT num_var ] Parameters fnum The file number that HP Business BASIC/XL uses to identify the file.
statement; if TRUE, control is transferred to the line following the ENDLOOP statement. If the loop does not contain an EXIT IF statement, and control is not transferred out of the loop by some other means (for example, a GOTO statement) the loop never ends. Examples 100 110 120 130 140 150 160 999 LET I=0 LOOP PRINT I LET I=I+1 EXIT IF I=100 ENDLOOP PRINT I END !Initialize I !Begin loop !Print I (at this line, I=0,1,2,...,99) !Increment I (at this line, I=1,2,3,...
145 150 160 200 210 220 999 I=I+1 END LOOP STOP REM Subroutine PRINT I RETURN END !Reenter loop here !End loop !Begin subroutine !Return to loop If a program unit contains an EXIT IF statement that is not in a loop, an error occurs. MARGIN The MARGIN statement sets the margin for the terminal screen or for an ASCII file. Also, see the MARGIN option described in the "Device Specification Syntax" section of chapter 6.
(3b) MAT num_array1 = (num_expr ) op num_array2 (4) MAT num_array1 = num_array2 op num_array3 (5) MAT num_array1 {CON} = {ZER} [(dims )] {IDN} (6) MAT num_array1 = s_or_a_function (7) MAT num_array1 = array_function (8) MAT num_array1 = MUL (num_array2, num_array3 ) (num_array2 ) (num_array2 ) Parameters op +, -, *, /, <, <=, =,>=, <>, or # num_array1 In equation (4), num_array1 must have the same number of dimensions as num_array2 and num_array3.
matrix. INV Inverts square matrix. MUL Multiplies two matrices or a vector and a matrix. Table 4-5 through Table 4-6 give more information about the MAT = statement. Table 4-5 Gives the new dimensions of and value of num_array1 each form of the MAT = statement. Table 4-6 Shows how the dimensions of num_array2 and num_array3 determine the new dimensions of num_array1. Table 4-5.
Table 4-6.
320 330 340 999 ! DATA 10,20,30,40 DATA 1,2,3,4,5,6,7,8 END MAT INPUT The MAT INPUT statement accepts values from the terminal keyboard to one or more arrays. If new dimensions are specified for the arrays, the MAT INPUT statement redimensions them before assigning values to them. It assigns values element by element, in row-major order. Syntax MAT INPUT array [dims ][, array [dims ]]... Parameters array Structured collection of variables of the same type.
? RETURN ?8 RETURN then A is: 2 4 0 8 MAT PRINT The MAT PRINT statement prints one or more arrays to the standard list device or a data file. It prints them element by element, varying the rightmost subscript fastest. Syntax For printing to a string variable or the standard list device: MAT PRINT array [{,} ] [,] [{;} array]...[;] For printing to a data file: [{,} ] [{,} ] MAT PRINT #fnum [,rnum [,wnum ]]; array [{;} array ]...
The following shows an example of printing an array with MAT PRINT. >list ! mprtexam 5 OPTION BASE 1 10 DIM A(2,2) 20 A(1,1)=0 21 A(1,2)=0 22 A(2,1)=0 23 A(2,2)=0 30 MAT INPUT A 40 MAT PRINT A >run ?1,2,3,4 1 2 3 4 MAT READ The MAT READ statement assigns values from one or more DATA statements or a data file to one or more arrays. If new dimensions are specified for the arrays, the MAT READ statement redimensions them before assigning values to them.
Examples The following examples show the MAT READ statement. Each reads a group of arrays into array variables. In lines 100 and 120, the entire arrays are read, and in lines 110 and 130 selected elements are read.
197 200 210 220 225 230 240 250 260 ! ASSIGN #2 TO "File2b" OFF END #2 !Disables the ON END statement in line 140 RETURN ! SUB End3 PRINT "Reusing File3" POSITION #3;BEGIN SUBEND OFF ERROR Execution of the OFF ERROR statement deactivates any ON ERROR statement that affects the program unit containing the OFF ERROR statement. Syntax OFF ERROR If a program unit executes an OFF ERROR statement and then calls another program unit, any previous ON ERROR statement is inactive in the called program unit also.
returns to the calling program unit. OFF KEY The OFF KEY statement restores the last typing aid key definition for a user-definable key or set of keys. If no typing aid key definitions are active then the default key definitions are restored. Syntax OFF KEY [key_number_list ] Parameters key_number_list A list of integers or numeric expressions that evaluate to an integer in the range of [1, 8] separated by commas or semicolons. No more than eight values can be specified for each statement.
Table 4-7. ON DBERROR Statements --------------------------------------------------------------------------------------------| | | | | Statement Executed If | Line to Which | Scope of ON DBERROR | | Run-Time Error Occurs | Error-Handling Code | Statement | | After ON DBERROR | Transfers Control When | | | Statement Executes | it Ends | | | | | | --------------------------------------------------------------------------------------------| | | | | GOTO line_id | None.
sub_id Subunit identifier. Control transfers to this subunit when the ON END statement executes. Examples The following example uses the ON END statement to trap an end-of-file error. Lines 20-90 set up the file. Line 200 contains the ON END statement. Lines 210-240 read the file, and an end-of-file occurs. The ON END statement prints line 300, and execution continues.
Table 4-8. ON ERROR STATEMENTS --------------------------------------------------------------------------------------------| | | | | Statement Selected | Line to Which | Scope of ON ERROR | | | Control is Transferred | Statement | | | following ON ERROR | | | | processing | | | | | | --------------------------------------------------------------------------------------------| | | | | GOTO line_id | None. | Program unit that contains | | | | it.
statement. 100 105 115 116 120 130 140 150 ON ERROR GOTO 115 A=B/0 PRINT "ERROR" CALL Sub1 END SUB Sub1 I=J/0 SUBEND 100 105 110 115 116 120 130 140 150 ON ERROR GOSUB 115 A=B/0 CALL Sub1 PRINT "ERROR" RETURN END SUB Sub1 I=J/0 SUBEND 100 110 115 120 130 141 150 160 170 180 190 ON ERROR CALL Error A=B/0 CALL Sub1 END SUB Error PRINT "ERROR" SUBEND SUB Sub1 I=J/0 SUBEND !Error occurs; go to line 115 !ON ERROR at line 100 inactive within Sub1 !Error aborts program !Error occurs; gosub line 115.
Syntax {GOSUB } {GO SUB} line_id ON num_expr [, line_id ]...[ELSE else_line_id ] Parameters num_expr A numeric expression that is evaluated and converted to an integer, n. The integer n must be between one and the number of line_id s, or an error occurs if no ELSE clause is present. Control is transferred to the n th line_id. line_id Line number or line label of the line to which control is transferred. The line must be in the same program unit as the ON GOSUB statement.
Parameters num_expr A numeric expression that is evaluated and converted to an integer, n. The integer n must be between one and the number of line_id s, or an error occurs if no ELSE clause is present. Control is transferred to the n th line_id. line_id A line number or line label of a line to which control can be transferred. The line specified must be in the same program unit as the ON GOTO statement.
Table 4-9. ON HALT Statements --------------------------------------------------------------------------------------------| | | | | Statement Selected | Line to Which | Scope of ON HALT | | | Control is Transferred | Statement | | | following ON HALT | | | | processing | | | | | | --------------------------------------------------------------------------------------------| | | | | GOTO line_id | None. | Program unit that contains | | | | it.
subprogram A valid subprogram name. line_id A line number or line label. key_label A quoted string of characters used to fill in the label field of the user-definable key. The string that you use is specific for your terminal. If the label is <= fifteen characters, it is centered in the key label. If the key label is missing, "f1" through "f8" are used.
If there is no form currently active and a form file is specified in form_file_name, the file type of the form file is examined to determine whether the file to be activated is an VPLUS form file or a JOINFORM File. If there is no form file specified as part of the form name, the most recently opened form file is used. An error occurs if no form file has been opened and the form_file_name is omitted.
Table 4-10. Changeable Program Unit Characteristics --------------------------------------------------------------------------------------------| | | | | Program Unit | Option (Default First) | Effect | | Characteristic | | | | | | | --------------------------------------------------------------------------------------------| | | | | Default numeric | REAL | Implicitly declared numeric | | type (type | DECIMAL | variables are type REAL.
| | | | --------------------------------------------------------------------------------------------- Table 4-11 Note ** The default value if neither is specified is MAIN NONEWCOM. The value of this option is not set in the configuration utility nor is the value displayed in the INFO command's display. Syntax [GLOBAL] OPTION option_list Parameters GLOBAL Allowed only if the statement is in the main program.
TRACE MAIN NONEWCOM OPTION and GLOBAL OPTION statements are processed immediately before the program units containing them are run. Neither statement can be used as a command. The MAIN and SUBPROGRAM global options are used chiefly for compiling multi-program applications. A program that uses the SUBPROGRAM option can only be run by execution of a GET program line from within an executing program. Trying to RUN a program in the interpreter that has a GLOBAL OPTION SUBPROGRAM statement results in an error.
10 OPTION REAL 20 A = PI 99 END 10 OPTION DECIMAL 20 A = PI 99 END 10 REM No option specified 20 A = PI 99 END In the first and second programs below, the variables are initialized to zero when the program is run; in the third, they are not. 10 OPTION INIT 20 INTEGER X,Y,Z 99 END 10 REM No option specified 20 REAL A,B,C,D,E 99 END 10 OPTION NOINIT 20 DECIMAL P,Q 99 END In the first and second programs below, implicit variable declaration is legal.
PACK The PACK statement assigns the values of data from one or more variables to one scalar string variable, in the order specified by the names of the variables in the referenced PACKFMT statement. Syntax PACK USING line_id; str_var Parameters line_id Identifies the program line of the appropriate PACKFMT statement that specifies the variables to be packed and the format in which to pack them within str_var. str_var Scalar string variable into which variables are to be packed.
INTEGER SREAL REAL SDECIMAL DECIMAL where number is a positive short integer numeric constant that specifies the number of characters skipped. The skip feature is used to bypass unneeded data in a data set. For the PACK USING and UNPACK USING statements, that number of characters (bytes) are skipped in the specified str_var. For the DBGET USING, DBPUT USING and DBUPDATE USING statements that number of characters is skipped in the implicit str_var.
The USING clause is executed each time a page header is printed. The PAGE HEADER statement generates an error if a report is not active. If a report section is active; that is, executing, and encounters this statement, then that report section is ended. The PAGE HEADER statement executes when an automatic page break condition occurs, or when the TRIGGER PAGE BREAK statement is executed. Under these circumstances, the PAGE TRAILER prints, followed by the PAGE HEADER.
Examples The following examples show the use of the PAGE LENGTH statement. 100 PAGE LENGTH 60,0,0 100 PAGE LENGTH 66,2,2 ! HP 250/260 default The PAGE LENGTH statement is evaluated only during BEGIN REPORT. The page size cannot change during the report. The statement is busy only while being evaluated. PAGE TRAILER The PAGE TRAILER statement in the PAGE TRAILER section is a Report Writer statement used to print lines at the bottom of every page of a report.
In order to perform a page break, the PAGE TRAILER section first prints enough blank lines to position the page trailer properly on the page. Then the PAGE TRAILER statement executes its USING clause, if present. The PAGE TRAILER section executes next, terminating when another REPORT WRITER section statement is encountered. Blank lines are then printed for the remaining lines reserved by the PAGE TRAILER and for the bottom margin.
>CONT >MAT PRINT Matrix_ inverse -.035714285714857 -.0357142857142857 .1785714285714286 -.130952380952381 .2023809523809524 -.0119047619047619 .0119047619047619 -.0595238095238095 .3452380952380952 >80 CREATE "inverse" >90 ASSIGN #2 TO "inverse" >100 MAT PRINT #2;Matrix_inverse >110 PRINT "Done with program" >120 END >CONT Done with program > In the above program, the program is paused at line 50, and the first two MAT PRINT statements are executed.
until a carriage return is pressed before continuing. Any characters typed are not echoed. Essentially, the report writer executes the ACCEPT statement to accomplish the pause. POSITION The POSITION statement positions the record pointer of a specified file at a specified record. The RESET option can reset the file to an empty file. Syntax {rnum } {BEGIN} POSITION #fnum; {END } {RESET} Parameters fnum The file number that HP Business BASIC/XL uses to identify the file.
Syntax PREDICATE whole_str FROM dataset [ [{>=} ] ] [WITH item_name [{<=} expr ] ] [ [{= } ] ] [[{,} [ [{>=} ]]] ] [[{;} dataset [WITH item_name [{<=} expr ]]]...] [[ [ [{= } ]]] ] Parameters whole_str A string variable or string array element that is filled by the PREDICATE statement with the locking information required by TurboIMAGE. The string can then be used in the DBLOCK statement to perform the locking. dataset The dataset name or number to be locked.
DISP statement uses the standard list device. If the most recently executed SEND OUTPUT TO statement specifies the standard list device, or if the program has not executed a SEND OUTPUT TO statement, then the PRINT statement is equivalent to the DISP statement. The PRINT statement can also transfer the value of one or more variables to a data file.
Examples Below are several examples of the PRINT statement. 200 210 220 230 240 250 260 270 PRINT PRINT, PRINT; PRINT X,X+Y;A$,LWC$(A$+B$);P(*),Q$(*);PAGE,TAB(10+X); PRINT Z(*), (FOR I=1 TO 10, Z(I); 2*Z(I); I*Z(I)), D$ PRINT X,B$,C(*),D$(*), PRINT A,,B PRINT "THE ANSWER IS: "; Final_total The PRINT statement evaluates the expressions in the display list from left to right, and displays their values on the appropriate output device.
Table 4-12. Effect of File Type on PRINT Statement --------------------------------------------------------------------------------------------| | | | | | | BASIC DATA | Binary | ASCII | | | | | | --------------------------------------------------------------------------------------------| | | | | | Sequential Write | Record indicated by | Record indicated by | Record indicated by | | Starts at | record pointer. | record pointer. | record pointer.
Parameters num_var A numeric variable assigned the sequence of values: num_expr1, num_expr1 +num_expr3, num_expr1 +(2*num_expr3 ), etc. The DISP or PRINT statement prints the values of the elements of d_list for each value that is less than num_expr2 if num_expr3 is positive or greater than num_expr2 (if num_expr3 is negative). num_expr1 First value assigned to num_var. num_expr2 Value to which num_var is compared before the DISP or PRINT statement prints a value.
| | | | | | 2 | 1 | 1 | B(2,1,1) | | | | | | --------------------------------------------------------------------------------------------| | | | | | 2 | 1 | 2 | B(2,1,2) | | | | | | --------------------------------------------------------------------------------------------| | | | | | 2 | 2 | 1 | B(2,2,1) | | | | | | --------------------------------------------------------------------------------------------| | | | | | 2 | 2 | 2 | B(2,2,2) | | | | | | --------------------------------------------------------
controlling the detailed output with PRINT DETAIL IF is more automatic and centralized in one place: Suppressed by program: 100 REPORT HEADER ... 200 END REPORT DESCRIPTION ... 500 510 515 520 530 IF Pdi THEN DETAIL LINE 0 WITH N LINES USING A;X,Y ELSE DETAIL LINE 1 WITH N LINES USING A;X,Y ENDIF Suppressed by Report Writer: 100 REPORT HEADER 110 PRINT DETAIL IF Pdi ... 200 END REPORT DESCRIPTION ...
260 PRINT USING "DD2XZZ"; A, B 300 IMAGE DDD,4A,DD PROTECT The PROTECT statement assigns a lockword to a file to protect the file against unauthorized copying, renaming, and purging. A COPYFILE, RENAME, or PURGE statement cannot access the file unless it specifies the associated lockword. Syntax PROTECT fname [, lock_word ] Parameters fname The file name. lock_word A string expression or literal. A string expression representing a valid file system lockword.
The RAD statement indicates that angular units will be specified in Radians. This is the default. A Radian is 1/(2*PI) of a circle. trigonometric functions. This statement is used with Syntax RAD Example 10 20 30 40 Radius=10 RAD Area=PI*Radius**2 PRINT Area RANDOMIZE The RANDOMIZE statement resets the value of a seed that the RND function uses for random number generation. The seed is set to one of 116 values that are available to it.
wnum Word number, a numeric expression. If a file I/O statement specifies wnum, it is a direct word. Direct word reads are allowed only with BASIC DATA files. [{,} ] [{;}item ]... input_list item Each item is a numeric or string variable, an array reference, or a FOR clause. An array reference has the syntax array_name ([*[,*]...]) with one asterisk per dimension or it does not have asterisks. Not using asterisks specifies any number of dimensions.
--------------------------------------------------------------------------------------------- When reading from a binary file, HP Business BASIC/XL does not convert data to the types of the variables to which it assigns them. For example, if a program tries to read decimal data that is in a binary file into real variables, the numbers returned are incorrect.
FOR Loops in READ statements The READ statements in the previous examples have contained only references to individual variables. A READ statement can contain a FOR loop designed to assign values to specific array elements or substrings of a string variable.
READ FORM The READ FORM statement assigns the values entered into the fields of a VPLUS form to HP Business BASIC/XL variables. A time limit for input can be specified by using the TIMEOUT clause. Syntax READ [FROM] FORM [ [{,} ]] [form_item [{;} form_item...]] [{,} ] [{;} TIMEOUT [=] time_expr ] [{,} ] [{;} NOEDIT [[=] key_number_list ]] Parameters form_item One of the following: form_element for_clause skip_clause form_element One of the following: num_var str_var $ array_name ([*[,*]...
user-defined branch-during-input key. Fields with matching data items are converted and assigned to the corresponding HP Business BASIC/XL variables. The READ FORM statement is designed to assign the information in all the fields on an entire screen at once. Each field is assigned to a single variable or array element. The first form_item is assigned the value of the first field on the form, the second form_item is assigned the next value, etc.
100 120 130 140 SHORT REAL Fraction SHORT REAL Reading1, Reading2(36,36) REAL Distance REAL Time1(0:35,1:36,3),Time2 REDIM An array can be redimensioned explicitly or implicitly. The REDIM statement explicitly redimensions one or more arrays. Unlike the DIM statement, it is executable. You can do the following by redimensioning an array: * * Change the bounds of one or more dimensions. Decrease the number of elements accessible.
A: 1 2 3 4 5 6 B: 1 2 3 4 5 6 7 8 9 1 2 3 Arrays can also be explicitly redimensioned by the MAT READ and MAT INPUT statements, or implicitly redimensioned by the MAT = statement. REM The REM statement specifies a remark. It is the first keyword on a comment line. HP Business BASIC/XL ignores the rest of that line. Syntax REM Examples 10 REM The rest of this line is ignored RENAME The RENAME statement changes the name of a file.
Examples 10 20 30 40 50 60 99 Nums_read=0 REPEAT !Begin loop READ Number Nums_read=Nums_read+1 UNTIL Number !End loop when Number<>0 PRINT Nums_read," numbers read" END REPEAT constructs can be nested.
Examples The following examples show the use of the REPORT EXIT statement. 100 REPORT EXIT TRUE 100 REPORT EXIT Implementor > 0 WITH 3 LINES USING Rpt_image The REPORT EXIT statement generates an error if no report is active. If a report section is active (executing) and encounters this statement, then that report section is ended. The REPORT EXIT section executes ONLY when STOP REPORT is executed in a program. A STOP REPORT command stops the report immediately.
statement after the matching END REPORT DESCRIPTION statement. If a report is active and the REPORT HEADER statement is executed, two possible actions can occur. If another report section is active, that section is ended. Otherwise, the statement is unexpected and an error occurs. The REPORT HEADER section is executed when report output begins. The section only executes once.
RESAVE KEY The RESAVE KEY statement's action is dependent on whether a filename parameter is included in the statement. If a filename parameter is included and the file does not previously exist, the RESAVE KEY statement stores the typing aid definitions in a BKEY file. The file to which the information is saved has a special format and a BKEY file code.
RETURN The RETURN statement returns control to the program unit that called a subroutine or multi-line function. When used in a subroutine, control is returned to the statement following the GOSUB statement. When used in a multi-line function, the value of the expression immediately following RETURN is returned to the statement or expression where the call was made.
After a GOSUB statement is executed, the subroutine to which it transfers control is "open". When a matching RETURN statement is executed, the subroutine is "closed." An error occurs if a RETURN statement is executed when no subroutine is open.
unquoted string literal or a string expression as described in chapter 6. Examples The following examples show the use of the SAVE KEY statement, and also show that SAVE key is also available as a command. SAVE KEY SAVE KEY typeaid 100 SAVE KEY 110 SAVE KEY typeaid1 SCRATCH KEY The SCRATCH KEY statement resets the current typing aid contents of the attribute, label, and key definition fields of an individual or group of user-definable keys.
nonempty. If the workfile is empty, all data records in the data sets, mentioned in the threadlist, are searched. If, however, the workfile is nonempty searching is done only on the records whose pointers are contained in the workfile. The pointers to those records whose data fail the search condition are dropped from the workfile. Syntax {search_condition } SEARCH USING line_id; {ALL } Parameters line_id Line label on line number that identifies the line on which a THREAD IS statement is defined.
Each case_descriptor must be a numeric literal if select_expr evaluates to a numeric value and a string literal if it evaluates to a string value. If the select_expr value is equal to one of the specified case_descriptor literals or is within the range specified in the case_descriptor, then the case clause associated with the case_descriptor is executed. stmt Program line. It is executed if select_expr fits the associated case_descriptor.
40 41 42 50 51 52 60 61 62 70 72 73 80 81 82 83 90 91 92 100 CASE 1 TO 10 PRINT "1 thru 10" GOSUB Routine1 CASE 10 TO 20 EXCLUSIVE PRINT "Between 10 & 20" GOSUB Routine2 CASE 20,22,24 PRINT "Special Case #1" GOSUB Spec_case1 CASE 21,23,25 PRINT "Special Case #2" GOSUB Spec_case2 CASE > 30 PRINT "Over 30 by:" PRINT (A+B)-30 STOP CASE ELSE PRINT "26 thru 30" GOSUB Routine3 END SELECT !1 <= A+B <= 10 !10 < A+B < 20 !A+B = 20, 22, or 24 !A+B = 21, 23, or 25 !A+B > 30 !26 <= A+B <= 30 SELECT constructs can b
133 134 140 141 142 150 160 300 310 400 410 500 510 520 999 PRINT 2*T PRINT T REM Clause 3 CASE > 0 GOSUB 400 END SELECT STOP REM Do anything RETURN REM Do anything RETURN SUB Sub1 REM In procedure SUBEND END !Return to construct from 310 !Jump out of construct !Return to construct from 410 !Arrive !Return !Arrive !Return !Called from Clause 2, line 132 to Clause 2, line 133 from Clause 3, line 142 to Clause 3, line 122 from Clause 1 line 121 !Return to clause 1 line 122 SEND OUTPUT TO The SEND OUTPUT
statements and commands effected by SEND SYSTEM OUTPUT TO are CHANGE, COPY, FIND, INFO, LIST, LIST SUBS, MODIFY, MOVE, and REDO. If a program does not contain a SEND SYSTEM OUTPUT TO statement, output is sent to the system standard list device.
An HP Business BASIC/XL program can pass an HP Business BASIC/XL string as an actual parameter to a Pascal PAC or C array formal parameter, but only the string characters are passed (the current string length is not). If the HP Business BASIC/XL program passes the string by reference, and the Pascal or C external routine changes its current length, then the HP Business BASIC/XL program must reset the current length when it resumes control.
Syntax SORT USING line_id; key_list Parameters line_id Line label or line number that identifies the line on which the THREAD IS statement is defined. key_list List of variables. The DES keyword can follow each variable in the list. Specifying DES means that the data is sorted in descending order. If not specified, data are sorted in ascending order. Whole arrays are not allowed.
Table 4-15.
* Files are closed (except those declared in COMMON). * Data pointers are lost. * ON END, ON ERROR, ON DBERROR, ON GOTO, and ON GOSUB statements are deactivated. STOP REPORT The STOP REPORT statement is a Report Writer statement that can be used to terminate a report prematurely. This statement can also be used when the user does not know if a report is active as no error is generated by this statement.
f_param A formal parameter. [type ] num_var One of the following: num_var is a numeric variable and type is one of the following: SHORT SHORT REAL SHORT INTEGER SHORT DECIMAL REAL INTEGER DECIMAL If type is not specified, num_var is declared with the default numeric type. If type is specified, it determines the type of each num_var between it and the next type or the next nonnumeric f_param. str_var $ String variable. Its maximum length is the same as that of the actual parameter.
calling program unit. #fnum A file designator. fnum is a positive short integer greater than zero. The file designated by the actual parameter file designator is referenced by #fnum within the subprogram.
The SUBEND statement is legal only in a subprogram. main program or a multi-line function. It is illegal in the It is good programming practice to end a subprogram with a SUBEND statement, and use SUBEXIT statements within the subprogram. The SUBEND statement can appear more than once within a subprogram, and it need not be the last line. One subprogram ends where the next subunit begins, or where the program ends.
Syntax {AT [LEVEL]} SUPPRESS [PRINT] {LEVEL } suppress_level Parameters suppress_level A numeric expression with a value from zero to nine. A level of zero causes the statement to be ignored. All output from the suppress_level and higher summary levels is suppressed. Examples The following examples show the use of the SUPPRESS AT statement. 100 SUPPRESS PRINT AT N+M 100 SUPPRESS AT 4 The SUPPRESS AT statement is evaluated by BEGIN REPORT. It is busy only during evaluation.
As an example of using this statement, assume that the first nine pages of a report have been printed, and an error occurs on the tenth page. After fixing the error, the user may wish to re-run the program. Since the first nine pages are correct, the following statement prevents the reprinting of those pages: SUPPRESS PRINT FOR 9 PAGES Suppressing print for zero pages allows all output to take place. SUPPRESS HEADER This statement enables and disables the execution of the PAGE HEADER section.
The SUPPRESS TRAILER TRAILER section. If TRAILER, it does not the PAGE TRAILER for on the current page. ON statement prevents this statement occurs take effect until the the current page, the the execution of the PAGE during the execution of a PAGE next page. If executed before PAGE TRAILER does not appear When the PAGE TRAILER is suppressed, the lines normally reserved for the page trailer are available to you. Therefore, this statement can increase the size of a page.
If any error or warning results from the command the JCW CIERROR will be changed to reflect the error or warning. num_var NOTE If str_expr is specified, num_var returns the operating system error number. If str_expr is not specified, num_var returns the interpreter command error number, which is: 0 No error (if HP Business BASIC/XL is running interactively). 1 Error (if HP Business BASIC/XL is running from a batch job).
priority exceeds the highest priority that the system permits for the log-on account, then the priority is the highest possible below BS. The default priority is HP Business BASIC/XL's priority. num_var Returns job control word (JCW) of called process.
THREAD IS The THREAD IS statement defines the thread list that is used by the SEARCH/SORT process. A thread list is a list of data sets in a database being searched. The thread list defines the hierarchy as well as the relationship between the data sets. In a THREAD IS statement, each data set is represented by a line label that refers to an IN DATASET statement of the corresponding data set. Syntax [ [PATH num_expr ] ] THREAD [IS] [line_id [LINK identifier ] {,1;}] ...
Example : 500 THREAD IS Set1, Set2 LINK Var, Set3, Set4 * An error results if the specified path between the data sets does not exist and (for detail sets) no LINK is specified. Link cannot be used to connect a master to a detail. * The THREAD statement is nonexecutable. Its validity will be checked at run time by the SEARCH statement or the SORT statement. TINPUT The TINPUT statement obtains a string of characters from an input device. The characters are echoed to the display as they are entered.
rounded to nearest second Greater than 255 Set to 255 seconds If the TIMEOUT option is not selected, then the input time limit is unlimited. If input time is limited through the use of the TIMEOUT option, HP Business BASIC/XL transfers control to the next program statement when the time limit is exceeded without assigning a new value to the specified var. elapsed_num_var A numeric variable to which the time, in seconds, taken to enter the input is returned.
many expressions as desired. When referring to a particular total, a sequence number is used. The first expression is sequence number 1, the second is number 2, and so on. Examples 100 TOTALS ON My_var, TRUNC(Sales), Quantity*100 The BEGIN REPORT statement makes the TOTALS statement busy and it remains busy until an END REPORT or STOP REPORT statement is executed. The TOTALS statement is used ONLY if contained in a HEADER or TRAILER section with a nonzero level number.
Examples 100 TRAILER 1 WITH 3 LINES 100 TRAILER Order(1) USING Hd_image;Who If a report section is active when this statement is seen, the section is ended. An error occurs if this statement is executed directly when a report section is not active. When BEGIN REPORT executes, the level _number of each TRAILER statement is evaluated and the statement is made BUSY. TRAILER sections with level numbers equal to zero are ignored.
A break can be caused either by DETAIL LINE, when a BREAK IF or BREAK WHEN condition is satisfied, or by the TRIGGER BREAK statement. In either case, the Report Writer function LASTBREAK is set to the lowest break that occurred. 1. Execute TRAILER sections from level nine down to the level contained by LASTBREAK. Each section first executes the TRAILER statement. The WITH clause is evaluated, and if the number of lines left on the page is less than the WITH value, a page break is automatically triggered.
When no suppress options are specified, this statement acts identically to an automatic page break; for example, one caused by a WITH clause on any Report Writer statement. The following actions are taken: * Print blank lines up to the location where the PAGE TRAILER should begin. * Execute the PAGE TRAILER section, if present. During this process, the number of lines left on the page is reset to the page trailer size. * Print the blank lines at the top of the page.
Syntax UNLOCK #fnum Parameters fnum The file number that HP Business BASIC/XL uses to identify the file. It is a numeric expression that evaluates to a positive short integer. Examples 100 200 300 400 500 999 CREATE "File1",FILESIZE=1200 ASSIGN "File1" TO #10 LOCK #10 PRINT #10; A,B,C UNLOCK #10 END !Assigns file to #10. !File is locked. !File is unlocked after printing. For more information, see the LOCK statement.
236 240 245 246 250 PRINT Num,S1$,S2$,(FOR I=1 TO 4, N1(I)) Pack4: PACKFMT N1,SKIP 2,S1$,SKIP 1,Num,SKIP 1,S2$[3;5] UNPACK USING Pack4; P2$ PRINT N1(1),N1(2),N1(3),N1(4),S1$,Num,S2$ END UNTIL The UNTIL statement is part of the REPEAT UNTIL construct. REPEAT statement for more information. Refer to the UPDATE The UPDATE statement assigns a value to the current datum of a specified BASIC DATA file, if the assignment is legal.
20 WAIT Wait_time 25 WAIT Wait_time+60 30 WAIT !Number of seconds specified by Wait_time !One minute more than specified by Wait_time !Until user interrupt (control-Y) WARNINGS OFF The WARNINGS OFF statement suppresses the warning messages that HP Business BASIC/XL normally displays. Use WARNINGS ON to return to the default. Syntax WARNINGS OFF WARNINGS ON The WARNINGS ON statement allows HP Business BASIC/XL to display warning messages, as it does by default.
Entering a WHILE loop from a statement other than the WHILE statement is considered to be a bad programming practice, and is not recommended. Use of a GOSUB or CALL statement from within a WHILE loop can be useful.
Parameters form_element One of the following: num_var str_var $ array_name ([*[,*]...]) str_array_name $([*[,*]...]) The last format above has one asterisk per dimension or no asterisks. No asterisks specifies any number of dimensions. Either format is legal, but the format with no asterisks is not compilable. Substrings are also allowed. for_clause (FOR num_var =num_expr1 TO num_expr2 form_item [, form_item ]...) [STEP num_expr3 ], A for_clause is useful for reading array elements.
position the cursor to the first field. Use the SKIP clause to begin writing to a field other than the first field. If no VPLUS form is active, executing a WRITE FORM statement causes a run-time error. Examples The following examples show the use of the WRITE FORM statement.
4- 160
Chapter 5 Functions Introduction HP Business BASIC/XL has a set of predefined standard functions. These functions do not need to be defined to be called, nor is a calling statement necessary. They can be treated like any expression. For example, in the program below, Bnum and Cnum are assigned the return value from the ABS function.
ASN The ASN function returns the principal value of the arc sine of a number. The argument value is in the range [-1, 1]. The result can be expressed in angular units of degrees, grads or radians. Syntax ASN(n ) Parameters n n The number to be evaluated. range of [-1, 1]. is a REAL number in the The ASN function returns a REAL number. Examples 10 A = ASN(0.6) 20 B = ASN(0.6) 30 C = ASN(0.6) !A = 36.87(Degrees) !B = 40.97(Grads) !C = .
The BINAND function returns the binary AND for two numbers. The result of this function is a short integer that contains a one in each bit for which the same bit in both of the arguments is a one. It returns a short integer R such that: R (n ) = N1(n ) AND N2(n ) for all n in [0, 15] where N1(n ) and N2(n ) represent the value of bit n of each expression and R represents the short integer result of BINAND. Syntax BINAND(N1,N2) Parameters N1 Binary representation of a numeric expression. short integer.
Syntax BINOR(N1,N2 ) Parameters N1 Binary representation of the value of a numeric expression. This is a short integer. N2 Binary representation of the value of a numeric expression. This is a short integer. Examples The example below shows the bit layout for the BINOR function. It shows each bit of both arguments, and the result of the BINOR function.
a SHORT INTEGER. This is the number of the bit to be extracted from N1. Examples The example below shows a bit layout for N1. It shows the results of the BITLR function for several values of the second parameter (N2 ). Bit Number: N1= 0 0 1 1 2 1 3 0 4 0 5 1 6 0 7 1 8 0 9 10 11 12 13 14 15 0 0 1 1 1 0 1 BITLR(N1,15)=1, BITLR(N1,11)=1, BITLR(N1,8)=0, BITLR(N1,3)=0 BITRL The BITRL function returns the value of a particular bit of an expression, where 15 is the Most Significant (or leftmost) bit.
restarts HP Business BASIC/XL. If CONTROL Y is enabled and pressed and a program is being executed, a message is printed indicating that HALT was pressed and control is returned to the HP Business BASIC/XL interpreter. If CONTROL Y is pressed while in the HP Business BASIC/XL interpreter, only the message is printed. When BREAK and CONTROLY are disabled, pressing either has no result.
Table 5-2.
Syntax CEIL(n ) Parameters n The number to be evaluated. type. This can be of any numeric Examples 10 20 A = CEIL(3.7) B = CEIL(-3.7) !A = 4 !B = -3 CHR$ The CHR$ function returns the single ASCII character associated with a number. Syntax CHR$(N ) Parameters N The numeric expression to be evaluated. This must evaluate to a value within the range of an HP Business BASIC/XL integer.
Examples OPTION BASE 1 is assumed. The following shows several examples of the result of the COL function on arrays A, B,C,D,E, and F. A(2,2): 1 2 4 5 B(2,4): D(3,3): 1 0 1 3 5 7 9 0 9 COL(A) COL(B) COL(C) COL(D) COL(E) COL(F) = = = = = = 1 2 3 4 5 6 7 8 E(2,2): 8 3 4 7 C(4,3,2): 1 2 5 1 2 0 0 4 1 0 3 2 0 0 4 5 1 2 1 2 0 0 0 1 F(5): 5 4 3 2 1 2 4 2 3 2 1 COMPRESS$ The COMPRESS$ function returns a copy of string in which a single blank space replaces each run of blank spaces.
Syntax CPOS Examples 200 PRINT CPOS CPU If called from within either an interpreted or compiled program, the CPU function returns the number of CPU seconds elapsed since the beginning of program execution. If typed directly in response to the interpreter prompt, the CPU function returns the total number of CPU seconds required for the execution of the last previous program to execute in the interpreter. The result of this function is a REAL number.
12 13 16 9 CURKEY The CURKEY function branch-during-input branch-during-input program. The value returns the integer value of the last key pressed. If the value returned is 0, then no keys have been pressed during the execution of the returned representing a key is in the range [1, 8]. Syntax CURKEY Example 100 PRINT CURKEY !Prints the value of the last branch-during-input 105 !key pressed. 110 IF CURKEY > 0 THEN ENABLE !If a branch-during-input key was pressed, 115 !then the branch occurs.
Table 5-3.
| Integer zero | U. S. format: mm/dd/yy. | | | | --------------------------------------------------------------------------------------------| | | | Integer one | European format: dd.mm.yy. | | | | --------------------------------------------------------------------------------------------| | | | Other | Error.
Examples OPTION BASE 1 is assumed. A(2,2): 1 2 4 5 D(3,3): 1 0 1 3 5 7 9 0 9 E(2,2): 8 3 4 7 DET(A) = -3 DET(D) = 0 DET(E) = 44 DOT The DOT function returns the dot product, or inner product, of two vectors. The elements of the two vectors must be of the same type. If they are short integer arrays, the result is an integer; otherwise, the result is the same type.
110 120 200 210 250 I=J/0 END SUB Fixit PRINT ERRL SUBEND !The error occurred here. The above program prints: 110 ERRM$ The ERRM$ returns information about the last error trapped by an ON ERROR statement. It returns an error message associated with the error number, as listed in Appendix A. Syntax ERRM$ Example 100 110 120 200 210 250 ON ERROR CALL Fixit I=J/0 END SUB Fixit PRINT ERRM$ SUBEND !The error occurred here. The above program prints: Division by zero, or modulo 0.
250 SUBEND The above program prints: 31 EXP ** n. The EXP function returns the value of e number. The result is a REAL Syntax EXP(n ) Parameters n The power that e is to be raised to. Although this can be of any numeric type, it is converted to REAL. Examples 10 A = EXP(0) 20 B = EXP(1) 30 C = EXP(1.0) !A = 1 !B = 2.71828 !C = 2.718281828459 FNUM The FNUM function returns the MPE XL file number of a file. primarily when calling MPE XL file intrinsics.
In the program: 120 ... 180 IF INFO$="Debug" THEN ENDIF In this case, the above block would execute since the expression INFO$="Debug" is true. The INFO$ function can also be used with an HP Business BASIC/XL program file. :RUN Prog1;INFO="Debug" The INFO$ function can be used within Prog1. INT The INT function returns the largest integer that is less than or equal to a specified number. The result is of type INTEGER. Syntax INT(n ) Parameters n The number to be evaluated. numeric type.
Syntax INTERPRETED Examples 10 A=INTERPRETED 20 IF A=1 THEN GOSUB 100 !Control transfers to 100 if this program is interpreted 30 ELSE GOSUB 200 !Control transfers to 200 if this program is compiled . . . INV The INV function returns an array that is the inverse of a specified array. Both arrays must be of the same floating-point type. HP Business BASIC/XL converts a DECIMAL or SHORT DECIMAL array to REAL before computing the inverse.
Parameters fnum The file number that HP Business BASIC/XL uses to identify the file. It is a numeric expression that evaluates to a positive short integer. For this function, fnum must specify a BASIC DATA file. An optional # can precede fnum. Examples 10 11 12 13 14 16 18 19 20 21 99 CREATE "File1", FILESIZE=10 !BASIC DATA file; each PRINT ! statement starts a new record. ASSIGN "File1" TO #1 POSITION #1; BEGIN PRINT #1; 10 PRINT #1; 20,30 DISP ITM(#1) !Pointer at record 1.
expression. nl_num_expr A numeric expression that evaluates to a Native Language ID. If nl_num_expr is -1, the underlying native language number is used as the language specifier. If a non-negative number is used, that number is taken directly as the language specifier. If the native language option is not specified then the option defaults to zero (the underlying native language). The underlying native language specifies NATIVE-3000.
letters to a string containing only lowercase letters. An optional second parameter can be used to specify the native language number. Syntax LWC$ (str_expr [, nl_num_expr ] ) Parameters str_expr A string variable, a quoted string, the value returned from a string function, or any expression using the appropriate string operators to construct a string expression. nl_num_expr A numeric expression that evaluates to a Native Language ID.
any numeric type. Examples 10 A = MIN(3,1,2) !A = 1 MUL The MUL function returns an array that is the result of multiplying two arrays. The arrays being multiplied must be of the same numeric type and the result array must be a different variable than either of the arrays being multiplied. This function has the form: MAT num_array1 = MUL(num_array2,num_array3 ) where num_array1 is num_array2 multiplied by num_array3. the dimensions of each array in different cases. Table 5-6.
32 17 51 55 99 43 53 131 Example 2. 10 DIM A(2,1),B(2,4),C(4,1) . . . 80 MAT A = MUL(B,C) If B is 9 8 7 6 1 2 3 4 and C is 1 2 3 4 then A is 78 42 Example 3. 10 DIM A(1,4),B(1,3),C(3,4) . . . 110 MAT A = MUL(B,C) If B is 6 9 2 and C is 1 2 8 5 7 1 3 7 6 4 2 9 then A is 81 29 79 111 NUM The NUM function returns the ASCII code that corresponds to the first character of a string. This is an integer in the range [0, 255].
Syntax NUMBREAK(level ) Parameters level The summary level number. 9]. This must be in the range [0, Example 100 No_conds = NUMBREAK(level3) 101 !Returns the number of break !BREAK conditions satisfied NUMDETAIL This Report Writer function returns the number of DETAIL LINES with a non-zero totals_flag executed for the given level. This value is reset to zero each time a break occurs at the indicated level. If a report is not active, an error occurs. The level number can be zero.
OLDCV The OLDCV function is a Report Writer function that returns the value of a BREAK WHEN control expression. The value stored is the value the last time a break at the given level (or lower level) occurred. The BREAK WHEN statement at this level must have a numeric control expression. The OLDCV value is not available until report output is started. References to this function before that time generate an error. Syntax OLDCV(level ) Parameters level A summary level number. 9].
S2 $ A string expression indicating the substring. The function returns the position of the first character of S2 $. Examples 10 A = POS("abcde","fg") 20 B = POS("abcde","cd") !A = 0 !B = 3 REAL The REAL function converts a number to a real number. type REAL. The result is of Syntax REAL(n ) Parameters n The number to be converted. type. This can be of any numeric Examples 10 A = REAL(2) !A = 2.0000 REC The REC function returns the number of the record indicated by a file's record pointer.
RESPONSE The RESPONSE function returns information about the method and type of input last entered from the keyboard. The statements listed below affect the value that is returned by this function: * INPUT * LINPUT * TINPUT * ACCEPT * PRESS KEY * FLUSH INPUT Likewise, the actions that are listed below affect the value that is returned by the RESPONSE function: * Pressing any branch-during-input key. * Pressing the HALT key (control Y). * Specifying a HARD HALT.
| 10: | The last previous input is valid. | | | | --------------------------------------------------------------------------------------------| | | | 11: | The input was accepted without a carriage return. The TINPUT and | | | ACCEPT statements allow suppression of the carriage return by | | | specification of the CHARS and NOLF options.
ROTATE The ROTATE function returns the result of moving each bit of a number a specified number of bits. If the number of bits to be moved is positive, the bits move toward the right and if negative, the bits move left. If a bit is rotated past the last bit in the number, it is placed at the other end of the number. That is, the bits wrap around. Syntax ROTATE(N1,N2) Parameters N1 Binary representation of the value of a numeric expression. This is of type short integer.
number of rows is the number of elements. Otherwise, the number of rows is the size of the dimension that is second from the right in the dims of the DIM statement. The result is an integer value by default. Syntax ROW(array ) Parameters array Structured collection of variables of the same type. The structure is determined when the array is declared. String variable names are suffixed with a "$". Examples OPTION BASE 1 is assumed.
Parameters S$ A string expression that contains the string to be concatenated. N The number of times that S $ is to be concatenated. This is of type INTEGER. Examples 20 A$ = RPT$("xy",3) !A$="xyxyxy" RSUM The RSUM function returns an array that contains the sum of the elements of each row of an array. Both arrays must be of the same type. This has the format MAT num_array1 = RSUM(num_array2 ) where element i of num_array1 is the sum of the elements in row i num_array2.
10 A$ = RTRIM("Hi ") !A$ = "Hi" RWINFO The RWINFO function is a Report Writer function that returns various pieces of information that may be useful in controlling the Report Writer. Table 5-8 shows the values returned. If there is no active report, -1 is returned. Table 5-8.
SCAN The SCAN function returns an integer containing the position of the first common character in two strings, scanning from left to right. It returns the position of the character in the first string specified. An optional third string parameter will return that first common character. If the two strings do not have common characters, SCAN returns 0 and the third string returns the null string.
Examples 10 A = SGN(-239) !A = -1 20 B = SGN(9-(3*3)) !B = 0 30 C = SGN(78.8) !C = 1 SHIFT The SHIFT function moves each bit of a number a specified number of places. If the number of places is positive, the bits move to the right, and if negative, to the left. If a bit is shifted out of the number, it is dropped. Syntax SHIFT(N1,N2) Parameters N1 Binary representation of the value of a numeric expression. This is a short integer. This is the number whose bits are to be shifted.
Parameters n The number to be converted. type. This can be of any numeric Examples 10 A = SINTEGER(5.678) !A = 6 SIZE The SIZE function returns the number of records in a file, including unused or empty records. The result is of type INTEGER. Syntax SIZE(fnum ) Parameters fnum The file number that HP Business BASIC/XL uses to identify the file. It is a numeric expression that evaluates to a positive short integer. An optional # can precede fnum.
Syntax SQR(n ) Parameters n The number to be evaluated. This is of type REAL. Examples 10 A = SQR(25) !A = 5 SREAL The SREAL function converts a number to a short real. type SHORT REAL. The result is of Syntax SREAL(n ) Parameters n The number to be converted. type. This can be of any numeric Examples 10 A = SREAL(4) !A = 4.0000 SUM The SUM function returns the sum of the elements in a numeric array.
TAN The TAN function returns the tangent of a number. REAL. The result is of type Syntax TAN(n ) Parameters n The number to be evaluated. This is of type REAL. Examples 10 20 30 A = TAN(50) B = TAN(50) C = TAN(50) !A = 1.19 (Degrees) !B = 1.00 (Grads) !C = -.27 (Radians) TASKID The TASKID function returns the current task number. The task number is the PIN (Process Identification Number) for a process (in this case the PIN for the HP Business BASIC/XL interpreter or the compiled program).
100 110 120 130 140 150 Run_time = TIME(-1) Minute = TIME(0) Hour = TIME(1) Day = TIME(2) Year = TIME(3) Year = TIME(4.8) !Returns clock time since program started !Returns the current minute !Returns the current hour !Returns the current day !Returns the current year !Also returns the current year TIME$ The TIME$ function returns the current system time. The TIME$ function without an argument returns the time in the form "hh:mm:ss".
Syntax TRIM$(S $) Parameters S $ A string expression that is to be trimmed. Examples 10 A$ = TRIM$(" ab ") !A$ = "ab" TRN The TRN function returns an array whose elements are the exchanged rows and columns of a specified array. Both arrays must be the same type. It has the form MAT num_array1 = TRN(num_array2 ) where the rows of num_array1 are the columns of num_array2, and the columns of num_array1 are the rows of num_array2.num_array1 is dimensioned (n,m ) and num_array2 is dimensioned (m,n ).
n The number that is to be evaluated. numeric type. This is of any Examples 10 A = TRUNC(57.571) 20 B = TRUNC(-57.541) !A = !B = 57 -57 TYP The TYP function returns a number that represents the type of the next datum in a file. See Table 5-9 below. Table 5-9.
Syntax TYP(fnum ) Parameters fnum The file number that HP Business BASIC/XL uses to identify the file. It is a numeric expression that evaluates to a positive short integer. Fnum must specify a BASIC DATA file. An optional # can precede fnum. Examples 110 Type = TYP(2) !Type is type of next datum in file 2 UPC$ Function The uppercase function, UPC$, converts a string with any lowercase letters to a string that is entirely uppercase.
Parameters S $ A string expression to be evaluated. If S $ does not start with a legal integer or real number, an error occurs. Examples 10 20 20 A = VAL("12ABC") B = VAL("3.45pq") C = VAL("9.00") !A = 12 !B = 3.45 !C = 9.00 VAL$ The VAL$ function returns the string formed by enclosing a number in quotes. Syntax VAL$(N ) Parameters N A numeric expression that is to be evaluated. be of any numeric type. This can Examples 10 20 A$ = VAL$(12) B$ = VAL$(3.45) !A$ = "12" !B$ = "3.
40 D = WORD("c,a.t","a") !D = 3 WRD The WRD function returns the number of the word indicated by the file's word pointer. The result is of type INTEGER. Syntax WRD(fnum ) Parameters fnum The file number by which HP Business the file. It is a numeric expression a positive short integer. Fnum must DATA file. An optional # can precede BASIC/XL identifies that evaluates to specify a BASIC fnum. Examples 10 11 12 13 14 15 16 17 18 19 99 CREATE "File1",RECSIZE=5,FILESIZE=10 !BDATA file; 10 5-wd recs.
5- 44
Chapter 6 Input and Output Introduction An HP Business BASIC/XL program can receive input from any of the following: * * * A terminal keyboard. An input file. A data file. It can produce output on any of the following: * * * A terminal screen. A printer. A data file. An output statement that specifies the output format produces formatted output; an output statement that does not specify the output format produces unformatted output.
Table 6-1. Keyboard Input Statements --------------------------------------------------------------------------------------------| | | | | Statement | Acceptable Input | Variable(s) to Which Statement | | | | Can Assign Input | | | | | --------------------------------------------------------------------------------------------| | | | | ACCEPT | Characters from ASCII or default | One string variable. | | | foreign character set.
| | | | | | --------------------------------------------------------------------------------------------- Input Prompt This section explains how prompts are displayed when HP Business BASIC/XL is running interactively. Input prompts are not displayed if HP Business BASIC/XL is running in a job stream. A prompt can be supplied for each input element except within a FOR clause. The default prompt is a question mark.
Variable Assignment during Interactive Input When you press RETURN, the INPUT statement assigns the values to the variables specified by the input list. The first value input is assigned to the leftmost variable in the input list, the second value to the next variable, and so on. If you type more values than the number of variables listed in the input list, the INPUT statement ignores the extra values.
* * * Numeric format statements that have the following characteristic: * * Produce output, but do not specify format. Are the BEEP, DISP, and PRINT statements. Specify format for numeric output of the DISP and PRINT statements. Output device specification statements that performs one of the following: * Directs output to specific output devices.
| | | | ---------------------------------------------------------------------------------------------| | | | | Comma | In consecutive output fields. | On consecutive output lines. | | | | | --------------------------------------------------------------------------------------------| | | | | Nothing (it is | In consecutive output fields. | On consecutive output lines.
If n is zero, the following occurs: "LIN (num_expr )" specifies only a carriage return character (zero line feed characters). The next output item is printed at the beginning of line cl (line cl is overwritten). If n is negative, the following occurs: "LIN (num_expr )" specifies -n line feed characters and no carriage return character. The next output item is printed on line cl+(-n), starting at character position cc +1. PAGE The PAGE function returns a form feed character.
If a program contains more than one numeric format statement, the most recently executed statement applies, with one exception: numeric format statements in a subunit are canceled when control returns to the calling program unit.
then all output from the program and the HP Business BASIC/XL interpreter is displayed on the standard list device. If HP Business BASIC/XL is running interactively, the standard list device is the terminal. If HP Business BASIC/XL is running in a job stream, the standard list device is the line printer of the computer system HP Business BASIC/XL is running on. An output specification statement in any program unit affects the entire program.
statement. num_expr2 A numeric expression that evaluates to the number of characters in an output field. num_expr2 is rounded to an integer, n2, called the output field width. The output line begins with n1 DIV n2 output fields of n2 characters each. If n1 MOD n2 is not zero, the output line ends with one output field of n1 MOD n2 characters. For example; a line with margin 75 and output field width 20 begins with three 20-character fields and ends with a 15-character field.
| | numeric expression that is evaluated and rounded to | | | an integer as required. | | | | -------------------------------------------------------------------------------------------- Table 6-9 gives the default margins for different types of destination devices. Table 6-9.
formatted output statements; they specify the output format to be used in printing data. A DISP USING or PRINT USING statement can specify output to format directly in a format string or indirectly by referencing an image statement. The format string or IMAGE statement describes the output format exactly, specifying the following: * * * Type of output. Spacing. Position of the following, if appropriate: * Plus or minus signs. * Radix indicators. * Exponents. * Dollar signs. * Blanks. * Control characters.
Table 6-11. Format Specifiers --------------------------------------------------------------------------------------------| | | | | | Specifier | Specifies | Symbolized by | Can Contain Repeat | | | | | Factor | | | | | | --------------------------------------------------------------------------------------------| | | | | | Numeric | One numeric output | D,Z,*,.,R,S, M,C,P,E | Yes | | | item.
An error occurs if a numeric specifier corresponds to a string value or if a string specifier corresponds to a numeric value. For example, the statement 400 PRINT USING "DDZ.DD"; "GOOD-BYE!" causes an error, since DDZ.DD is a numeric specifier and "GOOD-BYE!"is a string. Numeric Specifiers A numeric specifier specifies the output format for a numeric value. It can contain digit symbols, radix symbols, sign symbols, digit-separator symbols, an exponent symbol, and repeat factors (numeric expressions).
| | | separates integer and | | | | | fractional parts of a number. | | | | | | | --------------------------------------------------------------------------------------------| | | | | | R | Radix | Position of radix. | Radix is a comma (,). | | | | | | --------------------------------------------------------------------------------------------| | | | | | S | Sign | Position of sign symbol (+ or | + is printed if number is | | | | -). | positive; - is printed if | | | | | number is negative.
5Z, 5D, and 5* output a five-digit value the same way (because the value has no leading zeros). The digits in the integer part of a number can be represented by any digit symbol; however, all of the digits must be represented by the same digit symbol, with one exception. The digit in the one's place can be represented by Z, regardless of the symbol that represents the other digits. For example, DDD.DD, ZZZ.DD, ***.DD, DDZ.DD, and **Z.DD are legal. DZD.DD, Z**.DD, and *DZ.DD are illegal.
Examples DISP USING "DD.DD,2X,DDRDD"; 12.34, 12.34 The above statement prints: 12.34 12,34 Sign Symbols. The sign symbols, (S and M), specify the sign character. A numeric specifier can have at most one sign symbol. The sign symbols vary in that: S Prints a plus (+) if the output value is positive, and a minus (-) if it is negative. M Prints a blank if the output value is positive, and a minus if it is negative.
999 END The above program prints: 1234567 1234567 0800342 800342 0001234 1234 0000150 150 1,234.56 12,34,56 1,234,567 1,234,567 0,800,342 800,342 0,001,234 1,234 0,000,150 150 1,234.56 1.234.567 1.234.567 0.800.342 800.342 0.001.234 1.234 0.000.150 150 Exponent Symbol. The exponent symbol, E, specifies scientific notation. A numeric specifier must have at least one digit symbol before the symbol E. The DISP USING or PRINT USING statement prints the output value in the format {+} {+} {-} digit [digit...
Examples Legal: 500 PRINT USING 310 510 IMAGE 30X,"Title" Illegal: 600 PRINT USING "30X,"Title"" If num_expr has the value n of length s, then: If and the corresponding output item is a string DISP USING or PRINT USING statement prints n =s Entire string n s characters of the string Entire string, followed by n-s blanks Examples 99 100 110 120 130 140 150 S$="GOODBYE" DISP USING "7A"; S$ DISP USING "4A"; S$ DISP USING "8A"; S$ DISP USING 140; S$ IMAGE 7A,"TO YOU" DISP USING "4AX3A
The above program prints: 123 .4567 -1.234E+47 123.4567-1.234E+47 cat catbird 123cat.4567bird-1.234E+47 Space Specifiers A space specifier specifies one or more spaces. Syntax [num_expr1 ]X[X]... Parameters num_expr1 Repeat factor. Its value is rounded to a short integer. The specifier nX is equivalent to a sequence of nX symbols. The DISP USING or PRINT USING statement prints one space for every X.
Control Character Specifiers A control character specifier specifies that one or more control characters for carriage return, line feed, or form feed be printed or suppressed. It consists of one symbol: #, +, -, @, or /. Table 6-13 lists the control character specifiers, their positions in the image, (the item that is output) and their effect on the DISP USING or PRINT USING statement. Table 6-13.
prints ABC, followed by a carriage return character but not a line feed character. When the output file is printed on a line printer, xyz is printed over ABC. The statement: 200 DISP USING "DD,@,DD@DD@,@DD"; 12,13,14,15 prints 12, a form feed character, 13, a form feed character, 14, two form feed characters, 15. When the output file is printed on a line printer, 12 is printed on the current page, 13 on the next page, 14 on the next, and 15 two pages after 14.
| | on the command. | on the command. | on the command. | | | | | | --------------------------------------------------------------------------------------------| | | | | | Formatted | No | Yes | No | | | | | | --------------------------------------------------------------------------------------------| | | | | | Input | READ statement, | READ statement. | READ statement. | | | LINPUT statement.
* Its first nonalphabetic character cannot be "$". * It cannot contain the following characters: * comma (,) * semicolon (;) * space ( ) * exclamation point (!) * right parenthesis ()) The format of the file name depends on the operating system. For example, if HP Business BASIC/XL is running on the HP 3000 under MPE XL, the format of fname is filename [/lockword ][.groupname [.accountname ]] where filename, lockword, groupname, and accountname are strings of one to eight alphanumeric characters.
| | | | --------------------------------------------------------------------------------------------| | | | | BDATA | 1242 | HP Business BASIC/V Data | | | | file. | | | | | --------------------------------------------------------------------------------------------| | | | | BDTXL | 1248 | HP Business BASIC/XL Data | | | | file. | | | | | --------------------------------------------------------------------------------------------| | | | | BBNCM | 1249 | MPE/V binary file.
record prior to reading or writing. On a BASIC DATA file, a file I/O operation can also be: direct word Both the record and word pointers are moved to a specific word in the file prior to reading and writing. Refer to Table 6-15 for the data storage and data item descriptor size for each data type in the BASIC DATA file. This is useful for direct record and word I/O to a BASIC DATA file. Table 6-15.
the Native Language Programmer's Guide Language Support or NLS. for more information on Native Selecting a Native Language HP Business BASIC/XL determines the native language number at the start-up of the interpreter and when a compiled program is executed by making the following checks in the order shown: 1. The initial default is NATIVE-3000 (Language #0). 2. The operating system default language is determined by the NLINFO intrinsic. 3.
argument's value is -1, the underlying native language number is used as the language specifier. If a non-negative value is used, that number is taken directly as the language specifier. If the native language option is not specified, then the option defaults to zero. The following functions include parameters for NLS: LWC$ UPC$ LEX DATE$ TIME$ These functions are defined and explained in chapter 5.
Chapter 7 The Report Writer Introduction The Report Writer consists of HP Business BASIC/XL statements that aid in report generation by doing various bookkeeping jobs. In the Report Writer certain control structures cause the statements to be executed at the appropriate times. The PRINT and IMAGE statements specify the actual printing of the report. Report Writer statements are categorized into the following four classes: * Report Writer Section Statements. * Report Writer Block Statements.
WITH and USING Clauses The WITH and USING clauses control the automatic page break mechanism and to aid in the printing of each section. The WITH and USING clauses can occur in all of the Report Writer section statements except END REPORT DESCRIPTION and in the DETAIL LINE statements. These clauses are both optional; however if both clauses occur, the WITH clause must appear first. The USING clause is an implicit Syntax. PRINT USING statement.
If a Report Writer block statement executes when a report is not active, an error occurs. When there is an active report, the direct execution of the statement acts as a comment. These statements execute only when certain other Report Writer statements execute, such as DETAIL LINE.
report. However, once the report output starts, PRINT statements count as lines in the report. The following are Report Writer executable statements: * BEGIN REPORT * DETAIL LINE * TRIGGER BREAK * END REPORT * STOP REPORT * TRIGGER PAGE BREAK * SUPPRESS HEADER * SUPPRESS TRAILER * SET PAGENUM Report Writer Built-in Functions The Report Writer built-in functions have two main purposes. Some of these functions retrieve information Report Writer has kept for you, such as the automatic totals.
| RWINFO (Expression) | Returns various pieces of information that is useful in | | | controlling the Report Writer. | | | | -------------------------------------------------------------------------------------------| | | | TOTAL (Level, Sequence) | Returns accumulated totals. | | | | -------------------------------------------------------------------------------------------- Other Statements The PRINT and PRINT USING statements produce report output after report output has begun.
7-6
Chapter 8 User-Defined Keys Introduction User-definable keys, also called softkeys or programmable function keys, are the eight function keys, f1 - f8, that are on HP terminals. There are nine statements and two functions available in HP Business BASIC/XL that let you define and use these function keys. You have the following two options for specifying the actions to be taken after pressing a user-definable key.
f * SCRATCH KEY - Restores the default key definitions for the terminal. These statements are defined in chapter 4. You can define user-definable keys either before or after entering the interpreter. Consult your terminal reference manual for the method used to set the fields for your terminal's user-definable keys. A field in the configuration file can be set to indicate whether you wish to save the values of the user-definable keys prior to entering the interpreter.
The resulting branch ( GOTO, GOSUB or CALL ) to be taken is specified in the ON KEY statement used to define the branch-during-input key. The definition of the branch-during-input key overwrites the current typing aid definition for that key. However, the HP Business BASIC/XL interpreter remembers the last previous typing aid definition for that key. When an OFF KEY statement for that user-definable key is executed, the typing aid definition is restored.
f Subunits The ON KEY CALL statement is active in all subunits called by the subunit that the statement is in unless the user-definable key is redefined within the called subunit. If the key is redefined, the definition on exit from the called subunit is restored to the ON KEY call that it had upon entry. ON KEY GOTO and ON KEY GOSUB are active only within the subunit that they are in.
Chapter 9 Compiler Introduction The compiler increases execution speed of programs that have been developed using the interpreter. The interpreter is an extremely powerful development tool. It facilitates program creation, modification, and debugging by allowing the programmer to stop and start the program at will, examine or change the values of variables at any time, and trace program execution. The price of this power and flexibility is program execution speed.
* * * All trace statements. All untrace statements. PAUSE statement. When the compiler encounters one of these statements that are primarily for debugging, it issues a warning message and continues. The compiler does not generate code for the statement that caused the warning.
Parameters GLOBAL Allowed only if the statement is in the main block of the program. If GLOBAL appears, the statement is a GLOBAL COPTION statement; if GLOBAL is omitted, it is a COPTION statement. A GLOBAL COPTION statement affects every program unit in the program. A COPTION statement affects only the program unit that contains it. A COPTION statement overrides a GLOBAL COPTION statement, but only while the program unit that contains it is being compiled or executed.
Table 9-1. Listing Options --------------------------------------------------------------------------------------------| | | | | | Option 12 | Effect | Type | Default | | | | | | --------------------------------------------------------------------------------------------| | | | | | LINES [=] num_lit (10 <= num_lit | Sets the number of lines | INLINE | 60 | | <= 9999) | per page for the compiler | | | | | listing.
| | | | | --------------------------------------------------------------------------------------------| | | | | | TITLESUB [=] quoted_str_lit | Substitutes | PROGRAM UNIT | See Note 2. | | | quoted_str_lit in the | | | | | page title at the | | | | | beginning of the subunit. | | | | | | | | --------------------------------------------------------------------------------------------| | | | | | | Enable or suppress | INLINE | WARN | | | compile-time warning | | | | { NOWARN } | messages.
| | | | | --------------------------------------------------------------------------------------------| | | | | | | Level of optimization. | Subprogram | 0 = No | | | | | optimization. | | { 0} | | | 1 = Local | | OPTIMIZE { 1} | | | optimization. | | | | | | | | | | | | | | | The default is 1.
| | error occurs if more than | | | | | num_lit GOSUB statements | | | | | execute before a RETURN | | | | | (in one subunit). Each | | | | | invocation of a subunit | | | | | allocates one word for | | | | | each possible GOSUB. | | | | | | | | --------------------------------------------------------------------------------------------- Table 9-4.
the program. If GLOBAL appears, the statement is a GLOBAL COPTION statement; if GLOBAL is omitted, it is a COPTION statement. A GLOBAL COPTION statement affects every program unit in the program. A COPTION statement affects only the program unit that contains it. A COPTION statement overrides a GLOBAL COPTION statement, but only while the program unit that contains it is being compiled or executed. i_option s_option One of the in-line options listed in Table 9-2.
--------------------------------------------------------------------------------------------| | | | | | | Enables and disables | INLINE | LIST | | | compiler source listing | | | | { NOLIST } | and requested tables. ID | | | | LIST { NO LIST} | TABLES and LABEL TABLES | | | | | can be listed only if | | | | | listing is enabled.
| WARN { NO WARN} | statistics includes a | | | | | count of warnings even | | | | | when warnings are | | | | | suppressed. | | | | | | | | --------------------------------------------------------------------------------------------- Table 9-1 Notes 1 An HP Business BASIC/XL compiler page header consists of a page number followed by a page title; For example: HP Business BASIC/XL Compiler HP32715A.00.00 Copyright Hewlett-Packard Co.
| | Emit or suppress code | INLINE | Code savings | | | that causes a run-time | | vary, but option | | RANGE [ CHECKING] | error when one of the | RANGE CHECKING | NORANGE can save | | | following occurs: | | 12 to 16 words | | { NO RANGE} | | | per array or | | { NORANGE } [ CHECKING] | 1. An array index or | | substring access. | | | a substring index | | | | | is out of bounds. | | | | | | | | | | 2. An integer to | | | | | short integer | | | | | conversion | | | | | overflows. | | | | | 3.
Table 9-4. Other COPTIONS --------------------------------------------------------------------------------------------| | | | | | Option | Meaning | Type | Default | | | | | | --------------------------------------------------------------------------------------------| | | | | | | Allows you to insert a | Program Unit | none | | | copyright statement in | | | | COPYRIGHT=quoted_str | the program. No effect | | | | | on program execution.
| | program accesses a variable before assigning a value to it, no error | | | occurs, but the value of the variable is indeterminate. | | | | --------------------------------------------------------------------------------------------| | | | MAIN | Defines this as the main program of a multi-program application. | | | Outer block is generated.
50 60 70 80 Suit$(1)="spades" Suit$(2)="hearts" Suit$(3)="clubs" Suit$(4)="diamonds" . . . 200 COPTION NORANGE CHECKING 210 FOR I=1 TO 62 220 Deck(I)=I 230 NEXT I . . .
FNPrint$ 1000=000000D4 1090=00000118 1010=000000D4 1095=00000150 1015=000000D4 1020=000000D4 1030=00000100 move_to 2000=000000D0 2005=000000D0 Number of errors = 0 Processor time = 00:00:01 Number of lines = 26 2010=000000D0 2020=000002C0 Number of warnings = 2 Elapsed time = 00:00:02 Lines / CPU minute = 1560.
| v |--------------------------| | | | NMPROG file | | (NMPRG) | |--------------------------| | v RUN STEP | v |--------------------------| | | | Executing | | Program | | | |--------------------------| Figure 9-1. Steps to Compile and Run a Program The compilation step translates a BASIC SAVE file into object code, machine instructions in binary form, and stores those instructions in a relocatable object module in a specially formatted disk file with file code NMOBJ.
| | [ { ,} ] | | | | | [ { ;} LIST[ =]listfile ] | | | | | | | | | | | | | --------------------------------------------------------------------------------------------| | | | | | Compilation | | :BBXLLK [text =] | If progfile is | | Linking | | infile [,[prog=] | not specified and | | | COMPLINK [ infile ] | progfile [,[list=] | command succeeds, | | | | listfile ] ] | then $OLDPASS is | | | { ,} | | the program file.
objfile Name of binary file that the compiler writes the object code into. It can be either an NMOBJ or an NMRL file. The default objfile is $OLDPASS if it exists and is type NMOBJ; otherwise, it is $NEWPASS. If the system uses $NEWPASS as objfile, it changes the name of the file to $OLDPASS when it closes it. To create a new, permanent NMOBJ file, do any one of the following: * Specify a filename that is not in a directory as this parameter.
The main program procedure can be put into an executable library and called as an external subunit. If you compile a program from within the interpreter without specifying the name of the file, the name of the current program will be the name of the main procedure entry point. If the current program does not have a name, BBCINP will be the entry point name. See "Calling External Subunits from Interpreter" later in this chapter for more details.
Line 9-: 20 Result of Executing Line 10 Errsub will handle errors. 600 Control transfers to Extproc. handle errors. 110 Blob will handle errors. 420 Error occurs (division by zero). Blob. 590 Control returns to line 430. 400 Control returns to First_sub (line 610). handles errors again. 610 Error occurs (division by zero). Errsub.
Appendix A Error Messages Numbered Error Messages ( 2 - 216 ) -----------------------------------------------------------------------------------2 MESSAGE CAUSE ACTION 1. 2. Memory overflow. Not enough data space available for the local variables. The system does not have enough memory to run the program. Most probable case is that the program is too big or too many variables are used in the program. Message 1 comes out at run time and message 2 comes out as a verify error.
2. In the interpreter, error occurs because execution of a NEXT in a FOR..NEXT construct does not have a corresponding active FOR. The situation occurs when a branch is made to the middle of a FOR..NEXT construct without execution of the corresponding FOR statement. This message also appears in compiled programs with COPTION RANGE CHECKING selected. This error occurs because execution of a NEXT in a FOR..NEXT construct does not have a corresponding active FOR.
-----------------------------------------------------------------------------------12 MESSAGE CAUSE ACTION Attempt to redeclare a variable, VAR, in line N. An already declared variable VAR is being redeclared in line N. Only declare the variable once. -----------------------------------------------------------------------------------15 MESSAGE Invalid bounds on array dimension or string length. CAUSE Strings or arrays are declared with an invalid bound.
range. CAUSE 1. Most often caused by assigning to a short integer an expression whose value is beyond a short integer (16 bit) range of (-32768, 32767). 2. The value supplied in a CAUSE ERROR statement is beyond the range of a short integer. ACTION Check the expression for accuracy or use another data type. -----------------------------------------------------------------------------------21 MESSAGE SHORT DECIMAL precision overflow.
CAUSE ACTION The call to the log functions contains an invalid argument, in this case a zero quantity. Check the argument for accuracy. -----------------------------------------------------------------------------------30 MESSAGE Argument of SQR is negative. CAUSE The square root function SQR is called with a negative argument. ACTION Check the argument for accuracy. -----------------------------------------------------------------------------------31 MESSAGE Division by zero, or modulo zero.
-----------------------------------------------------------------------------------40 MESSAGE CAUSE 1. Improper REPLACE or DELETE. 2. RENUMBER cannot alter line sequence. 1. Because they affect the structure of the program, some statements may not be deleted or replaced individually. These are the SUB statement and the DEF FN statement. An attempt to replace or delete either of these statements will result in this error. 2.
declared in the main program. Messages four through six only occur when executing a GET in the interpreter. 4. A program that is brought into the interpreter by the GET command contains a COMMON that is larger than the program that contains the GET command. 5. A program that is brought into the interpreter by the GET command contains variables in COMMON that do not match those in the program that contains the GET command. 6.
exists. ACTION 1. Use a different file name or purge the existing file. 2. Use the RESAVE command or SAVE into a new file. -----------------------------------------------------------------------------------55 MESSAGE CAUSE Permanent directory overflow. The file directory is full, no more new files can be created. ACTION Purge some old and unused files. -----------------------------------------------------------------------------------56 MESSAGE File does not exist.
CAUSE ACTION The record size of the HP Business BASIC data file is too small for the numeric data item being output. Re-create the file and increase the record size. -----------------------------------------------------------------------------------62 MESSAGE CAUSE File is protected, wrong lockword/password specified. The wrong lockword has been used in trying to open a protected file. ACTION Use the correct lockword.
CAUSE ACTION A numeric value has been assigned when the format in the IMAGE statement specifies a character format. Change the format specification. -----------------------------------------------------------------------------------102 MESSAGE Format specification too long. CAUSE The output format of an item in an IMAGE statement is longer than the internal buffer can handle. For example, IMAGE DD.DD,510X,K . The specification 510X overflows the internal buffer used for formatted input.
-----------------------------------------------------------------------------------114 MESSAGE Size requested for subunit space is too large. Default size will be used. CAUSE The subunit space size requested is too large (larger than 20000), the default size of 10466 words is used. ACTION None, the default size will be used. -----------------------------------------------------------------------------------115 MESSAGE CAUSE ACTION Too much data space used in this subunit.
ACTION Change the SELECT and CASE statements to use data of the same type. -----------------------------------------------------------------------------------151 MESSAGE CAUSE ACTION This statement cannot occur in this report section The interpreter has detected a statement in a report section that does not belong there. This error is part of error 157, VERIFY error. Delete the statement.
CAUSE A statement that should not appear inside a report definition has been detected. This error is part of error 157, VERIFY error. ACTION Delete the statement. -----------------------------------------------------------------------------------171 MESSAGE CAUSE ACTION Statement can only occur in a SUB. A multi-line function is found to contain a statement that has meaning only in a SUB. For instance, a SUBEXIT statement is in a multi-line function. This error is part of error 157, VERIFY error.
ACTION Add the required closing statement. -----------------------------------------------------------------------------------180 MESSAGE CAUSE ACTION Illegal data in input. An illegal data item has been detected during input. If input data is numeric, this probably means there are non-numeric characters in the data. For string input, it could mean the data is longer than the receiving variable. Check input data for accuracy.
ACTION Delete the illegal specification in question. -----------------------------------------------------------------------------------214 MESSAGE Substring not allowed in IN DATASET statement with SORT. CAUSE The IN DATASET statement used by SORT to locate the sort key contains a substring variable. ACTION Replace the substring variable with a string.
DATASET statements referenced. ACTION Add the key used in an IN DATASET statement. -----------------------------------------------------------------------------------238 MESSAGE CAUSE ACTION Improper PATH or LINK specified in a THREAD statement. The PATH must be a valid path defined in the database schema and the LINK variable, if used, must be the same data type as the key. Use the correct PATH number or LINK variable.
-----------------------------------------------------------------------------------246 MESSAGE The SORTINIT intrinsic failed during SORT. CAUSE The SORT statement encountered some system level problem. ACTION Use the CCODE function to check the condition code returned by SORTINIT and consult the SORT-MERGE/XL General Users Guide for an explanation of the error condition.
CAUSE These are both Report Writer errors: 1. Blank_top or blank_bottom values are greater than the page_length value on the PAGE LENGTH statement. 2. Blank_top or blank_bottom values on the PAGE LENGTH statement are out of range. ACTION 1. (Blank_top + blank_bottom) must be < page_length. 2. Use a value in the range 0 to 255. -----------------------------------------------------------------------------------255 MESSAGE CAUSE 1. Unacceptable value for Report Writer expression. 2.
the page header and page trailer sections is too large for the size of page you are using. ACTION Adjust the line specification on the PAGE LENGTH, PAGE HEADER, or PAGE TRAILER statements so that at least three lines are left on the page after subtracting out blank top, blank bottom, header size, and trailer size. -----------------------------------------------------------------------------------259 MESSAGE Illegal execution of a Report Description section statement.
2. ACTION The level number out of range in TRIGGER BREAK. 1. If a constant is used, change the report definition to use levels 1 thru 9. If an expression is used, this error is reported during BEGIN REPORT execution. Verify that all level number expressions return 0-9. (Level zero cause statement to be ignored.) 2. Check value used by TRIGGER BREAK. Modify program logic or TRIGGER BREAK statement to use 1-9.
-----------------------------------------------------------------------------------270 MESSAGE Cannot redirect or copy output while a report is active. CAUSE A SEND OUTPUT or COPY ALL OUTPUT statement was executed after an active report started printing report output. ACTION Redirect or start copying output before any report output. The following statements will start report output: DETAIL LINE, TRIGGER BREAK, TRIGGER PAGE BREAK, and END REPORT.
being considered consistent. ACTION There may be little that can be done in this case. Call HP for assistance in piecing together your form file. It is helpful to know what changes were made since the last time the form file was consistent. -----------------------------------------------------------------------------------286 MESSAGE Error when writing to form. Form possibly not correctly.
CAUSE The output field pointer is undefined because all the fields on the form have already been written. ACTION Use the CURSOR OFLD(output_field_number) statement to position the output field pointer to the desired field. -----------------------------------------------------------------------------------294 MESSAGE CAUSE ACTION Operation only allowed when a joinform is active. The IFLD, OFLD and CFLD clauses of the CURSOR statement are not legal when a JOINFORM form is not active.
ACTION Reenter a numeric value in the appropriate field in the JOINFORM. -----------------------------------------------------------------------------------320 MESSAGE Invalid item name in PREDICATE statement. CAUSE The value of the item name at the time of execution of the PREDICATE statement is the null string. ACTION Ensure that the value of the string expression that represents the name of the database item to lock in the specified data set is correct.
the minimum length required for the call to the TurboIMAGE library routine. ACTION Rewrite the program, increasing the size of the string variable used with the RETURN clause of the DBERROR statement. -----------------------------------------------------------------------------------800 MESSAGE Data Base Management System error "error_number". CAUSE A TurboIMAGE database error with the error number, "error_number", has occurred.
-----------------------------------------------------------------------------------911 MESSAGE Invalid lockword specified. CAUSE An invalid file lockword was supplied. ACTION A lockword must have no more than eight characters, beginning with an alphabetic character and followed alphanumeric characters. Check that the specified lockword has these characteristics. -----------------------------------------------------------------------------------912 MESSAGE CATALOG's work-file size has been exceeded.
data. CAUSE The range of Native Mode (IEEE) real data is larger than the range of Compatibility Mode (MPE/V) REAL data. ACTION This value can't be represented as a CM real value. Your program logic might allow the CM values closest to zero to be used to represent NM values that are out of CM real range. -----------------------------------------------------------------------------------917 MESSAGE NM-specific real value, such as NaN and Infinity, occurs while converting to CM real value.
ACTION See the appropriate operating system reference manual for more information. -----------------------------------------------------------------------------------1107 MESSAGE CAUSE Program name's File name is missing. This occurs during execution of the :RUN command. file name was given to the SYSTEMRUN command. No program ACTION See the appropriate operating system reference manual for more information.
information. -----------------------------------------------------------------------------------1115 MESSAGE {keyword} must be greater than or equal to {number}. CAUSE This occurs during execution of the :RUN command or SYSTEMRUN command. The value given for parameter of the RUN command is less than the minimum value allowed for that parameter. ACTION See the appropriate operating system reference manual for more information.
CAUSE ACTION This occurs during execution of the :RUN command. See the appropriate operating system reference manual for more information. -----------------------------------------------------------------------------------1122 MESSAGE Out of system resources for program "{program_name}". CAUSE This occurs during execution of the :RUN command. ACTION See the appropriate operating system reference manual for more information.
-----------------------------------------------------------------------------------1130 MESSAGE Could not activate new process for program "{program_name}". CAUSE This occurs during execution of the :RUN command. ACTION See the appropriate operating system reference manual for more information. -----------------------------------------------------------------------------------1131 MESSAGE CAUSE One of "BS", "CS", "DS", or "ES" must come after "PRI=".
SYSTEM "command2" ... It may be that you have simply forgotten the "exit" command and are running into the job's prompt character: :job jobname,user.acct/passwd : :hpbb 10 print "Hi, Mom!" run : :eoj The ":" after the "run" command is read by HP Business BASIC/XL as the HP Business BASIC/XL "SYSTEM" command. In this case, insert an "exit" command between the"run" command and the following ":"... :job jobname,user.
ACTION Look up the error_number in the description of the fcheck intrinsic in the MPE XL Intrinsics Reference Manual for a text description of the problem. -----------------------------------------------------------------------------------1139 MESSAGE CAUSE INTEGER precision overflow. 1. An arithmetic operation involving INTEGER operands has produced a result which is out of the range of an INTEGER (possibly after implicit type conversion to make both arguments have the same type). 2.
CAUSE 1. The interpreter was unable to write to the program file while trying to do a SAVE or RESAVE. 2. The interpreter was unable to mark the indicated file as "run only" when executing the RUN ONLY statement. ACTION Further investigation of this problem is required. contact your Hewlett-Packard representative. Please -----------------------------------------------------------------------------------1143 MESSAGE Can't read from file. CAUSE 1.
CAUSE ACTION Some recent input operation, a read from file or database has resulted in a decimal value being read into a variable with a decimal type that does not have the correct format. In other words, the value in the file has been corrupted. Correct the value in the file or database. -----------------------------------------------------------------------------------1151 MESSAGE CAUSE Cannot RUN a program with OPTION SUBPROGRAM in effect.
SAVE LIST "filename". If this is successful, then do a GET "filename" If you obtained this message trying to run a program, then the run-time data structures used to store the values of variables could not be allocated because of space constraints. Try to reduce the size of large arrays or eliminate unnecessary or unused variables. -----------------------------------------------------------------------------------1155 MESSAGE Unable to open intrinsic file "intr_filename".
CAUSE An ANYPARM external before execution of the main, procedure, or function that contains the ANYPARM call was called before the interpreter has scanned that routine to initialize the internal structures required for the call. ACTION Add a PAUSE statement at the beginning of the main, procedure, or function that contains the call and execute the program. A call from the interpreter can be made when the program executes the PAUSE statement and returns control to the interpreter.
1186 MESSAGE CAUSE ACTION Interpreter BUILD file failure: please PURGE temp files prefixed BBTEMP. Certain HP Business BASIC/XL statements and commands create a file in the temporary file space to store information. HP Business BASIC/XL uses the "BBTEMP" prefix as the first six characters in the temporary filename. If you have created a large number of files with this prefix, HP Business BASIC/XL will be unable to process the information required.
CAUSE One of the following errors occurred when trying to assign the value of a field to a scalar or an element of the array specified in "form_item_number". This happened when a VPLUS form was read with the READ FORM statement. 1. The length of a numeric value in a form field exceeded the maximum length of a numeric literal. 2. There were illegal characters in the numeric literal in the form field. 3.
CAUSE The account or user priority is not set as high as that requested in the PRI clause of the SYSTEMRUN command. ACTION Use a lower priority for the PRI clause or have your System Administrator raise your MAXPRI value. -----------------------------------------------------------------------------------1203 MESSAGE Line number "line_number" does not exist. CAUSE "line_number" specified in a command, for example, LIST 1+10 where line number 1 is not a line in the current program.
to move or copy lines and the range is not sufficient, use RENUMBER to renumber the line immediately following the location to which the lines are targeted, "line_number_2". Renumber to a high enough number to allow sufficient space. -----------------------------------------------------------------------------------1218 MESSAGE CAUSE ACTION Cannot MOVE lines into a subunit which is moving. The actual message is: Lines are not contained in the same subunit.
CAUSE The quoted string literal or the value of the string expression following COMMAND cannot begin with a numeric value. ACTION Change the string so that it begins with a character in the set [a..z] or [A..Z]. -----------------------------------------------------------------------------------1230 MESSAGE CAUSE Tried to delete current line while there are still line ranges left. A program that deletes the current line has been run.
current program. -----------------------------------------------------------------------------------1233 MESSAGE CAUSE Could not add subunit name during GET SUB. Last subunit removed. The interpreter was unable to obtain sufficient space to add the name of a procedure or function during execution of a GET SUB command or statement. ACTION Take action similar to that recommended for error number 1231.
the line range option of the SAVE or RESAVE command when writing to a BASIC SAVE file. ------------------------------------------------------------------------------------ Numbered Error Messages ( 1241 - 1738 ) -----------------------------------------------------------------------------------1241 MESSAGE CAUSE Line range "line_range" contains no lines. Part of the current program was saved or resaved to a BASIC SAVE file using the line range list option.
to an ASCII file using the SAVE LIST or RESAVE command. -----------------------------------------------------------------------------------1245 MESSAGE No SAVE/RESAVE done, program contains no lines. CAUSE There are no lines in the current program to be saved. ACTION Enter a program line in the interpreter prior to doing a SAVE or RESAVE. -----------------------------------------------------------------------------------1246 MESSAGE CAUSE No SAVE/RESAVE done, default file does not exist.
the current program has no lines then RUN; Label will generate this error. ACTION Be certain that the line label specified exists in the current program. -----------------------------------------------------------------------------------1253 MESSAGE CAUSE ACTION Line number is invalid or missing, GET terminated. This occurs in the interpreter only. During the GET of an ASCII file a line in the file has been encountered which does not begin with a numeric literal that should correspond to a line number.
1270 MESSAGE Arrays need to be of the same type. CAUSE The type of the floating point numeric argument to the matrix built-in functions, CSUM, INV, MUL, RSUM, and TRN must be the same as the type of the numeric target of the MAT assignment statement in which the built-in occurs. Both of the arguments to the DOT operation must be the same numeric type. ACTION Coerce the argument prior to performing the built-in operation or coerce the result after the assignment.
BUILD the stdin file "stdin_filename" FILE PFILE="stdin_filename",OLDTEMP FILE LFILE="stdlist_filename",OLDTEMP RESET PFILE RESET LFILE PURGE "stdin_filename",TEMP PURGE "stdlist_filename",TEMP For this set of messages, "error_number" is the error number returned from the command intrinsic indicating the system error encountered. The interpreter must also enter command information into the stdin file.
1276 MESSAGE Invalid KEY number. Must be between 1 and 8. CAUSE The value of a numeric literal or a numeric expression corresponding to one of the keys specified in an ON KEY, OFF KEY, or PRESS KEY statement is not within the range [1,8]. ACTION Correct the value of the numeric literal or, if it is an expression, perform run-time checking of the value of the numeric variable or numeric expression prior to using that value in the statement.
ACTION Re-enter the command followed by one of the valid characters displayed. These characters select which of the ANALYST's screens will be initially displayed. -----------------------------------------------------------------------------------1285 MESSAGE CAUSE ACTION Program Analyst cannot be used when program contains no lines. The ANALYST command has been used when there is no program in the interpreter. Only use the ANALYST when there is a program in the interpreter.
ACTION Use the correct filename for the forms file. -----------------------------------------------------------------------------------1294 MESSAGE Normal Input and Output cannot occur when a VPLUS form is open. CAUSE A PRINT, DISP, INPUT, or similar operation has been executed while a VPLUS form is active. ACTION If a form has been left active inadvertently, then insert a CLOSE FORM statement. Otherwise, use the READ FORM and WRITE FORM statements.
--1341 MESSAGE Native language #"num" is not configured. CAUSE The specified native language is not configured. ACTION You must log on as MANAGER.SYS and run the utility program, LANGINST.PUB.SYS to add the language number to the configuration file. Please refer to the Native Language Programmer's Guide for more information about adding native languages on your system.
CAUSE The native language number specified in the call to TIME$ is less than -1. ACTION Correct the native language number. -----------------------------------------------------------------------------------1414 MESSAGE Language parameter to UPC$ or LWC$ must be >= -1. CAUSE The native language number specified in the call to UPC$ or LWC$ is less than -1. ACTION Correct the native language number in the second parameter.
description of "error-num" returned in the VFIELDEDITS intrinsic. ACTION Please read the ACTION section regarding "error-num" returned in the VFIELDEDITS intrinsic. -----------------------------------------------------------------------------------1421 MESSAGE "error-num" CAUSE An error occurred in one of the HPDialog routines. Please refer to the HPDialog Reference Manual for a detailed description of "error-num" returned. ACTION (HPDERR "error-message").
-----------------------------------------------------------------------------------1499 MESSAGE Catastrophic error in heap management (unable to return heap space). CAUSE This is a heap management problem due to internal problems. ACTION Further investigation of this problem is required. contact your Hewlett-Packard representative. Please -----------------------------------------------------------------------------------1500 MESSAGE Internal consistency check #"num" failed. to HP.
-----------------------------------------------------------------------------------1508 MESSAGE CAUSE ACTION WARNING 1508: MAXDATA increased to DLsize + globsize + STACKsize in program "prog-name". The maximum stack area value, MAXDATA, specified in the SYSTEMRUN statement is smaller than the minimum required to run the program. None. MAXDATA is increased to run the program.
executing. ACTION Change or modify the line when it has finished execution. -----------------------------------------------------------------------------------1605 MESSAGE CAUSE Line "linenum" secured and cannot be modified. The line number specified is secured and cannot be modified. A secured line cannot be listed, only an asterisk is displayed. ACTION Re-enter the line.
-----------------------------------------------------------------------------------1738 MESSAGE Type mismatch for parameter #parm_num, formal parameter type is formal_parm_type while actual parameter type is actual_parm_type. CAUSE The type of the formal and actual parameters do not match. ACTION Correct the actual parameter number parm_num so that it is formal_parm_type type.
-----------------------------------------------------------------------------------1743 MESSAGE Non-numeric or non-scalar actual parameter #parm_num cannot be passed by value. CAUSE The actual parameter number parm_num is either non-numeric or is not a scalar parameter. ACTION Only scalar numeric values can be passed by value. actual parameter so that it is a scalar.
ACTION Reduce the length of the alias name. -----------------------------------------------------------------------------------1750 MESSAGE CAUSE ACTION Formal parameter #parm_num of type parm_type to procedure proc_name has no corresponding Business BASIC/XL data type and no default value. An error occurred while processing the definition of the intrinsic proc_name, specifically while looking up information for formal parameter number parm_num.
ACTION Remove the VALUE keyword from the definition of the formal parameter number parm_num. -----------------------------------------------------------------------------------1756 MESSAGE Intrinsic filename "intr_file_name" exceeds the maximum filename length of max_file_name_length characters. CAUSE An invalid filename has been provided. ACTION Correct the name of the file.
1763 MESSAGE CAUSE ACTION External name provided, proc_name, exceeds the maximum length of max_num_characters . The external name length is too long. Shorten the name so that it is less than max_num_characters in length. -----------------------------------------------------------------------------------1764 MESSAGE Intrinsic intr_name parameter parm_num by reference has invalid address type specification of address_type.
-----------------------------------------------------------------------------------1805 MESSAGE MESSAGE 1805: Statement not implemented in HPBB "char-num") CAUSE The program uses an unimplemented feature. ACTION Do not use the unimplemented feature. ( at character -----------------------------------------------------------------------------------1806 MESSAGE WARNING 1806: Name at character "number" too Truncated. long. Name CAUSE The identifier specified is longer than 64 characters.
ACTION None. -----------------------------------------------------------------------------------1814 MESSAGE CAUSE WARNING 1814: Only one copy of subunit "name" will be saved. Multiple copies of a subunit were saved under the same name. For example > SAVE FILEX, SUB A, SUB B, SUB A ( SUB A is entered twice ) > SAVE FILEX, 10/100, SUB B ( SUB B is already saved in 10/100 ) ACTION None. Only one copy of subunit will be saved.
ACTION Exit Business BASIC and find out what is wrong with HPBBCAT.PUB.SYS. -----------------------------------------------------------------------------------1821 MESSAGE WARNING 1821: Recommend that you exit Business BASIC and retry. CAUSE The message catalog is inaccessible. additional message to warning 1820. This message is an ACTION Exit Business BASIC and find out what is wrong with HPBBCAT.PUB.SYS.
CAUSE A parameter to the compiler options contains an expression. ACTION Only use numbers or quoted strings for parameters in compiler options. -----------------------------------------------------------------------------------2005 MESSAGE ERROR, HALT, or KEY statement found while NO ERROR HANDLING option in effect. CAUSE When COPTION NO ERROR HANDLING is used, ON ERROR, ON HALT, or ON KEY statements cause a compile time error.
2013 MESSAGE Total space needed for parameters is too big. CAUSE The number or size of parameters to the subunit exceeds the limit. ACTION Reduce the number or size of parameters to the subunit. -----------------------------------------------------------------------------------2014 MESSAGE CAUSE ACTION Total space needed for DATA is too big. The number or size of values in the DATA statements exceeds the limit. Reduce the number or size of values in the DATA statements.
30 MAT READ A(1,1) ! ACTION attempt to redim. A Change the compiler option or change the statements so that no redimensioning is done. -----------------------------------------------------------------------------------2021 MESSAGE BASIC Compiler Backend Error: [in procedure proc_name] 'Actual backend error message.' Fatal compiler error; compile terminated. CAUSE A problem has been detected by one of the code generating subsystems of the compiler.
** MESSAGE File file_name has invalid record size. Expected 128W records ( 5383 ) CAUSE The object code file specified in the command to run the compiler is an RL file with an NMRL file code that does not have 128 word records. ACTION Check the record length for the file named file_name or the file specified by you as the object code file. BBCOBJ is the file that the compiler uses after it has been equated to your file. Build a new RL file using the linkeditor.
CAUSE REDIM compiler option. A matrix operation that might cause an implicit redimensioning of an array will generate this warning message at compile time. For example, 10 COPTION NOREDIM 20 DIM A(4,2), B(2), C(5) 30 MAT C = MUL(A,B) ! C may be redimensioned ACTION None, if you know exactly how the array will be redimensioned. Otherwise, the results will be unpredictable when the array is redimensioned. The compiler will not generate code to check the array bounds with COPTION NOREDIM.
2101 MESSAGE An unknown arithmetic error occurred. CAUSE This is caused by an internal problem. ACTION Further investigation of this problem is required. contact your Hewlett-Packard representative. Please -----------------------------------------------------------------------------------2103 MESSAGE CAUSE Attempt to execute a noncompilable statement.
CAUSE This is a substitute message for error number 68. One or more of the clauses following an HP Business BASIC/XL database keyword is missing. ACTION Check the syntax of the database statement in the Help Catalog or the HP Business BASIC/XL Reference Manual to be certain that you are using the correct syntax. ----------------------------------------------------------------------------MESSAGE The line number is not between 1 and 999999. CAUSE This is a substitute message for error number 68.
----------------------------------------------------------------------------MESSAGE A number between 0 and 255 must follow ' in the string. CAUSE A single quote was encountered in a string literal and was not followed by a digit. ACTION Determine the correct ASCII character number for the desired character and place it after the '. ----------------------------------------------------------------------------MESSAGE Unknown character " " found (ASCII nnn).
CAUSE A variable has been used to declare the array size or the string length in a string array declaration, and this is not allowed in MAIN. ACTION Declare the array dimension or the string length explicitly in MAIN. ----------------------------------------------------------------------------MESSAGE Improper string length declaration. CAUSE A variable instead of a constant has been used to declare the length of a string declaration in MAIN. ACTION Declare the sting length explicitly in MAIN.
MESSAGE Only =, >=, and <= are allowed here. CAUSE An invalid relational operator was specified in the PREDICATE statement. ACTION Check the relational operator. in the PREDICATE statement. Only =, >=, and <= are allowed ----------------------------------------------------------------------------MESSAGE Illegal line number: ! CAUSE GET (of an ASCII file), LINK, or MERGE has created a line reference that is greater than 999999. ACTION Renumber using a lower line number.
----------------------------------------------------------------------------MESSAGE New array bounds must be specified in REDIM statement. CAUSE New array dimensions were not specified in a REDIM statement. ACTION Specify the new array bounds. ----------------------------------------------------------------------------MESSAGE Undefined variable or improperly used keyword. CAUSE A line has been entered for immediate execution that has an unknown identifier.
Appendix B Statement Groups Table B-1 is a list of Business BASIC/XL statements, grouped by functionality. Each statement is defined and explained in chapter 4. Table B-1. Functional List of HP Business BASIC/XL Statements.
| | PACK | | | PACKFMT | | | PREDICATE | | | SEARCH | | | SORT | | | SORT ONLY | | | THREAD IS | | | UNPACK | | | WORKFILE IS | | | | -----------------------------------------------------------------------------------| | | | Data Files | ADVANCE | | | ASSIGN | | | LINPUT | | | LOCK | | | POSITION | | | PRINT | | | READ | | | UNLOCK | | | | -----------------------------------------------------------------------------------| | | | External Routines and Intrinsics | EXTERNAL | | | INTRINSIC | | | SETLEN | | |
| | | | JOINFORM | ACCEPT | | | CLEAR FORM | | | CLOSE FORM | | | CURSOR | | | DISP | | | ENTER | | | INPUT | | | LDISP | | | LENTER | | | LINPUT | | | OPEN FORM | | | PRINT | | | | -----------------------------------------------------------------------------------| | | | Operating System Access | SYSTEM | | | SYSTEMRUN | | | | | | | -----------------------------------------------------------------------------------| | | | Report Writer | BEGIN REPORT | | | BREAK IF | | | BREAK WHEN | | | DETAIL LINE | | |
| | | | User-definable Keys | CURKEY | | | DISABLE | | | ENABLE | | | GET KEY | | | OFF KEY | | | ON KEY | | | PRESS KEY | | | RESAVE KEY | | | SAVE KEY | | | SCRATCH KEY | | | | -----------------------------------------------------------------------------------| | | | Variable Operations | COM | | | CONVERT | | | DATA | | | DEFAULT OFF | | | DEFAULT ON | | | DIM | | | OPTION | | | READ | | | RESTORE | | | | ------------------------------------------------------------------------------------ B- 4
Appendix C HP Business BASIC/XL Configuration Utility The configuration file (HPBBCNFG.PUB.SYS), supplied with HP Business BASIC/XL, is a convenient way of supplying defaults to HP Business BASIC/XL for the language features shown in Table C-1 at the end of this appendix. The HP Business BASIC/XL configuration utility (CNFGHPBB.PUB.SYS) is a program that allows you to create and change configuration files.
How to Run the Configuration Utility To run the configuration utility, issue the MPE XL command: :RUN CNFGHPBB.PUB.SYS The configuration utility looks for the file, HPBBCNFG.PUB.SYS. To create or change a configuration file that has another name, you must set up a file equation before running the configuration utility. For example: FILE HPBBCNFG.PUB.SYS = HPBBCNFG.mygroup.myacct If the file is not found, it is created (assuming that you have the required capabilities).
Appendix D ASCII Character Codes Table D-1 maps each ASCII character to its decimal and hexadecimal code, its symbol, and its name. Each code is stored in eight bits; so the decimal codes are in the range [0, 255] and the hexadecimal codes are in the range [0, FF]. Table D-1.
Table D-1.
Table D-1.
Table D-1. ASCII Character Codes (continued) --------------------------------------------------------------------------------------------| | | | | | Decimal | Hexadecimal Code | Symbol | Name | | Code | | | | | | | | | --------------------------------------------------------------------------------------------| | | | | | 46 | 2E | .
Table D-1.
Table D-1.
Table D-1.
Table D-1.
Appendix E HP Terminals and Language Features This appendix contains information about HP terminals that are fully and partially compatible with HP Business BASIC/XL's terminal-specific language features. Redirecting output can make a terminal appear to HP Business BASIC/XL as a batch job.
The following terminals are compatible with all of the JOINFORM statements listed in Appendix F: E- 2 150 2382 2393A 2394 2392 2397
Appendix F JOINFORM JOINFORM Statements JOINFORM is a FORMS/260 compatible forms package available in HP Business BASIC/XL. The JOINFORM package cannot be accessed by any other languages on the HP 3000. Use of JOINFORM is supported only on the HP150 and HP239X Terminals. It is intended to provide an easy-to-use alternative to VPLUS forms for HP260 users converting their applications. OPEN FORM OPEN FORM opens a form file. It tries to find form_member_name in form_file_name if a form file is specified.
Syntax CLEAR FORM [[WITH] DEFAULT[S]] Examples 150 CLEAR FORM !Clears all fields CLOSE FORM CLOSE FORM deactivates and erases the form that is currently active. If no option is specified, the form is erased by deleting all lines occupied by the form, so the lines following the form are moved up on the screen. Use the CLEARREST option to clear the form by clearing display memory from the first line of the form to the end of display memory.
SETOFLD, SETCFLD field_number type of field indicated. The number of the field that the cursor will move to. Examples 100 CURSOR OFLD (35) 110 CURSOR SETIFLD (4) !Moves cursor to output field 35. !Sets the input field pointer to field 4. TFLD TFLD is a built-in numeric function that returns the field number of the last input field accessed in the form. The cursor pointer is moved either by a CURSOR IFLD(), CFLD(), or an INPUT statement.
Syntax LDISP [d_list ] Parameters [{,...} ] [{; } output_item ]... d_list [,]...output_item_list output_item One of the following: num_expr str_expr array_name(*) output_function Array reference. See "Array References in the Output Item List" in chapter 6 for more information. {PAGE {{CTL} {{LIN} {{SPA} (num_expr {{TAB} } } } )} } See "Output Functions in the Display List" in chapter 6 for more information.
The syntax for the INPUT statement is in chapter 4. LINPUT When LINPUT is executed and a JOINFORM is active, the current cursor position in screen memory is determined. If the cursor is within the form, LINPUT moves it to the first unprotected line following the form. Otherwise, the cursor stays where it is (usually positioned by a previously executed CURSOR statement). Then LINPUT outputs a line-output prompt.
XL.PUB.SYS. Before using BB_BLOCK_READ, be aware of the following considerations: * * * * BB_BLOCK_READ can lead to hard-coding dependencies on form layout (such as field length and order). BB_BLOCK_READ reads all unprotected fields on the screen each time it is called; input and input/output JOINFORM fields are read. The characters from the fields are read into a single string. The string must be large enough to hold all data from all fields plus one byte per field as a record separator.
capabilities: * Creating HP 260-type forms. * Modifying HP 260-type forms. * Copying and moving forms between files. * Deleting HP 260-type forms. * Displaying forms on a workstation screen. * Printing forms. To run the JOINFORM Editor, type RUN JOINEDIT.PUB.SYS at the MPE XL prompt. The Main Menu screen will be displayed. Each of the capabilities of the JOINFORM Editor is described in the following sections.
Setting Field Order and Individual Field Enhancements. After creating the fields, the frame, and the text, press the ENTER FORM softkey to display the softkeys that control field order and enhancements. Your screen will be displayed. The softkeys at the bottom control enhancements and order. You can make changes to the form layout (frame, fields and text) by pressing the CHANGE LAYOUT softkey. The cursor will be positioned at the bottom of the screen in the only active line on the screen.
keys destroys any changes you have made to the enhancements or access order. Storing the Form to Disk. When you are satisfied with the appearance of the form, press the EXIT softkey. The screen that is displayed prompts you for the name for the new form. After naming it, press the SAVE FORM softkey to store the form to disk. If you are not satisfied with the form, you can press the BACK TO EDITING softkey to return to the previous screen to further edit the form.
"Creating New Forms" for details. To modify the form frame, length or number of fields, or text in the form, press the CHANGE LAYOUT softkey, and refer to "Creating New Forms from Existing Forms" in the previous section. When you are adding, deleting, or moving fields while modifying forms, the JOINFORM Editor does not reorder them. The effect of these changes is as follows: * The previous field order remains valid for each field that has not been moved from its original location.
Once the merge has begin, the name of each form is removed from the display after it has been successfully merged. Deleting Forms Forms can be deleted one at a time or in groups, from a list. deleting forms, enter the JOINFORM Editor. To start Use the following steps to delete forms: 1. To delete a single form, use the TAB key to position the cursor at the field just past f5 DELETE FORMS, FORM IS. 2. Type the name of the form to be deleted. 3.
* Output order. * Row of screen in which field appears. * Position of field in that row. You can display a list of the forms in a particular file. Type the name of the file in the FILE NAME: field, but leave the FORM NAME: field blank. Press the SHOW DIRECTORY softkey. 90 forms are displayed at one time. Use the PREV PAGE and NEXT page softkeys to see more forms. To print a list of forms to your printer, press the PRINT DIRECTORY softkey instead of the SHOW DIRECTORY softkey.
alphanumeric character that will become the fill character in the to field for that parameter. To change the enhancements, type in any of the enhancement symbols at the bottom of the screen in the to field for that parameter. Press the SAVE NEW VALUES softkey when you have completed changing the default parameters. If you press the EXIT softkey before saving the new values, those changed values will be lost.
f: 14
Appendix G ANYPARM External Call Feature Introduction The HP Business BASIC/XL ANYPARM external feature is used with programs that were originally written in BASIC/V. Although calls to externals are easy to code in an HP Business BASIC/XL program, understanding and writing the externals that use the ANYPARM interface are more difficult than for normal externals. Therefore, use the ANYPARM external only when the HP Business BASIC/XL normal external call interface is too restrictive.
| | | | A Pascal ANYPARM | This section is an example program and a memory display of a | | Procedure Designed to | call from HP Business BASIC/XL to an external procedure. The | | Process Any Parameter | example demonstrates how to call an ANYPARM external that is | | | capable of processing any of HP Business BASIC/XL's data types.
* The address of the value of each actual parameter stored in the format specified by that parameter's HP Business BASIC/XL data type. * The type of the parameter at that address. * A value indicating whether the parameter is a scalar or, if it is an array, the number of dimensions. Data Structures in HP Business BASIC/XL In order to correctly manipulate the actual parameters, it is important to have a thorough understanding of the data structures that HP Business BASIC/XL uses.
described in this section is used to transfer execution control to externals declared in an ANYPARM EXTERNAL statement. Explicit declaration of procedures to be called by the ANYPARM method allows you to specify additional options concerning the scope and name of the external. External procedures can be declared in the main subunit of the program to be GLOBAL to the entire program. Otherwise, the external declaration is local to the subunit in which it is declared.
of other EXTERNALS. Syntax CALL ap_external_name [( actual_param_list )] Parameters ap_external_ name act_param_list An HP Business BASIC/XL identifier declared in an ANYPARM EXTERNAL or GLOBAL ANYPARM EXTERNAL declaration. The list of actual parameters to be passed to the external procedure. When more than two actual parameters are present in the list, each is separated from the next by a comma. Two consecutive commas are not valid.
Parameters ap_external_ name A valid HP Business BASIC/XL identifier that is the name of the external procedure in the executable library to be called. The maximum length of the name of the external is 60 characters. The entry point name is ap_external_name in lower case unless the external is explicitly declared with an ALIAS clause. act_param_list Same as the actual parameter list, act_param_list, in the CALL ap_external_name statement.
20 CALL Test2 ! Call is made to Test1 30 _Test2 ! Implicit local declaration Call is made to Test1 In the following example, the explicit local declaration takes precedence over the explicit global declaration.
BASIC/XL array. The data type and dimensionality information are contained in the flag word that immediately follows the address of the actual parameter.
The data structure that HP Business BASIC/XL uses to store strings consists of two parts: 1. A dope vector that (in the MPE XL environment) consists of one 4 byte word to indicate the maximum number of characters allowed in the string (the declared length) and one 4 byte word to indicate the actual number of characters currently in the string. 2. The characters in the string. The address that is passed to an ANYPARM EXTERNAL is the address of the dope vector, not the address of the first character.
Address in the actual parameter table references | | +---------------------------------------+ -----> | address of beginning of data area |----|---------------------------------------| | | total number of elements | | |---------------------------------------| | | number of elements in dim 1 | | |---------------------------------------| | | lower bound of dim 1 | | |---------------------------------------| | | . | | | . | | | .
Figure G-1.
Example of a Simple Pascal ANYPARM Procedure This section contains a Pascal procedure that can be called from HP Business BASIC/XL using the ANYPARM call interface. This procedure shows how to define the actual parameter table that the ANYPARM call requires. It also contains an example procedure that accepts the actual parameter table as a formal parameter.
const c_max_num_parameters = 50; type t_parameter_record = packed record param_address : tp_scalar_value; param_type : shortint; number_of_dimensions: shortint; end; t_actual_parameter_array = array [1..
{-----------------------------------------------------------} for param_index := 1 to num_params do begin {for loop processing of the actual parameters } write( tstfil, param_index:3, ' ' ); if p_actual_param_table^[param_index].number_of_dimensions = 0 then begin {process scalar actual parameters } with p_actual_param_table^[param_index].param_address^ do {sinteger_value} {integer_value } case p_actual_param_table^[param_index].
100 110 120 121 130 131 140 150 151 160 Sint1=-32768 Sint2=32767 CALL Example(Sint1,Sint2) ! a call with two short integer parameters CALL Example(Real1,Int_arr(*,*)) ! invalid real and array parameters Int_arr(2,2)=100000 CALL Example(Int_arr(2,2)) ! a call with an array element parameter CALL Example(Sint1,Int_arr(1,1),Int2,Sint2,Int1,& (Sint1),(Sint1+Sint2),& Int_arr(2,2),(Int1+Sint2),"Beginning of invalid parameters",& Str$,Real1,Int_arr(*,*)) >run Number of parameters passed to Number of parameters p
and prints error messages for all other entries in the actual parameter table. */ simple_example(num_params, p_actual_param_table) int num_params; struct parameter_record p_actual_param_table[]; { int param_index; printf("Number of parameters passed to SIMPLE EXAMPLE is:%3d\n", num_params); if (num_params > C_MAX_NUM_PARAMETERS) { printf("Too many actual parameters passed to SIMPLE EXAMPLE.
c_bytes_per_pointer c_bytes_per_integer c_bytes_per_32_bit_word c_bytes_per_16_bits = = = = 4; 4; 4; 2; {----------------------------------------------------------------------------} { t_basic_data_types } { An enumerated type that associates a data type with a value. Used as a } { field selector for variant records to associate the relevant variant with } { the data type.
{ { { { { { { { { { { { { { { { The second variant of the record is designed to serve as a record overlay to access each of the decimal digits of the DECIMAL value. The digits are stored in elements 1 to 12 of the array.
{ [1] |<-digits[-1] ->|<- digits[0] ->|<- digits[1] ->|<- digits[2] ->| } { |===============================================================| } { [2] |<- digits[3] ->|<- digits[4] ->|<- digits[5] ->|<- digits[6] ->| } { |===============================================================| } { } { NOTE: By definition, if shortint_rep[1] = 0 then the value of the SHORT } { DECIMAL number stored at that location is zero.
$page$ {----------------------------------------------------------------------------} { t_basic_scalar_type } { Definition of a variant record for which the representation of the data } { can be selected when the data type of the value is known.
{----------------------------------------------------------------------------} { Definition of the maximum size and dimensions of each array type.
t_basic_array_type = record case t_basic_data_types of basic_sinteger_type : ( sinteger_array : t_bas_sinteger_array ); basic_integer_type : ( integer_array : t_bas_integer_array ); basic_short_decimal_type : ( short_decimal_array : t_bas_short_decimal_array ); basic_decimal_type : ( decimal_array : t_bas_decimal_array ); basic_short_type : ( short_array : t_bas_short_array ); basic_real_type : ( real_array : t_bas_real_array ); basic_string_type : ( word_view : t_string_word_view ); end; { record t_basic_a
c_real_type = 13; $page$ {----------------------------------------------------------------------------} { The Actual Parameter Table } { An array of records describing the address, type and dimensionality of } { each of the actual parameters. t_parameter_record, a record which } { contains fields for the address, type and dimensionality of a single } { actual parameter in the actual parameter table, is defined. } { t_short_basic_string_type is defined to allow processing of strings.
{ as the formal parameter to the procedure. The actual parameter table } { contains addresses referencing any of the data types. The referenced } { values can be either scalars or arrays. The procedure will print the data } { type of the value and the value itself to a file named TESTFILE. TESTFILE } { must be created before calling this procedure. Testfile should be created } { as an ASCII file with a fixed record length of 80 bytes.
$title 'PROCESS_STRING_ARRAY of ANYPARM_EXAMPLE',page$ {----------------------------------------------------------------------------} { procedure process_string_array of anyparm_example } {----------------------------------------------------------------------------} procedure process_string_array( p_actual_param_table : tp_actual_parameter_array; param_index : integer; var tstfil : text ); const c_2_spaces = ' '; type t_pascal_string = string[c_max_str_len]; tp_pascal_string = ^t_pascal_string; var array_el
end end end; { processing individual strings } { with } { procedure process_string_array } $title 'PROCESS_ARRAY of ANYPARM_EXAMPLE',page$ {----------------------------------------------------------------------------} { procedure process_array of anyparm_example } {----------------------------------------------------------------------------} procedure process_array( p_actual_param_table : tp_actual_parameter_array; param_index : integer; var tstfil : text ); const c_2_spaces = ' '; var array_element_num
, array_element_num:3 , c_2_spaces ); {----------------------------------------------------------------} { Check to ensure that there will not be a numeric overflow when } { the decimal value is converted to a real. } {----------------------------------------------------------------} if ( decimal_array[array_element_num].decimal_rep.exponent > -308 ) and ( decimal_array[array_element_num].decimal_rep.
otherwise writeln( tstfil,'error in passed type') end { case } end { with } end; { procedure process_array } $title 'PROCESS_SCALAR of ANYPARM_EXAMPLE',page$ {----------------------------------------------------------------------------} { procedure process_scalar of anyparm_example } {----------------------------------------------------------------------------} procedure process_scalar( p_actual_param_table : tp_actual_parameter_array; param_index : integer; var tstfil : text ); var temp_real : longre
temp_integer := sinteger_value; writeln( tstfil, 'SHORT INTEGER end; { short integer } c_integer_type: writeln( tstfil, 'INTEGER c_short_real_type: writeln( tstfil, 'SHORT REAL c_real_type: writeln( tstfil, 'REAL c_whole_string_type: writeln( tstfil, 'STRING ', temp_integer:1 ); ', integer_value:1 ); ', short_value ); ', real_value ); ', string_value.
if p_actual_param_table^[param_index].number_of_dimensions > 0 then process_array( p_actual_param_table, param_index, tstfil ) else process_scalar( p_actual_param_table, param_index, tstfil ) end end; { for loop processing of the parameters } { anyparm_example's actual parameter array is large enough } writeln( tstfil, 'exiting anyparm_example' ); end; { anyparm_example } begin end. The ANYPARM Call Assume that the Pascal program presented in the previous section is in the file, ANYPROG.
Figure G-2. Memory Layout The Results of Program Execution The first call to the external from within the interpreter will require substantially more time than subsequent calls. The reason is that the external procedure must be dynamically loaded before it can be called. Subsequent calls do not need to reload the external. The amount of time required to do the initial load is dependent on the size of the external being loaded.
>run hello from the external example the total number of parameters passed to example is: param type ----- -----------1 REAL 1.2300000000000L+45 2 STRING ANYPARM 3 SHORT INTEGER Array 0 1 1 2 2 3 3 4 exiting example > 3 Differences Relative to BASIC/V For those users familiar with BASIC/V's external procedure call feature, this section describes the differences between that feature and HP Business BASIC/XL's ANYPARM feature, and explains some of the reasons for the differences.
HP Business BASIC/XL Reference Manual HP Business BASIC/XL Reference Manual Printed in U.S.A. 900 Series HP 3000 Computer Systems HP Part No. 32715-90001 Edition First Edition Printed Oct 1989 E1089 ________________________________________________________________________ |The information contained in this document is subject to change | |without notice.
Additional Documentation Refer to the following manuals for further information on the MPE XL operating system, HP Business BASIC/XL and the IMAGE Database Management System: * * * * * * * * * * * MPE XL Commands Reference Manual (32650-9003). MPE XL Intrinsics Reference Manual (32650-90028). HPLink Editor/XL Reference Manual (32650-90029). Accessing Files Programmer's Guide (32650-90017). TurboIMAGE/XL Database Management System (30391-90001). SORT-MERGE/XL General User's Guide (32650-90082).
Appendix C Explains the HP Business BASIC/XL Configuration Utility, which establishes default values for HP Business BASIC/XL. Appendix D Gives the decimal and hexadecimal codes for the ASCII characters. Appendix E Describes the HP terminals and language features. Appendix F Explains JOINFORM, the FORMS/260 compatible forms package. Appendix G Contains a technical discussion of the ANYPARM External Call Feature.
p- 4