HP-85 control characters in strings

Basic used for HP-80 series (HP-83 , HP-85)
Post Reply
User avatar
Gary
Posts: 2
Joined: Sun Jul 02, 2023 6:36 am

HP-85 control characters in strings

Post by Gary »

hi, maybe this will be useful for all HP-85 owners:

I just discovered something about the HP-85 that seems worth sharing. The BPLOT statement uses strings containing arbitrary bytes, including the ASCII control characters (decimal 0 to 31). The first confusing thing is that the HP-85 renders both SPACE and CR (carriage return) characters as blanks. So if you evaluate a string and see blanks they may be either SPACE or CR characters. But it gets worse. Do the following on the HP-85 keyboard.

A$="SPACE CR ." <<< Type Ctrl-M (Carriage Return) for the 2nd blank.
A$ <<< No errors or warnings, and it looks like
SPACE CR . <<< the CR was accepted and rendered as a blank.
NUM(A$[6])
32 <<< The space is ASCII decimal 32 (good).
NUM(A$[9])
32 <<< No! The typed CR became a SPACE with no indication.
B$="SPACE CR"&CHR$(13)&"." <<< So try this.
B$
SPACE CR . <<< B$ looks exactly like A$.
NUM(B$[9])
13 <<< But B$ has the CR character in it


The HP-85 Owner's Manual says control characters can be typed using Ctrl-<LETTER> on the keyboard, and all but CR are rendered as special unique characters. It appears typing control characters into strings works in all cases except CR, and it must be included in a string using &CHR$(13)&.
Typing a CR into a string using Ctrl-M appears to work but actually inserts a SPACE.

By the way, doing the above on Everett's emulator behaves differently. In typing the A$="SPACE CR ." line no blank is echoed for the Ctrl-M keystroke. I didn't compare the emulator and actual HP-85 beyond finding that difference.

I'm not sure why there'd be a difference between the emulator and the real HP-85, without digging into things, but I SUSPECT that the
difference you're seeing is caused by the emulators effort to take input from the Windows keyboard and convert it into simulated
keystrokes to the emulated Keyboard Controller, and CR/END LINE is kind of a special case.

The reason why SPACE and CR are visually the same on the Series 80 machines is the CR character is used for the "screen editor".
When the screen is cleared, it is filled with CR characters. When you type commands, expressions, or program lines, those characters
just get output to the CRT, they don't go into any internal RAM buffer. Then, when you press END LINE, the system code reads
characters from the CRT, taking up to (on the 85) three lines of 32 characters each. How many it takes depends upon the CR characters
it sees. In other words, it looks at the ends-of-lines on the CRT for CR characters to figure out where the start and end of the line
is that END LINE was just pressed on. And that's why they don't allow a QUOTED CR character, but it has to be entered using the
CHR$() function.
User avatar
ronaldo
Posts: 2
Joined: Sun Jul 02, 2023 11:22 am

Re: HP-85 control characters in strings

Post by ronaldo »

That is Interesting information, but I wanted to emphasize that I couldn't find anywhere in the HP-85 user documentation that "they don't allow a quoted CR character" [specifically, a typed Ctrl-M being a CR character in a quoted string]. Also as demonstrated, it appears that it works fine just like the other 31 typed Ctrl-<LETTER> characters do. Note the HP-85B Owner's Manual, page 362, "HP-85 Character and Key Codes" makes no exception for "Key Crtl-M" being any different than the other 31 control characters.
Post Reply