                             THE INPRT LIBRARY
                             -----------------
         By Jordi Hidalgo - Version A. Copyright (c) December 2003

IMPORTANT NOTICE: The INPRT command is copyright (c) 1990,93 by HEWLETT-PACKARD.
The original program and documentation are available on Goodies Disks #8 and #9.
This postcardware library enhances its functionality by providing a graphics
string-to-GROB conversion feature.

Installation
------------

The library runs on any 48 (except the newly introduced 48gII!). Transfer the
inprt.lib file to your calculator (binary mode), recall the library object to
the stack and store it in any port. Then press ON-C or power cycle.

A new menu label (INPRT) should show up in the library menu. The library 835
includes four visible commands, namely: INPRT, REMAP, S->G and ABOUTIL. The
latter just displays the version and copyright information.

To purge the library: HOME :n: 835 DUP DETACH PURGE, n being the port number.

INPRT & REMAP
-------------

The INPRT command in this library is nearly the same INPRT program on Goodies
Disk #9, which works on both the S and G series. The only difference is that it
no longer remaps the bytes received to the 48 character set. To do so, I have
included the command REMAP, separately. The reason is twofold: by assuming that
the incoming bytes correspond to Roman 8 text, the original INPRT corrupts the
transmitted graphics string; and also, there are now models that use the same
character set as the 48, such as the 38G and the 39G, whose printouts do not
need to be remapped (there are a few changes in the 39G, though).

When receiving text data from a calculator that prints to the 82240A printer,
just run REMAP on the string returned by INPRT.

(The following instructions for use are based on HP's documentation).

These are the steps for transferring IR printer output to the 48:

1. If your calculator has a double-spaced print mode (19BII, 28S, etc.), set
it to single-spaced print, in order to avoid receiving too many CHR(4)

2. Line up the calculators. The calculators should be no more than 0.5 inches
(1.3 cm) apart for the transmission. Also, other alignment issues apply to
several calculators:

  o  For the 41:  The IR printer module should be in one of the top ports, and
     the shiny "IR cone" in the centre of the module should be aligned between
     the E and T of HEWLETT on the 48's Hewlett-Packard logo.

  o  For the Pioneer series (17B/BII, 27S, 42S): The calculator must be raised
     0.75 cm (0.3 inches). The centre of the LED (which is located at the top
     end of the calculator in line between the E and W of HEWLETT) should be
     aligned between the E and T of HEWLETT on the HP48's Hewlett-Packard logo.

  o  For the Clamshells (18C, 28C/S, 19B/BII): Just line up the calculator's
     LED between the E and T of HEWLETT on the 48's Hewlett-Packard logo. Try
     placing both calculators on the same surface and letting the Clamshell
     unfolded.

  o  For the 95LX, line up the 48's small cone with the 95LX's "/" key. Both
     machines should be on the same flat surface.

As for other models such as the 38G, 38G+ and 39G, the alignment is easy: just
line up the calculator's triangular marks above the display. And as for the new
models (39g+, 49g+, 19bII+, etc), please let me know if additional information
is required for them.

3. Run INPRT on the 48. Bear in mind that INPRT terminates in 10 seconds if no
IR output is received, and that it does not detect whether batteries are low.

4. Execute the print command on the other calculator. You can now use any IR
print command on the transmitting calculator, including those which print
graphics, such as PRLCD on the 42S, 28C/S, 48SX/GX, etc. ON-L on the 28S,
ON-PRNT on the 19B, etc. For the 95LX, use HP's TSR (Terminate and Stay
Resident) program IRPRTSC.COM ("Infrared Print Screen"): the screen is printed
lengthways, resulting in a 128x240 GROB, once S->G is run.

INPRT Results. The S->G Command
-------------------------------

When the transfer is complete, the 48 returns the received data to the stack in
the form of a string to level 2 and a flag to level 1. If the flag is 0,
uncorrectable transfer errors were detected; if the flag is 1, there still may
be missing bytes. The 1 means that each byte that was detected was received
correctly.  You should still check the received data since there may be a
linefeed in strings, names, expressions, etc. more than 24 characters long. If
the flag is 0, each byte that was not correctable is a gray blot (character
number 127) in the level 2 string.

When receiving graphics strings, you can convert them to GROB format with the
S->G command. The input string is assumed to have been printed by another
calculator and received by INPRT. The graphics string can have an unlimited
number of escape sequences, provided that all of them correspond to graphics
with the same number of columns. Any byte that does not belong to a graphics
escape sequence is simply ignored. Even though an error checking is done
(invalid or corrupt strings generate the error "Bad Argument Value") the
returned GROB might not be correct because of a corrupted input string: just
line up the calculators carefully and re-send the screen or graphics data.

Converting HP-28S Graphics Strings to HP48 GROBs
------------------------------------------------

Graphics strings on the 28C/S are just graphics escape sequences for the IR
printer. But the 28S' command LCD-> returns the current display as a string
of 548 characters: it's a graphics string without the escape and control chars.
Since it does not have the escape sequences, S->G cannot convert them to GROBs.
But, an internal routine in the INPRT library, XLIB 835 4, does just that:

First do 33 SF (auto CR off) on the 28S, so that the 28S doesn't print CHAR(4)
every 24 chars, run INPRT on the 48, and print the string on the 28S with PR1,
you can now clear the flag 33. On the 48, run this program, which assumes the
string is on level one:

<< IF DUP SIZE 548 == THEN "GROB 137 32" OBJ-> #343004h LIBEVAL END >>

Note that it should also verify that the level one object is a string, but I
believe that checking that its size is exactly 548 suffices! Also, the sequence
"GROB 137 32" OBJ-> is 10 bytes shorter than #137d #32d BLANK.

XLIB 835 4 expects a graphics string without escape and size chars on level two
and a blank GROB on level one. It returns the GROB version of the graphics
string. The file code.s contains the source code for this routine.

Sending Large GROBs
-------------------

You can also print GROBs from a 38G or 39G (and of course from another 48),
but, in this version, there's no special consideration for graphics objects
wider than 166 dot columns, which are printed in 166-column wide segments: for
example, a 175-column wide graphics object would be printed in one 166-column
segment and one 9-column segment. But since the number of columns must be the
same, if the graphics object to be printed is wider than 166 columns, you
should first make sure on the transmitting calculator that the number of
columns is a multiple of 166, by running either this User-RPL program:

Input:  1: Graphic m x n.
Output: 1: Graphic p x n, where p is the least multiple of 166 greater than or
           equal to m.

<< DUP SIZE SWAP B->R 166 / CEIL 166 * R->B SWAP BLANK SWAP { # 0d # 0d } SWAP
REPL >>

or this 38/39G program: expects GROB in G0, stores broadened GROB in G1
( |> means STO )

SIZE(G0)|>L1:CEILING(L1(1)/166)*166|>L1(1):
ZEROGROB G1;L1(1);L1(2):
REPLACE G1;(Xmin,Ymax);G0

Postcardware
------------

For bug reports and comments, please contact the author at hidalgo@tv3mail.com
Remember that this library is POSTCARDWARE: if you like and use this library,
please try and send a nice postcard to:

Jordi Hidalgo
Av. Jaume Recoder, 80, 1 - 4
08302 Mataro
Barcelona, Spain
