Supported On | UX WS |
Option Required | None |
Keyboard Executable | Yes |
Programmable | Yes |
In an IF ... THEN ... | Yes |
FBYTE returns 1 when the first byte of a string expression is a valid first byte in the HP-15 character set. The HP-15 character set is used by versions of HP BASIC that support certain two-byte languages, such as Japanese.
IF FBYTE(A$) AND SBYTE(A$[2]) THEN Valid_Kanji
Certain localized versions of HP BASIC, such as Japanese localized HP BASIC, use two-byte characters. Together, FBYTE and SBYTE allow you to programmatically determine whether a character is one or two bytes long. Note that FBYTE only checks the first byte of the string expression. If FBYTE returns 1 (true), you must also test the second byte of the string using SBYTE to determine if the second byte is in the valid range for HP-15 characters.
For a general discussion of globalization and localization including two-byte characters, refer to HP BASIC Porting and Globalization. To determine the values returned by FBYTE for specific characters, refer to Using LanguageX with HP BASIC, where LanguageX is your local language.
FILL is a secondary keyword used to create shading with these graphics keywords:
Supported On | UX WS DOS |
Option Required | EDIT and PDEV |
Keyboard Executable | Yes |
Programmable | No |
In an IF ... THEN ... | No |
FIND lets you find a character sequence while editing a program.
FIND "SUB Printer"FIND "Cost=" IN 1550
FIND "Target" IN Label1,Label2
Item | Description | Range |
---|---|---|
text | literal | -- |
beginning line number | integer constant identifying program line | 1 to 32 766 (1 through 2 147 483 646 for HP BASIC/UX 700) |
beginning line label | name of a program line | any valid name |
ending line number | integer constant identifying program line | 1 to 32 766 (1 through 2 147 483 646 for HP BASIC/UX 700) |
ending line label | name of a program line | any valid name |
This command causes a search through the program currently in memory. It compares the specified text to an internal "listing" of the program. Therefore, line numbers, keywords, variables, and constants can be found.
lf an the specified text is found, the line containing it is displayed with the cursor under the first character of that occurrence. The line can be modified or deleted if desired.
lf [ENTER], [Return] or the delete line key is pressed, the search resumes with the next character. Alternately, the search is resumed without modifying the program when [CONTINUE] is pressed. Overlapping occurrences are not detected; e.g., if you were looking for "issi", only one occurrence would be found in "Mississippi".
If the beginning line number is given, the search begins at that line number. If the specified line number doesn't exist, the next line that does exist is used. If the beginning line number is not specified, the search begins at the line currently being edited; or, (if you're not in edit mode), with the first line of the program. If a specified label doesn't exist, an error occurs.
The search continues through the last character of the Ending Line; or (if that was not specified) the end of the program. If you specify an Ending Line Number that does not exist, the highest numbered line which occurs before that line number is used.
If there were no occurrences found, the cursor is left at the end of the first line searched. If one or more occurrences were found, the cursor is left at the end of the line containing the last occurrence.
A FIND command is canceled by entering a line after changing its line number. Other keys which will cancel a FIND are [EXECUTE], [CLR I/O], [Break], [&up;], [&down;], or [INS LN]. Any of the keys which cancel EDIT mode will also cancel a FIND (with the exception of [CONTINUE]).
FIND is not allowed while a program is running; however, it may be executed while a program is paused. The program is continuable if it has not been altered by pressing [ENTER], [Return], [EXECUTE] or [DEL LN].
While in the FIND mode, keyboard execution is only possible with the [EXECUTE] key. Using [ENTER] or [Return] causes an error.
Supported On | UX WS DOS IN |
Option Required | None |
Keyboard Executable | Yes |
Programmable | Yes |
In an IF ... THEN ... | Yes |
FN transfers program execution to the specified user-defined function and may pass items to the function. The value returned by the function is used in place of the function call when evaluating the statement containing the function call.
PRINT X;FNChange(X)
Final$=FNStrip$(First$)
Parameter=FNProcess(Reference,(Value),@Path)
R=FNTrans(Item(Start+Offset),Lookup(*))
Item | Description | Range |
---|---|---|
function name | name of a user-defined function | any valid name |
I/O path name | name assigned to a device, devices, or mass storage file | any valid name (see ASSIGN) |
variable name | name of a numeric or string variable | any valid name |
substring | string expression containing substring notation | (see Glossary) |
literal | string constant composed of characters from the keyboard, including those generated using the ANY CHAR key | -- |
numeric constant | numeric quantity expressed using numerals, and optionally a sign, decimal point, or exponent notation | -- |
A user-defined function may be invoked as part of a stored program line or as part of a statement executed from the keyboard. If you type the function name on the command line and then press [EXECUTE], [ENTER], or [Return], [ENTER] or [Return], the value returned by the function is displayed. The dollar sign suffix indicates that the returned value will be a string. User-defined functions are created with the DEF FN statement.
The pass parameters must be of the same type (numeric or string) as the corresponding parameters in the DEF FN statement. Numeric values passed by value are converted to the numeric type (REAL, INTEGER, or COMPLEX) of the corresponding formal parameter. Variables passed by reference must match the type of the corresponding parameter in the DEF FN statement exactly. An entire array may be passed by reference by using the asterisk specifier.
Invoking a user-defined function changes the program context. The functions may be invoked recursively.
If there is more than one user-defined function with the same name, the lowest numbered one is invoked by FN.
Supported On | UX WS DOS IN |
Option Required | None |
Keyboard Executable | Yes |
Programmable | Yes |
In an IF ... THEN ... | Yes |
FNEND is the last statement of a function subprogram. Control is actually transferred back to calling context by a RETURN statement. See DEF FN.
FNEND
Supported On | UX WS DOS IN |
Option Required | None |
Keyboard Executable | No |
Programmable | Yes |
In an IF ... THEN ... | No |
FOR...NEXT defines a loop which is repeated until the loop counter passes a specified value. The step size may be positive or negative.
100 FOR I=4 TO 0 STEP -.1
110 PRINT I;SQR(I)
120 NEXT I
1220 INTEGER Point
1230 FOR Point=1 TO LEN(A$)
1240 CALL Convert(A$[Point;1])
1250 NEXT Point
Item | Description | Range |
---|---|---|
loop counter | name of a numeric variable | any valid name |
initial value | numeric expression | -- |
final value | numeric expression | -- |
step size | numeric expression; Default = 1 | -- |
program segment | any number of contiguous program lines not containing the beginning or end of a main program or subprogram, but which may contain properly nested construct(s). | -- |
The loop counter is set equal to the initial value when the loop is entered. Each time the corresponding NEXT statement is encountered, the step size (which defaults to 1) is added to the loop counter, and the new value is tested against the final value. If the final value has not been passed, the loop is executed again, beginning with the line immediately following the FOR statement. lf the final value has been passed, program execution continues at the line following the NEXT statement. Note that the loop counter is not equal to the specified final value when the loop is exited.
The loop counter is also tested against the final value as soon as the values are assigned when the loop is first entered. If the loop counter has already passed the final value in the direction the step would be going, the loop is not executed at all. The loop may be exited arbitrarily (such as with a GOTO), in which case the loop counter has whatever value it had obtained at the time the loop was exited.
The initial, final and step size values are calculated when the loop is entered and are used while the loop is repeating. If you use a variable or expression for any of these values, you may change its value after entering the loop without affecting how many times the loop is repeated. However, changing the value of the loop counter itself can affect how many times the loop is repeated.
The loop counter variable is allowed in expressions that determine the initial, final, or step size values. The previous value of the loop counter is not changed until after the initial, final, and step size values are calculated.
NOTE |
---|
Avoid using fractional values in a FOR ... NEXT statement. Remember that some REAL fractional numbers cannot be represented exactly by the computer. For example, if you use a step size of 0.1, the loop may execute a different number of times than you expect. Also, if the step size evaluates to 0, the loop may repeat infinitely. In either case no error message is given. Refer to the "Numeric Computation" chapter of the HP BASIC Programming Guide for detailed information on the effects of the computer's internal numeric representation. |
Each FOR statement is allowed one and only one matching NEXT statement. The NEXT statement must be in the same context as the FOR statement. FOR...NEXT loops may be nested, and may be contained in other constructs, as long as the loops and constructs are properly nested and do not improperly overlap.
See ASSIGN.
Supported On | UX WS DOS IN |
Option Required | None |
Keyboard Executable | Yes |
Programmable | Yes |
In an IF ... THEN ... | Yes |
FRACT returns the "fractional part" of its argument. For REAL X, X=INT(X)+FRACT(X).
PRINT FRACT(17/3)
Right_part=FRACT(Both_parts)
This function does not allow COMPLEX arguments.
Supported On | UX WS DOS |
Option Required | GRAPH |
Keyboard Executable | Yes |
Programmable | Yes |
In an IF ... THEN ... | Yes |
FRAME draws a frame around the current graphics clipping area using the current pen number and line type. After drawing the frame, the current pen position coincides with the lower left corner of the frame, and the pen is down.
FRAME
See LEXICAL ORDER IS.