Re: HP49 Printing Message #6 Posted by James M. Prange on 20 July 2002, 8:26 p.m., in response to message #4 by Mike Neu
Well, first off, I suggest that when you upload programs to your
PC in ASCII mode, you use HP Kermit translation mode 3 instead
of 1. You can set that by executing 3 TRANSIO, or in the
"TRANSFER" input form you can choose "\->255" for the "Xlat:"
field. I find it much easier to read or edit that way; pure
ASCII text, and you can use copy and paste from a text editor to
a Forum message (and vice versa) without having to mess around
with non-ASCII characters. I don't believe the 49G guides
include the Kermit translations, but they should be on page
27-16 of the HP 48G Series User's Guide; if you don't have it,
you can download a scanned PDF copy from hpcalc.org; see
http://www.hpcalc.org/details.php?id=3937. In the forum
you can use the preformatted text option (see
http://www.hpmuseum.org/artfmt.htm for details) to avoid
things like unwanted newlines after a hyphen.
Personally, I like to add the information from the BYTES command
so that anyone who copies a program can verify that he got it
exactly right.
Note that there's a lot of information about these calculators
at http://www.hpcalc.org/, and most of the information
about the 48 series (and even the 28 series) also applies to the
49G.
Also note that the usenet newsgroup comp.sys.hp48 rather
specializes in the 28 series, 48 series, 38G, 39G, 40G, and 49G
calculators. You can search the newsgroup archive at
http://groups.google.com/advanced_group_search?group=comp.sys.hp48,
which can be customized to you preferences by using
http://www.google.com/help/customize.html. But GOOGLE only
updates a few times a day, so if you wish to participate it's
better to use a different server. If your ISP doesn't provide a
usenet server, then I recommend
http://www.mailgate.org/index.html for a free web-based
server, or after you've signed up at mailgate, you can use your
own newsreader and the newsreader.mailgate.org server. This
Forum is great, but the Museum seems to specialize in
out-of-production models; I hope that not all of these
calculators will "qualify" for the museum anytime soon.
For your EN1 program, note that DUP DUP DUP can be replaced by
DUPDUP DUP, DUP DUPDUP, or (I believe very slightly faster) DUP
DUP2. The sequence 3. DROP seems particularly pointless. The 49G
command NIP can replace SWAP DROP. I haven't figure out why they
named it NIP; maybe it makes sense in French. In general, don't
put more copies of anything on the stack than you'll actually
use, that way it will be easier to keep track of what's actually
on the stack, the program will run faster, and you won't have to
go to the trouble of discarding unneeded copies later.
If you want to do statistical analysis, the 49G has lots of
commands for that, but they do require that the data is in the
form of a matrix stored in '\GSDAT', so as long as you only want
the minimum and average, it's probably just as easy to stick to
using lists.
As a replacement for:
%%HP: T(3)A(R)F(.);
@ Checksum: # 7F0Eh
@ Bytes: 104.5
\<<
DUP DUP DUP SORT HEAD SWAP \GSLIST
3. ROLL SIZE / 3. DROP 4. PICK 4. PICK
SWAP 4. PICK 4. PICK 4. \->LIST
REVLIST SWAP DROP SWAP DROP SWAP DROP
SWAP DROP
\>>
I'd suggest:
%%HP: T(3)A(R)F(.);
@ Checksum: # EF5Fh
@ Bytes: 54.
\<<
DUP \GSLIST OVER SIZE / OVER SORT HEAD
4. ROLL 4. ROLL 4. \->LIST
\>>
Much smaller, and I'd bet faster, although it's hard to get
anything done in a nanosecond when using a 4MHz processor.
Regarding "carriage return" characters, yes, I think that you
want character 10. I believe that the calculator manual refers
to it as "newline", but in ASCII it's called "Line Feed" or
"LF". I'll use the HP Kermit "backslash" translation "\010". The
ASCII "Carriage Return" or "CR" is character 13. Note that when
you transfer a string in HP Kermit ASCII translation mode 1, 2,
or 3, "\010" is translated to "\010\013", which is expected as
an "End-Of-Line" marker for text files in the MS DOS/Windows
world.
Anyway, I'll guess that the best thing for you to do is replace
every space character in your string with a "newline" character,
even though that may give you a few more newlines than you
really need. You could loop through the string looking for every
occurrence of " " and using REPL to replace it with "\010", like
this:
%%HP: T(3)A(R)F(.);
@ Checksum: # B40Bh
@ Bytes: 47.
\<<
WHILE
DUP " " POS DUP
REPEAT
"\010" REPL
END
DROP
\>>
but the 49G provides the faster, shorter, and easier SREPL
command specifically for this task. Try:
%%HP: T(3)A(R)F(.);
@ Checksum: # 179Fh
@ Bytes: 30.
\<<
" " "\010" SREPL DROP
\>>
If you also want to get rid of the "{ " and " }" delimiters, you
can use:
%%HP: T(3)A(R)F(.);
@ Checksum: # A0B7h
@ Bytes: 70.
\<<
"{ " "" SREPL DROP
" }" "" SREPL DROP
" " "\010" SREPL DROP
\>>
Regards,
James
|