Post Reply 
How to save a CAS program
07-24-2014, 05:55 PM
Post: #1
How to save a CAS program
As I noted in this post http://www.hpmuseum.org/forum/thread-1864.html the Prime will rewrite CAS program to its own taste. In a program similar to the one in that post (CASE to PIECEWISE), I used the Sto key instad of the := combination for initializing some local variables. The Prime then replaced some of those Sto with an equal = sign (intead of the := combination). Running that program it reports "unitialized variable" when encountering = intead of :=. I tried to edit the = to :=, but since the program does not pass the Check test, it will to record any edits and ... forever.

So, does anybody know how to actually make these edits to CAS programs recorded? Thank you!
Find all posts by this user
Quote this message in a reply
07-29-2014, 05:08 AM
Post: #2
RE: How to save a CAS program
If I try to initialize local variables with the STO key in a CAS program, the program doesn't even compile.

I can change that to :=, e.g., LOCAL a:= 1; the program compiles and runs OK (even multiple times), as long as I don't open the program for editing. Once I try to edit the program, the line now reads LOCAL a; and running the same program as before returns "uninitialized local variable."

So it seems to me that you have to assign values to your local variables on separate lines. Do you even need the local statements? My programs seem to run fine without them.
Find all posts by this user
Quote this message in a reply
07-29-2014, 06:36 AM
Post: #3
RE: How to save a CAS program
(07-29-2014 05:08 AM)Helge Gabert Wrote:  If I try to initialize local variables with the STO key in a CAS program, the program doesn't even compile.

I can change that to :=, e.g., LOCAL a:= 1; the program compiles and runs OK (even multiple times), as long as I don't open the program for editing. Once I try to edit the program, the line now reads LOCAL a; and running the same program as before returns "uninitialized local variable."

So it seems to me that you have to assign values to your local variables on separate lines.

The loss of the LOCAL assignments in CAS programs is a known bug. As you mention, the workaround is to declare them first, then assign their values in subsequent lines.

(07-29-2014 05:08 AM)Helge Gabert Wrote:  Do you even need the local statements? My programs seem to run fine without them.

I suggest not omitting the LOCAL declaration. Doing so is a Bad Thing (even though the program will run), because (1) if that variable already exists as a global CAS variable, then its contents will silently be blown away by your program, which would be most unfortunate if that variable contains a CAS program or anything else you don't want silently blown away, and (2) if the variable does not already exist as a global variable, then it will be created as a global CAS variable, and thus clutter up your CAS variable list and waste memory.

<0|ɸ|0>
-Joe-
Visit this user's website Find all posts by this user
Quote this message in a reply
07-29-2014, 02:19 PM
Post: #4
RE: How to save a CAS program
I'm missing CAS programs in backup and in Connectivity kit.
(added this to tricider.com)

Are your CAS programs visible in Connectivity kit ?
Find all posts by this user
Quote this message in a reply
07-29-2014, 03:31 PM
Post: #5
RE: How to save a CAS program
(07-29-2014 06:36 AM)Joe Horn Wrote:  
(07-29-2014 05:08 AM)Helge Gabert Wrote:  If I try to initialize local variables with the STO key in a CAS program, the program doesn't even compile.

I can change that to :=, e.g., LOCAL a:= 1; the program compiles and runs OK (even multiple times), as long as I don't open the program for editing. Once I try to edit the program, the line now reads LOCAL a; and running the same program as before returns "uninitialized local variable."

So it seems to me that you have to assign values to your local variables on separate lines.

The loss of the LOCAL assignments in CAS programs is a known bug. As you mention, the workaround is to declare them first, then assign their values in subsequent lines.

(07-29-2014 05:08 AM)Helge Gabert Wrote:  Do you even need the local statements? My programs seem to run fine without them.

I suggest not omitting the LOCAL declaration. Doing so is a Bad Thing (even though the program will run), because (1) if that variable already exists as a global CAS variable, then its contents will silently be blown away by your program, which would be most unfortunate if that variable contains a CAS program or anything else you don't want silently blown away, and (2) if the variable does not already exist as a global variable, then it will be created as a global CAS variable, and thus clutter up your CAS variable list and waste memory.

Thanks for the info!
Find all posts by this user
Quote this message in a reply
07-30-2014, 08:31 AM
Post: #6
RE: How to save a CAS program
(07-29-2014 02:19 PM)Thomas_Sch Wrote:  I'm missing CAS programs in backup and in Connectivity kit.
(added this to tricider.com)

Are your CAS programs visible in Connectivity kit ?

Short answer: Yes, they are properly backed up and restored by the Connectivity Kit, but no, they are not displayed within the Connectivity Kit itself.

Full answer: All your CAS variables (including your CAS programs) are saved in the "cas.settings" file when you perform a backup. They are all backed up and restored properly by the Connectivity Kit, but they are not shown (for some reason) within the Connectivity Kit's user interface. I hope they add that feature at some point. Meanwhile, just check the Prime itself (or emulator) to see its CAS variables.

<0|ɸ|0>
-Joe-
Visit this user's website Find all posts by this user
Quote this message in a reply
07-30-2014, 08:55 AM
Post: #7
RE: How to save a CAS program
(07-30-2014 08:31 AM)Joe Horn Wrote:  Short answer: Yes, they are properly backed up and restored by the Connectivity Kit, but no, they are not displayed within the Connectivity Kit itself.

Full answer: All your CAS variables (including your CAS programs) are saved in the "cas.settings" file when you perform a backup. They are all backed up and restored properly by the Connectivity Kit, but they are not shown (for some reason) within the Connectivity Kit's user interface. I hope they add that feature at some point. Meanwhile, just check the Prime itself (or emulator) to see its CAS variables.

Hello Joe,

Many thanks for your answer and the details. I looked for separate files in the backup, but could not find them. Now I'm a bit satisfied.
But in my opinion it's ugly, though the source code for the CAS programs is not available in the connectivity kit.

Thomas
Find all posts by this user
Quote this message in a reply
07-30-2014, 02:36 PM
Post: #8
RE: How to save a CAS program
The basic issue boils down to this: CAS programs are not really programs but rather saved function objects. There is no difference between f(x)->x^2 and a much more complicated func()->begin...end that has hundreds of lines.

What this means is that there is no way to save them separately or differently at this point in time. There are several possible solutions/workarounds, but all of them are dependent on some other things that are quite tricky to implement and in order to resolve completely will requires some significant changes/updates.

In short, no matter how big or large the CAS "program", you really should think of them as a function definition and the restrictions/behavior in place currently suddenly makes much more sense.

TW

Although I work for HP, the views and opinions I post here are my own.
Find all posts by this user
Quote this message in a reply
07-30-2014, 03:22 PM (This post was last modified: 07-30-2014 03:23 PM by parisse.)
Post: #9
RE: How to save a CAS program
But then why make a difference, what about being able to save any CAS function individually in the connectivity kit ? In fact, the other way is the most interesting, import a CAS function written with a PC keyboard to the Prime. What I would like to do (and probably most users who need a CAS program) is: write/debug/test my function inside Xcas on the PC, then run it on the Prime. I can copy/paste from the PC to the Prime emulator but not to the Prime. I can save the program in Xcas as text as progname.cas, but I can not send it to the Prime.
Find all posts by this user
Quote this message in a reply
07-30-2014, 05:47 PM
Post: #10
RE: How to save a CAS program
Seconded.
Find all posts by this user
Quote this message in a reply
07-30-2014, 08:17 PM
Post: #11
RE: How to save a CAS program
(07-30-2014 03:22 PM)parisse Wrote:  ... I can copy/paste from the PC to the Prime emulator but not to the Prime. I can save the program in Xcas as text as progname.cas, but I can not send it to the Prime.

That's another reason, why the "SEND" button should be re-activated for ALL prime variants.

In my opinion the internal representation as a CAS function should be translated to the user: if you call it a program, it should behave like a program.
Find all posts by this user
Quote this message in a reply
07-31-2014, 07:48 AM
Post: #12
RE: How to save a CAS program
(07-30-2014 08:17 PM)Thomas_Sch Wrote:  In my opinion the internal representation as a CAS function should be translated to the user: if you call it a program, it should behave like a program.

I don't understand what you mean, a CAS program has the same internal structure a CAS user-defined function, it's a symbolic object with program as root-node.
Find all posts by this user
Quote this message in a reply
07-31-2014, 11:47 AM (This post was last modified: 07-31-2014 12:27 PM by Thomas_Sch.)
Post: #13
RE: How to save a CAS program
(07-31-2014 07:48 AM)parisse Wrote:  
(07-30-2014 08:17 PM)Thomas_Sch Wrote:  In my opinion the internal representation as a CAS function should be translated to the user: if you call it a program, it should behave like a program.

I don't understand what you mean, a CAS program has the same internal structure a CAS user-defined function, it's a symbolic object with program as root-node.

What I mean: As a program it should have the same functionality like Home-programs, like visibilty in connection kit, and transfer functions between emulator and real calc. It's more adressed to Tim / HP.
Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 1 Guest(s)