Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Problem-free CAS command execution (no fail, no mode change, etc.)

25 views
Skip to first unread message

John H Meyers

unread,
Aug 11, 2004, 1:53:46 PM8/11/04
to
XC49 can perform hp49g CAS commands (in RPN mode)
so that they don't delete any variables,
don't fail because of variables which already exist,
don't prompt for any mode changes,
and don't leave any modes changed after execution.

Text and binary versions available from:
http://www.hpcalc.org/details.php?id=5493
http://www.hpcalc.org/hp49/math/symbolic/xc49v02.zip
File names: xc49v02.zip, xc49v02.bin, xc49v02.txt


----- File xc49v02.txt from the above -----

To: (hpcalc.org)
From: John H Meyers <jhme...@mum.edu>
Date: 2003/02/22
Subject: XC: CAS Modes/Vars relief!

Description:

This program can perform hp49g CAS commands (in RPN mode)
so that they don't delete any variables,
don't fail because of variables which already exist,
don't prompt for any mode changes, and
don't leave any modes changed after execution.

You can use it in programs which in turn call CAS commands,
or you can use it in menus which offer the same CAS commands
as built-in menus, but which will execute them from your own
custom menus in this new, hassle-free manner.

You can also use it manually, any time at all,
on any command or program you want to execute in this
protected manner, by just putting the command on the stack,
below its arguments, and then invoking XC,
which will execute the command object left on the stack
(you can leave the command in a list, or in a program, etc.
because XC simply does an EVAL on whatever is there).


How it works:

Many CAS commands will fail if some particular variable exists;
the variable which the CAS thinks it needs to delete is
the variable whose name you store as "Independent variable"
in the MODES CAS screen, which is stored in 'VX' within CASDIR,
although for many more CAS commands (e.g. DERIV, RISCH, SOLVE, ISOL),
it should instead delete the variable named as an argument
on level 1, which the CAS doesn't even account for, causing it
often to delete the wrong variable and then still fail.

What XC does instead is to temporarily rename *both* the
variable named in VX *and* any variable named as a final
command argument on level 1, causing these variables
to become invisible to any CAS (symbolic) command whatsoever;
after the command completes, XC renames the variables back,
completely eliminating any conflicts between
existing variables and CAS commands.

XC also saves all modes and flags and remembers the current directory,
restoring them after the command completes, much like PUSH and POP,
eliminating the current effect (as of rom 1.19-6) that
all CAS commands otherwise leave your modes changed permanently
(they all leave you in RADian angle mode, for example).


Examples of use (RPN mode):

123 'X' STO 'X' STOVX @ create 'X' and set VX to 'X'
456 'Y' STO @ create 'Y' and store something

'2*X+5' { INTVX } XC @ integrate this expression w/r/t 'X'
Result: 'X^2+5*X' [without disturbing existing variable X]

'X-Y=5' 'Y' { SOLVE } XC @ solve this equation for 'Y'
Result: 'Y=X-5' [without disturbing existing Y or X]

Also leaves all modes and flags unchanged in each case, of course.


Example of a "custom" menu which you can create,
which performs all of its CAS commands
using XC to make them hassle-free:

{
{ DERVX \<< { DERVX } XC \>> }
{ INTVX \<< { INTVX } XC \>> }
{ SOLVE \<< { SOLVE } XC \>> }
{ TEXPAND \<< { TEXPAND } XC \>> }
{ } @ Etc.
STOVX @ no need to use XC for this command
} MENU @ becomes the CUSTOM menu in current (and lower) directory

You can also do exactly the same within a program,
substituting TMENU for the MENU command,
to display a temporary menu, instead of a permanent menu.


Instructions and program listings:

Important! -- If you are going to download or type these into
your calculator, instead of using the supplied pre-compiled
binary version, then you must *first* do HOME 256 ATTACH,
*before* downloading or typing, to make sure that
the special commands from built-in library 256
will be properly compiled.

The precompiled binary (for ROM versions 1.19-5 or later)
is a directory containing two programs, XC and VRENP,
plus additional variables $TITLE, $ROMID, $VISIBLE and $CONFIG,
which optionally can be used to make a library.

If you want to keep programs XC and VRENP in your HOME directory,
just copy these two items into HOME using the Filer.

If you prefer to store these programs as a library (faster execution),
first type HOME 256 ATTACH (and press ENTER),
then go into the precompiled directory and type CRLIB 2 STO <enter>
to store the library (XClib 1358) into flash port 2
(you may then need to do an ON+C warmstart to install the library).

After you have chosen between copying into HOME or creating a library,
you may purge the originally supplied precompiled binary directory.


This is the XC program:

\<< IF OVER TYPE 6. == THEN OVER ELSE RCLVX END
RCLF PATH \-> v. f. p. \<< v. VRENP RCLVX VRENP
-120. SF IFERR EVAL THEN 1. ELSE 0. END f. STOF p. EVAL
v. S~N NOT S~N VRENP RCLVX S~N NOT S~N VRENP
{ ERRN DOERR } IFT \>> \>> 'XC' STO

Note: ROM versions prior to 1.19-5 do not have a RCLVX command,
but you may substitute #C4007h FLASHEVAL for each RCLVX
if your ROM is older (type VERSION to check your ROM version).


The following creates a SysRPL program
which is used by XC to rename variables:

"D9D200036234133D9D20881309EB5079E6031BC39136251B502A170D9D20"
"03D53B7970A3B63CA620400960018A30B2130F046385230B2130B2130" +
DUP BYTES DROP #DB72h == { H\-> } IFT 'VRENP' STO

Note:

If VRENP ends up containing a string,
then there was a data transfer (or manual typing) error.


SysRPL source for VRENP (58.5 bytes, #AAFEh checksum):

( ID -> rename all occurrences in current path )
::
CK1&Dispatch
SIX
::
DUP ID>$ ' xNOT EvalNoCK $>ID
BEGIN
::
2DUPSWAP @ NOTcsdrpfls
FPTR2 ^RENAME TRUE
;
NOT_UNTIL 2DROP
;
;


A final note:

In very rare circumstances (e.g. interrupting an executing command),
some variable may be left in a renamed state, with some special
characters in its name (e.g. a variable originally named 'TD'
would have program delimiter characters in its temporary name);
if this ever happens, just put the current incorrect name ('xxx')
in single quotes on the stack, or recall the variable and then press
ANS, then type VRENP <enter> to restore the original variable name.


With best wishes for happy calculating, from http://www.mum.edu

GS

unread,
Aug 12, 2004, 1:23:03 AM8/12/04
to
Welcome back John!

- Greg S


"John H Meyers" <jhme...@miu.edu> wrote in message
news:opsckxbw...@news.cis.dfn.de...


> XC49 can perform hp49g CAS commands (in RPN mode)

[snip]


Bill Markwick

unread,
Aug 12, 2004, 3:10:14 AM8/12/04
to
John H Meyers <jhme...@miu.edu> wrote in message news:<opsckxbw...@news.cis.dfn.de>...
> XC49 can perform hp49g CAS commands (in RPN mode)
> so that they don't delete any variables,


John! Is it really you? Welcome back!

Bill

0 new messages