[comp.sys.handhelds] HP48SX PROGRAM: TEXTVIEW

dhe@engr.uark.edu (David Ewing) (04/09/91)

HP48sx Program : TEXTVIEW
---------------------------------------------------------------------

Ever wished for a better way to view a large text string containing 
new lines as if it was a 'text document'?  Well, this program may be 
what you've been looking for.

TEXTVIEW: A String viewing utility.

   TEXTVIEW requires string that you wish to view on the stack - 
an error message will be displayed otherwise.  The string may contain 
any number of new line characters (which of course indicate the end of 
a line) and any number of characters per line (within memory limits), 
but only 32 characters can be displayed per line.

   Once TEXTVIEW is started it will analyze the string for lines, 
the results of which are briefly displayed on the top line along with 
the string size.  After all the program initialization is complete, 
which will depend on the string size, the screen will display the first 
ten lines using the smallest text font; the smallest font is used to 
display the most on the screen at once, however the only drawback is 
that all the characters are displayed only in upper case.  Six keys on 
the keyboard now become active at this point:

 Arrow up             :  Up one page   (if not at the beginning)
 Arrow down           :  Down one page (if not at the end)
 Arrow left           :  Top of string/document
 Arrow right          :  Bottom of string/document
 Enter                :  Exit TEXTVIEW program
 Blue/Right-Shift On  :  Turns off Calculator -Pressing ON resumes.

     (Pressing any other key simply refreshes the screen just
      to let you know that the HP really felt you press a
      mostly-dead key :-)

As always in RPL programs, ON is active - but not really recommended as 
an exit since it will leave one or two objects of its own on the stack.
TEXTVIEW will also not erase anything that was previously on the stack
besides the object that you wished to view.


     VERY QUICK OPERATION SUMMARY:
--------------------------------------
On Stack Level 1:  A string   (e.g. "This is a string
                                     with a line-feed in it")
Press the TEXTVIEW menu key or type 'TEXTVIEW'.
Arrow keys acts as page up and down, and ENTER quits


     TO INSTALL:
---------------------
   Simply strip off all this documentation until only the program
remains, then set the HP48 for a ASC transfer with translate code
3 set, and finally send it to the calculator.   I recommend putting
it in the HOME directory so that it is available anywhere in the
directory structure.


     COMING SOON (probably after this post!)
----------------------------------------------
     TCAT: A text string catalog program; Nice User interface for
           navigating directories and selecting a string variable 
	   to view using this TEXTVIEW program.

#include <disclaimer.h>
  "...this program shouldn't in anyway damage data, and if it does
   I can't be held responsible - blame some other program...."  :-)

        -David

==============================================================================
 dhe@engr.uark.edu                        David Ewing, University of Arkansas
 dewing@uafhp.uark.edu                        Computer Science Engineering

Ensign, if you encounter any holes...steer clear.
    -- Riker to Wesley, "Where Silence Has Lease",
        stardate 42193.6
==============================================================================

--------------------->Cut Here and Download to HP<-------------------
%%HP: T(3)A(D)F(.);
\<< 0 1 1 1 1 0 \-> S a
b c l m
  \<< CLLCD ERASE DUP
TYPE
    IF 2 \=/
    THEN DROP
"Invalid Object Type"
DOERR
    END 'S' STO S
"
" + 'S' STO S
SIZE 'l' STO
"Size:" l \->STR + 1
DISP
    WHILE S "
" POS
DUP 'b' STO 0 >
    REPEAT S c b 1
- SUB S b 1 + l SUB
'S' STO 'm' 1 STO+
    END "Lines:" m
\->STR + 2 DISP m
\->LIST 'S' STO 0 'l'
STO
    DO 1 l + m l -
10 MIN l +
      FOR a S a GET
1 \->GROB PICT SWAP a
1 + 'b' STO # 0d a
l - 1 - 6 * R\->B 2
\->LIST SWAP REPL
      NEXT { # 0d
# 0d } PVIEW 0 WAIT
DUP { 25.1 35.1
34.1 91.3 36.1 51.1
} SWAP POS DUP
      IF 0 \=/
      THEN ERASE {
        \<<
          IF l 0 >
          THEN 'l'
10 STO-
          END
        \>>
        \<<
          IF l m 1
- 10 / IP 10 * <
          THEN 'l'
10 STO+
          END
        \>>
        \<< 0 'l' STO
        \>>
        \<< OFF
        \>>
        \<<
          WHILE l m
1 - 10 / IP 10 * <
          REPEAT 1
'l' STO+
          END
        \>>
        \<<
        \>> } SWAP
GET EVAL
      ELSE DROP
      END
    UNTIL 51.1 ==
    END
  \>>
\>>