SysRPL: Some Editor Utilities
- From: Bill Markwick <bd628@xxxxxxxxxxx>
- Date: Tue, 25 Nov 2008 07:15:14 -0800 (PST)
Sure is slow around here lately. We even have VPN replying to
a message from one year ago ("Have a great Summer"). :-)
Carsten Dominik wrote a good tutorial on SysRPL routines
for controlling the text editor, which you can download from:
http://www.hpcalc.org/search.php?query=editor49
So I did some HP49/50 series editor utilities that might be of
use to someone. These are not examples of the best programming,
but they do what they should and they're stable.
Maybe that *is* the best programming. :-)
(I'll aim this article at people like myself who use SysRPL only
occasionally. Let me know of any unnoticed disasters waiting to
happen. None of these were tested on the HP48.)
Hope they're useful,
Bill
-> All the programs below require assignment to a user key
so they can be used in the editor.
If you want, you can store them instead and assign only the name
with either single quotes or a UserRPL program containing the
name - both should have TakeOver applied (Keyman's ->TO? command
is good for this).
If you don't have Keyman, here's a stripped-down version I call
TOV that will apply TakeOver to global names or programs only.
Post-compile on-the-stack bytes and checksum: 56, #35ACh
::
CK1NOLASTWD ( Check for at least 1 obj on stack)
DUPTYPEIDNT? ( Is it a global name?)
SWAP ( Tuck TRUE/FALSE out of the way)
DUPTYPECOL? ( Is it a program/secondary?)
BINT3
ROLL ( Put the results on levels 1 and 2...)
OR ( ... and OR them)
ITE ( If either is true, run the secondary below)
:: ( Else if neither is true, jump to error msg)
?Ob>Seco ( If not already a secondary, add :: and ;)
' ( Quote the following line to the stack)
TakeOver
>HCOMP ( Add Lev1 obj to head of composite)
; ( End TakeOver conversion)
"Name or pgm" ( Error msg to stack if required)
;
@
DATSTR: INSERT DATE INTO TEXT AT CURSOR
If you'd like the time inserted as well, delete BINT1, BINT12, and
SUB$. The string converter TIMESTR requires both time and date
before it will convert to a readable string (which includes the
day spelled out, eliminating an idiocy of the all-number system:
is it dd/mm/yy or mm/dd/yy?).
Post-compile on-the-stack bytes and checksum: 30, #8034h
::
TakeOver ( Work when inside the editor)
EditLExists? ( Are we in the editor?)
NOT?SEMI ( If not, exit.)
DATE ( Get date in number form)
TOD ( Get time in number form)
TIMESTR ( Change both to string form)
BINT1
BINT12
SUB$ ( Extract only the date string)
CMD_PLUS ( Insert this string into text)
;
@
APPEND: APPEND SELECTIONS TO CLIPBOARD
I find this really useful. Windows editors should have an Append,
but I've never seen one (except on the late, great, stillborn
Aurora for Windows).
Options:
- If you want to overwrite the clipboard first, make the first
selection a regular COPY - otherwise all your selections will be
appended to whatever's in the clipboard to start with.
- If you want to keep the highlighting as a reference, delete the
last command, ClearSelection.
(There will be rioting in the streets when people see that I've
used CMD_COPY.SBR because it's said to sometimes get the
font/style wrong if the cursor is not repositioned to the start
of the selection. The suggested sub using RCL_CMD adds a
linefeed. My workaround is below. Fonts and styles are safe.)
Post-compile on-the-stack bytes and checksum: 45, #884F
::
TakeOver ( Work when inside the editor)
EditLExists? ( Are we in the editor?)
NOT?SEMI ( If not, exit.)
VERIF_SELECTION ( Is there a selection?)
NOTcase ( If not, beep if flag 56 is clear)
DoBadKey
DO>BEG ( Cursor to beginning of sel)
CMD_COPY.SBR ( Selection to stack as string)
DO>END ( Cursor back to end of sel)
Clipboard?_ ( Anything in the clipboard?)
NOTcase ( If not, add the selection string)
Clipboard!_ ( Stores string to clipboard)
Clipboard@_ ( Clipboard contents to stack)
!insert$ ( Swap and append string)
Clipboard!_ ( Stack string back to clipboard)
ClearSelection ( Clear the highlighting - can be deleted)
;
@
UCASE: CONVERT SELECTION TO UPPER CASE
This changes only characters a-z, so it won't affect numbers
or symbols. The "invisible codes" mentioned are the ones that
determine font and style changes; PASTE.EXT instead of
CMD_PLUS preserves font information.
Post-compile on-the-stack bytes and checksum: 154.5, #1A5Fh
::
CK0NOLASTWD
EditLExists? ( Are we in the editor?)
IT ( If not, exit)
:: ( If so, is there a selection?)
VERIF_SELECTION
NOTcase
( If False [no sel] do beep only)
( If True, skip beep section)
:: ( Beep section begins)
FPTR 7 1DC ( aka FPTR2 ^PUSHFLAGS_)
BINT56
ClrSysFlag ( Beep on)
DoBadKey ( Beep)
FPTR 7 1DD ( aka FPTR2 ^POPFLAGS_)
; ( Beep section ends)
DO>BEG ( Cursor to beginning of sel)
CMD_COPY.SBR ( Selection to stack as string)
DO>END ( Cursor back to end of sel)
CK1NOLASTWD ( Dbl check)
DUPTYPECSTR? ( Trpl check to see if it's a string)
NcaseTYPEERR ( If not, do Wrong Argument Type)
TOTEMPOB ( To temp obj area)
::
NULL$ ( Empty string)
SWAP
DUPLEN$ ( Stop # from length of string)
BINT0 ( Start #)
DO ( Start loop)
::
DUP
CAR$ ( Get 1st chr)
CHR># ( Get ASCII)
SWAP
CDR$ ( Get $ tail)
SWAP
DUP
BINT96 ( Is chr a-z, ASCII 97 to 122?)
#>
OVER
BINT123
#<
AND
IT ( If a-z then: )
::
BINT32 ( Subtract 32)
#-
;
#>CHR ( Convert back to chr)
CHR>$ ( Replace in $)
SWAP
3UNROLL
&$SWAP ( Add to $, swap)
;
LOOP ( Repeat for next chr)
DROP
;
CMD_CUT ( Delete selection $)
PASTE.EXT ( Replace with new $, inc. invis. codes)
;
;
@
(I have the awful feeling some SysRPL guru is going to say, "But
there's already a single command for all that.")
ALLP: ALL-PURPOSE LINE WIDTH TRIM
This can be used on the stack or in the editor.
STACK USAGE:
"wide string" n -> "string formatted to n columns"
n can be any number; the usual is 22 (Font8) or 33 (minifont).
IN THE EDITOR:
Highlight the text to be formatted and press the assigned key.
The program reads flag 73 and will format for either Font8
(22 col) or the minifont (33 col), whichever is in use.
Note that the actual cut command, ^StrCutNchr_, will not split
words or numbers. If you want this (handy for very large
integers), add a 2 to the command to get ^StrCutNchr2_.
Post-compile on-the-stack bytes and checksum: 97, #7E57h
::
CK0NOLASTWD
EditLExists? ( Are we in the editor?)
ITE ( If so, run the following pgm)
:: ( If not, skip to the next pgm)
VERIF_SELECTION ( Is a selection highlighted?)
NOTcase ( If not, beep if flag 56 is clear)
DoBadKey
DO>BEG ( Reposition cursor to sel start)
CMD_COPY.SBR ( Selection string to stk)
DO>END ( Reposition cursor to sel end)
CK1NOLASTWD ( Dbl check)
DUPTYPECSTR? ( Trpl check to see if it's a string)
NcaseTYPEERR ( Error msg if not)
TOTEMPOB ( Work in temporary obj area)
BINT73
TestSysFlag ( See which font is in use)
ITE
BINT33 ( 33 col for minifont)
BINT22 ( 22 col for Font8)
FPTR2 ^StrCutNchr_ ( Use ^StrCutNchr2_ to split words, nos.)
CMD_CUT ( Delete selection $)
PASTE.EXT ( Replace with new $)
;
:: ( This secondary pgm is for stack mode)
CK2NOLASTWD ( At least two obj on stack?)
::
CK&DISPATCH1 ( String, Lev2, and real/integer, Lev1)
( CK&Disp. converts integers to reals)
BINT49 ( #49d=#31h - 3=string, 1=real)
COERCE ( Real to bint)
;
SWAP
TOTEMPSWAP
FPTR2 ^StrCutNchr_ ( Use ^StrCutNchr2_ to split words, nos.)
;
;
@
--END--
.
- Prev by Date: Re: HP50g Error Message Display
- Next by Date: List Processing
- Previous by thread: HP50g Error Message Display
- Next by thread: List Processing
- Index(es):
Relevant Pages
|