HP-71 Lexfile ListCollected by Joe Horn
An Alphabetical list of the most popular and useful HP-71 lexfiles.
For a complete list of any lexfile's keywords and syntax, see The LEXicon .
ATTNLEX “Attention Key lexfile”. SIZE: 68 bytes.
- ATTN OFF disables the ATTN key from interrupting programs; it becomes just another key that is put in the key buffer when pressed.
- ATTN ON restores it to normal. Looks better than POKE “2F441”,“0” and POKE “2F441”,“1”, but has identical effects.
BASICLEX “BASIC file utilities”. SIZE: about 1000 bytes.
- LIST$ returns any program line of any BASIC program in memory, in the form of a string that is identical to the way the program line would be LISTed. This allows a program to examine the contents of another BASIC program, or even itself, without needing to TRANSFORM it into text.
- MODIFY takes a string (a valid line of program BASIC) and merges it into the specified program. This allows a BASIC program to modify any other BASIC program, or even itself, without POKE.
- Together, LIST$ and MODIFY allow such things as a telephone directory program with all its data in DATA statements that are updated by the program itself.
BANNER Converts a string character into a string of 48 characters that represents the LCD display (8 rows of 6 dots) of that character. Allows printing large banners from keyboard input text. Even works on CHARSET characters! SIZE: 202 bytes (“CLOCKVID” = 593 bytes).
- BANNER$’s parameters allow optional specification of foreground and background characters.
- Comes with a BASIC program “CLOCKVID” that displays a digital clock on a CRT (using video interface) in HUGE digits; the HP-71 turns itself on once a minute to update the display, then turns off again!
BEEPLEX “Beeper lexfile”. Great for game programs. SIZE: 206 bytes.
- CHIRP causes the error-beep to sound, but without an error.
- MGUN causes a machine-gun type of noise.
- SING sings a happy upward sweep of notes.
- ZAP sounds a despressing, downward sweep of notes.
BREAKPT “Break Point lexfile”. Adds breakpoint ability, usually only found in low-level languages like Assembly language debuggers. SIZE: 365 bytes.
- BREAK lets you specify any line number or numbers where the HP-71 should automatically PAUSE (same as inserting a PAUSE at that line of code). Even works on ROM programs. Primarily used for debugging, but also good for simple program control.
- UNBREAK clears all breakpoints set by BREAK.
- BLIST lists all the current breakpoint line numbers.
CALCLEX “CALC Mode lexfile”. Adds no keywords to BASIC. Modifies the action of the back-arrow key in CALC mode to be identical to the BACKspace key. With CALCLEX in memory, you no longer have to press the gold “f” key to backspace! SIZE: 41 bytes.
CLOCKDSP “Clock Display lexfile”. SIZE: 328 bytes.
- CLOCK ON puts the HP-71 into clock display mode: the right end of the display turns into a digital clock updating every second, but the rest of the display is left alone for you to do work of any sort as usual! Even works in CALC mode.
- CLOCK OFF turns off the clock and returns the entire display to your control. Cannot be used with programs that use the WINDOW statement.
COMBARR “Combinations / Arrangements lexfile”. SIZE: 168 bytes.
- COMB quickly finds the number of different groups of R things you can take from a group of P things.
- ARR quickly finds the number of ways of arranging P things taken R at a time (also known as “permutations”).
- Allows greater ranges than allowed by the FACT definitions of combinations or permutations.
CONTRLEX “Contrast lexfile”. SIZE: 49 bytes.
- CONTRAST function: returns the current display setting as set by the built-in CONTRAST statement.
CURLEX “Cursor lexfile”. Adds no keywords to BASIC. Modifies the action of the “g”-shifted left and right-arrow keys. Ordinarily, they go to the far left and right, respectively. When CURLEX is in memory and USER mode is ON, then they only move 21 spaces left or right, respectively. This makes it possible to “jump” back and forth in the display in display-width chunks, like the HP-75 can. The feature can be disabled by turning USER OFF. SIZE: 110 bytes.
CURVIEW “Cursor VIEW lexfile”. Adds no keywords to BASIC. Modifies the action of the VIEW key. When VIEW is pressed in USER mode, the current position of the cursor is displayed until VIEW is released, then the display is restored. Disabled by USER OFF (VIEW works normally). Great for text editing. SIZE: 90 bytes.
CUSTUTIL “Customization Utilities lexfile”. This lexfile is a must for those who plan to market their programs to the “real world”. SIZE: 1007 bytes.
- INLINE is an improved INPUT, with controls such as cursor position and type, and termination key specification. It allows amazingly “friendly” programming.
- KEYNAM$ returns the name of the numbered key, and
- KEYNUM returns the number of the specified key name. These allow full use of functions and statements that use either key name or number.
- KEYWAIT$ is the most useful lex function of all; it is the same as KEY$ but it waits in low-power “idle” mode until a key is pressed.
- MSG$ returns the specified message or error string, automatically translating if a translator lexfile that handles pTRANS is in memory.
- SCROLL scrolls the display so that the specified character is the first one displayed, the rest being off the left edge, available with the arrow keys.
DATALEX “DATA File utilities”. SIZE: 1416 bytes.
- DDELETE deletes the specified record, and shrinks the DATA file size.
- DINSERT inserts data into the specified record, and the DATA file size grows.
- DRECORDS returns the number of records in the specified DATA file.
- EXPAND lengthens the specified DATA file by expanding all of its current records by any specified number of bytes.
- RECLEN returns the record length of the specified DATA file.
- SWAP: I'm not sure what this does, but it seems that it ought to swap records or fields in records.
DESAL SIZE: 718 bytes.
- ADBUF$ finds the address of the specified buffer.
- ASC$ returns its argument string with all non-printable characters (ASCII codes 0-31 and 127-255) changed to a period.
- ATH$ is an ASCII to HEX converter; a string of ASCII characters (regular string) is changed to a string of hex digits, each pair representing one byte of the string, nibble-reversed.
- HTA$ converts hex to ASCII.
- RED$ reduces a string by removing all spaces on both ends.
- KEYWAIT$: see KEYWAIT below.
- REV$: see REVLEX below.
- PEEK$ and POKE: see POKELEX below.
DRIVELEX “Lexfile Driver”. Wonderful! SIZE: 277 bytes.
- DISABLE “turns off” the specified lexfile; although the lexfile is left in the catalog chain, it is removed from the lex chain, and changed to a “D-LEX” file which has no effect on HP-71 operation.
- ENABLE changes the lexfile back into a “LEX” file, restores it to the lexfile chain, and returns all its effects (keywords and poll handlers) to normal.
- Having many lexfiles in memory is delightful because of the power it gives you, but it’s bad because it slows down the whole machine. For optimum speed, DISABLE the lexfiles not needed at the moment, and ENABLE them only as needed. This makes purging / reloading unnecessary. A must for all lexfile users, especially those with more memory than the bare HP-71B.
ENDUPLEX SIZE: 252 bytes.
- ENDUP is similar to the built-in STARTUP statement puts a string of BASIC commands into a special buffer that gets executed automatically at power-up, but the string specified by ENDUP gets executed at power-down. This is true whether power-down is due to pressing the OFF key, execution of OFF or BYE from the keyboard, or even if the HP-71 “times out” and automatically goes to sleep after ten minutes of inactivity. (Inactive in CALC mode, but active in FORTH mode).
- ENDUP$ returns the contents of that buffer, and STARTUP$ returns the contents of the STARTUP buffer.
EXTFILES “External Files Poll Handler”. This lexfile does not add any keywords to BASIC, but extends the number of file types that the HP-71 recognizes. The HP-71 normally recognizes only BASIC, KEY, TEXT, SDATA, DATA, LEX and BIN file types, and refuses to copy files into memory (or from disc to disc) if they are of any other type. The FORTH ROM allows a new file type, FORTH files, to be copied, and identifies these files by putting “FORTH” into their catalog string. The EXTFILES lexfile takes this idea a step further. It makes just about every file type known to the handheld community recognizable to the HP-71, and not only allows it to copy them, it identifies them in their catalog listing. No longer do we need to decipher file type code numbers. SIZE: 502 bytes.
FILELEX “File checker lexfile”. SIZE: 64 bytes.
- FILE? checks whether or not its argument is a filename that exists in the HP-71’s file chain, even if IRAM, ROM, etc. If it is, FILE? returns a 1; 0 if not. Most useful as in IF NOT FILE?(A$) THEN COPY A$&“:TAPE”.
FKEYLEX “First Key lexfile”. SIZE: 81 bytes.
- FKEY (similar to the built-in PUT statement) pushes the specified key onto the key buffer, but pushes it onto the other end of the stack, so that it is the first, not most recent, keystroke in the buffer. PUT uses the key buffer as the keyboard does: first in, first out. FKEY, on the other hand, uses it on a last in, first out basis.
FORMALEX “Format lexfile”. These functions are the core of all word processing. SIZE: 454 bytes.
- CENTER$ centers any string in a longer string of spaces of specified length.
- CESURE tells where to break a string for printing purposes, to avoid lines beginning with spaces and punctuation.
- FORMAT$ “right justifies” text to any specified length by inserting spaces between words.
- REDUCE$ does the opposite; spaces at the ends and any “extra” spaces between words are removed.
- SPACE$ returns a string of spaces of any specified length.
HIGHLEX “High bit lexfile”. SIZE: 57 bytes.
- HIGH$ sets the high bit of every byte in its argument to a 1. This allows rapid replacement of a string with its video inverse (if you have a video interface) or custom character replacement (if you are using CHARSET).
INDATLEX “Date Input lexfile”. Designed for French-speaking Europeans. SIZE: 147 bytes.
- INDATE$ first displays DATE : “JJ/MM/AA” with the cursor flashing on the JJ. The user types two-digit day, month and year over the letters, and they are reversed and returned as a string with slashes inserted properly (no input returns “AA/MM/JJ”).
KBEEP “Keyboard Beep lexfile”. When in memory, every keystroke causes a audible “chirp”, like a cheap calculator. This wonderful feature can easily be turned off by BEEP OFF or by purging KBEEP. SIZE: 38 bytes.
KEYWAIT The most useful of all lexfiles for the general programmer. SIZE: 55 bytes.
- KEYWAIT$, like KEY$, returns the most recent key from the key buffer, but unlike KEY$ it pauses execution of the program if there is nothing in the key buffer, and resumes execution the moment a key is pressed. Better than a loop, it goes into “idle” while waiting, which conserves battery power. The HP-71 design team has said that this function was supposed to have been in the mainframe, and it is unfortunate that it was one of the ones they decided would have to be left out to keep the operating system down to 64K. KEYWAIT$ is therefore found in many lexfiles and ROMs, since it is so useful. This lexfile adds just KEYWAIT$.
LCDLEX “Liquid Crystal Display control lexfile”. SIZE: 672 bytes.
- BLD puts the display into “bold” mode (letters look “fatter” than normal).
- BLINK puts the display into “blink” mode (whole LCD blinks on/off every half second).
- CLR clears (turns off) the specified dot in the display.
- DOT returns the value (0 or 1) of the specified dot in the display, and optionally sets or clears it.
- INVERT inverts the entire display (all dots toggle their value).
- LCD allows friendly setting of the contrast: up and down arrows raise and lower the contrast.
- MIRROR puts the display in “mirror” mode (everything in upside down).
- NRMAL resets the display to its normal mode.
- SET sets (turns on) the specified dot on the display.
- SMALL puts the display into “small” mode (everything looks tiny).
- None of these keywords affect anything other than the LCD display itself.
LIFELEX “Game of Life lexfile”. SIZE: 457 bytes (LIFEVID = 443 bytes).
- LIFE$ takes a string of spaces and asterisks, representing a matrix of dead and living cells respectively, and calculates the next generation by the rules of Conway’s mathematical game of Life. Parameters specify the row width, and optionally specify wrap-around logic, and characters to be used instead of the default asterisks and spaces. Comes with a BASIC program “LIFEVID” designed for use with a video interface; each full-screen generation takes only 1 second!
LINKLEX “Lexfile Linker”. SIZE: 260 bytes.
- LINK merges two or more lexfiles into one, maintaining the features of all of them but saving memory because there is only one file header in memory. Allows the creation of custom lexfile packages by linking all the desired keywords into a single lexfile. Even works on lexfiles that don’t add any keywords.
LOCKOFF Does not add any keywords to BASIC. Effectively puts the HP-71 into LOCK OFF mode; the LOCK command has no effect as long as LOCKOFF is in memory. To be precise, LOCKOFF clears the LOCK password at power-up before the “password?” routine, thus making it impossible to LOCK the machine. Can be used to unLOCK another HP-71 with unknown password even if it isn’t in memory (method available upon request). A must for those whose HP-71 can fall into the evil clutches of bozos who like to LOCK “IBM 360” or other
“practical joke” passwords that no self-respecting HP-71 owner would ever guess, resulting in INIT 3 and total Memory Lost. SIZE: 33 bytes.
MARGELEX “Margin lexfile”. SIZE: 92 bytes.
- MARGIN sets the right “margin” on the HP-71. When typing and the specified position in the display is reached, a chirp is sounded, like the margin bell on a typewriter. This is like the HP-75’s margin feature, sorely missed on the HP-71... until now! Makes text editing a snap. Editing programs that should be listed on an 80-column printer without wrapping around is easy too.
MENULEX SIZE: 308 bytes.
- MENU allows easy menu-driven programming. MENU displays the first DATA statement’s data in the display, and pressing the up and down arrow keys steps through successive DATA data until the user presses ENDLINE which returns the number of the displayed data. RESTORE can be used to specify the starting DATA, and MENU specifies how many data to use in the menu and optionally specifies which of the menu entries should be displayed first.
NOISE SIZE: 299 bytes. (“MUSIC” program = 503 bytes; “MARYLAMB” = 256 bytes; “PHASER” = 512 bytes; “WTELL” = 2048 bytes)
- NOISE is similar to the NOISE statement that HP put into the HP-75 I/O ROM and then didn’t mention in the owner’s manual. Given a string containing encoded frequencies and durations, NOISE plays it as music (or noise). Does not use the operating system’s BEEP subroutines, but drives the beeper directly, resulting in a much wider frequency range than the BEEP function has. Timing is also much more precise. Comes with a BASIC program called MUSIC that allows you to write music on the keyboard, listen to it, save it in a file, and play back files thus saved. Three sample music files are available on card, tape or disc: MARYLAMB (Mary Had a Little Lamb), PHASER (spine-tingling red-alert type of sound), and WTELL (about two minutes of the William Tell Overture).
ONKEYLEX “ON Curser Keys lexfile”. SIZE: 195 bytes.
- CURSDOWN is like KEYDOWN but takes no argument, and responds only to the four arrow keys, returning 1 through 4 respectively if one of them is currently being pressed down.
- CURSKEYS is like KEY$, but responds only to the four arrow keys and the “g”-shifted up-arrow and down-arrow, returning 1 through 6 respectively if any of them is in the key buffer. Best used with the ON statement, ONKEYLEX makes writing menus much simpler.
PATTERN SIZE: 171 bytes.
- PATTERN$ takes a normal DISP-type string and converts it to a GDISP-type string, so that DISP “HELLO” and GDISP PATTERN$(“HELLO”) have the same result on the LCD, but the latter is much faster if the string is pre-compiled with PATTERN$. Even works with custom CHARSET characters.
PEEKUTIL “Peek Utilities lexfile”. SIZE: 351.
- REV$ reverses the byte order of a string (see REVLEX below).
- RPEEK$ is like REV$(PEEK$).
- PEEK is like HTD(PEEK$), and the second parameter can be omitted for a default of 1 nibble.
- RPEEK$ is like REV$(PEEK$).
- ADPEEK$ (“address peek”) is used when the nibble(s) being peeked contain a memory offset; ADPEEK$ adds the offset (considered a signed value) to the address being peeked.
- ADPEEK is like HTD(ADPEEK$).
- TEXT$ is like HTA$(PEEK$) (see DESAL above).
- All of these can take string or numeric address arguments, and work on PRIVATE files in RAM or ROM.
POKELEX Improves the built-in PEEK$ and POKE to work anywhere, even on SECURE and PRIVATE sections of memory. SIZE: 257 bytes.
PLOTLEX “Plotter utilities lexfile”. Adds COLOR, CSIZE, DRAW, HOME, LABEL, LDIR, LTYPE, MOVE, PLOTTER IS, RDRAW, RESET PLOTTER, RMOVE, and SETORG to BASIC. Assumes an HP-IL plotter device (plotter, or video interface that recognizes HPGL). Makes reading BASIC programs easier. SIZE: 855 bytes.
PRIMLEX “Prime Factor lexfile”. SIZE: 148 bytes.
- PRIM(X) returns the lowest prime factor of X. Allows rapid factorization of composite numbers.
PRINTLEX “Printer function lexfile”. SIZE: 565 bytes.
- BELL sends the ASCII “BEL” control character, CHR$(7), to the current printer, to ring its bell (if it has one).
- BOLD ON / OFF controls the printer’s bold mode.
- CR sends a carriage return, CHR$(13).
- ESC$ sends the escape character, CHR$(27).
- FF sends a form feed, CHR$(12).
- LF sends a line feed, CHR$(10).
- MODE 0 sends ESC$&“&kOS” to set normal pitch; MODE 1 and so on set other pitches or printer features.
- PERF ON / OFF controls perforation skip mode.
- PL 66, 56 sets the page length to 66 lines, with 56 lines of text per page.
- UNDERLINE ON / OFF controls the printer’s underline mode.
- WRAP ON / OFF controls wrap-around mode (unique to the ThinkJet).
REPEAT SIZE: 266 bytes.
- REPEAT modifies the keyboard repeat feature. Normally, when you press a key and hold it down, it begins to repeat after a little wait (half a second), repeating about 6 keys per second. This is too slow for us hyperactive people who want keys to repeat FAST and see the cursor control keys fly across the screen. REPEAT allows you to specify the length of the initial wait after pressing a key (from half a second to no wait at all), and automatically speeds up key repeating to about 13 keys per second (roughly twice as fast as normal). This is one of those lexfiles that you’ll always want to leave in memory.
REPLEX “REPLACE. String lexfile”. SIZE: 320 bytes.
- REPLACE$(A$,B$,C$) returns A$ with every B$ in it replaced by C$. An optional fourth parameter specifies a character which is to be considered a wildcard character in B$. Although useful in itself, it is very powerful when combined with the TEXTUTIL functions (see below).
REVLEX “Reverse String lexfile”. SIZE: 33 bytes.
REV$ reverses its string argument’s byte order. REV$(“Hello!”) gives !olleH. Useful for heavy things like memory management, or silly things like display graphics. A subset of STRINGLX.
RGCMDS “Row Graphics Commands”. Originally used with the ThinkJet Space Shuttle demo. SIZE: 207 bytes.
- CPRSRG$ (“Compress Row Graphics String”) compresses strings of row-graphic data by replacing strings of zeros with a single zero and a count.
- EXPORG$ (“Expand Row Graphics String”) expands a string compressed with CPRSRG$.
ROMAN8LX “Roman 8 lexfile”. SIZE: 850 bytes (note: after CHARSET ROMAN8$, LEN(CHARSET$) = 768 bytes).
- CHARSET ROMAN8$ remaps the display to look like the International, or Roman 8 Extension character set. For example, CHR$(191) will no longer look like a “?“ but like a “t”, which is how the ThinkJet prints it. If only a few of the Roman 8 characters are desired, you can CHARSET or GDISP any substring of ROMAN8$.
ROWCOL “Row/Column swapper”. SIZE: 119 bytes.
- ROWCOL$ converts a string of 8 bytes into an 8x8 matrix of bits, transposes it (converting the rows to columns and vice versa), and converts it back into a string of 8 bytes. If the argument is less than 8 bytes, it is padded with nulls before transposing. Great for graphics work.
RPTLEX “Repeat String lexfile”. SIZE: 143 bytes.
- RPT$ repeats any string any number of times. Saves memory when programming and makes output simpler.
SHOWPORT Improves the built-in SHOW PORT statement. The built-in showport shows only IRAM and ROMs. This improved version shows everything, whether configured as part of main memory or not. Allows seeing exactly what the owner has installed inside the HP-71! And rapid verification of what’s in that module you paid so much for. SIZE: 151 bytes.
STKLEX SIZE: 107 bytes.
- STACK 15 sets the command stack to be 15 high; any number 1 to 16 can be used.
STRINGLX “String Utilities lexfile”. This package of string functions was originally intended to be part of the built-in BASIC, but was left out due to memory constraints. SIZE: 837 bytes.
- TRIM$ trims spaces (or any other specified character) off the ends of a string, whereas
- LTRIM$ trims only the left end, and
- RTRIM$ trims only the right end.
- LWC$ and its alias
- LWRC$ both convert a string to lowercase.
- MEMBER searches a string for any one of a given set of characters.
- SPAN searches a string for the first character which is not a member of a given set of characters.
- REV$ reverses the byte order of a string (see REVLEX above).
- ROT$ rotates the bytes in a string any number of times in either direction.
- RPT$ repeats a string (see RPTLEX above).
- SBIT and
- SBIT$ let you test, toggle, set or clear any bit or byte in a string.
SYRACUSE SIZE: 74 bytes.
- MSA (“Modified Syracuse Algorithm”) is like the ULAM function (see below), but counts how many steps it takes to fall below the starting number, and counts (3x+1)/2 as one step. This value is useful in rapid elimination of counterexamples to Ulam’s Conjecture.
SYSLEX “System Utilities lexfile”. SIZE: 314 bytes.
- SETCMOST sets the command stack height from 1 to 16.
- CLKSPD returns the current clock speed.
- CMSTSIZE returns the current command stack size.
- CONTRST returns the current display contrast.
- DWIDTH returns the current display width.
- PRWIDTH returns the current printer width.
- LOOPOFF? is a boolean HP-IL test for OFF IO / RESTORE IO.
TEXTUTIL “Text editor Utilities”. The core of a text editor program. SIZE: 1512 bytes.
- DELETE deletes the specified record from a text file, and shrinks the text file size.
- FILESZR returns the number of records in the specified text file.
- INSERT inserts a string into a text file at the specified record number, and expands the text file size.
- REPLACE is a combination of DELETE and INSERT: it replaces the specified record with a string.
- SEARCH is a super-fast, super-powerful function that searches a text file for any specified substring, with several optional wildcard specifiers.
- LIST and PLIST are improved to be able to work on TEXT files.
ULAMLEX “Ulam’s Conjecture lexfile”. SIZE: 78 bytes.
- ULAM(x) calculates how many steps it takes for x to get to 1 by repeated application of the Syracuse algorithm. ULAM(27)=111 because if you start at 27 it takes 111 steps to get to 1. This iterative function is useless in itself, but there's £1000 awaiting the one who can prove that any number will eventually reach 1.
UNPRIVLX “UnPrivate lexfile”. SIZE: 105 bytes.
- UNPRIV is identical in all respects to the built-in PRIVATE statement, but has the opposite effect. What required several lines of BASIC or a few statements in FORTH is now possible in a single BASIC command.