Post Reply 
is there a way to change the cas check in an existing program
07-14-2017, 09:38 AM
Post: #1
is there a way to change the cas check in an existing program
If I already have a program and I didn't set the CAS checkbox when I created it and I now wish to do so. Is there a way to do that and change the program to be a CAS program without having to create a new program?
Thx
-Donald
Find all posts by this user
Quote this message in a reply
07-14-2017, 10:23 AM
Post: #2
RE: is there a way to change the cas check in an existing program
Some links about the CAS programming and interaction between Home and CAS that you may find useful: Much more links about the Prime have been compiled by jebem here.
Find all posts by this user
Quote this message in a reply
07-14-2017, 10:54 AM
Post: #3
RE: is there a way to change the cas check in an existing program
Thank you....these are really useful links with some info I didn't have before.
However, they don't address if I can mix a #cas type program with a conventional EXPORT type program in the same program document. Is that possible....i.e. to have a home program and a cas program in the same program document?
Thx
-Donald
Find all posts by this user
Quote this message in a reply
07-14-2017, 11:45 AM
Post: #4
RE: is there a way to change the cas check in an existing program
(07-14-2017 10:54 AM)webmasterpdx Wrote:  Is that possible....i.e. to have a home program and a cas program in the same program document?
Yes, this is called the hybrid approach in the first link.
Find all posts by this user
Quote this message in a reply
07-14-2017, 11:47 AM
Post: #5
RE: is there a way to change the cas check in an existing program
I think you mean something like:
Code:
#cas
simpsonint(g,a,b,n):=
BEGIN
local l,l1;
IF even(n) THEN
IF (type(g)==DOM_SYMBOLIC  OR type(g)== DOM_FUNC)
  THEN 
   l:=MAKELIST(X,X,a,b,(b-a)/n);
     IF type(g)==DOM_SYMBOLIC THEN
     g:=unapply(g,x);
     END;
   l:=apply(g,l);
   l1:=MAKELIST(even(X)+1,X,1,n+1);
 return (2*DOT(l,l1)-g(a)-g(b))*(b-a)/(3*n);
   ELSE return ("f must be symbolic or function!");
  END;
 // return 0;
ELSE return "n must be even!";
END;

END;
#end


#cas
trapezregel(g,a,b,n):=
BEGIN
local l;
IF (type(g)==DOM_SYMBOLIC  OR type(g)== DOM_FUNC)
  THEN 
   l:=MAKELIST(X,X,a,b,(b-a)/n);
     IF type(g)==DOM_SYMBOLIC THEN
     g:=unapply(g,x);
     END;
   l:=apply(g,l);
   return (2*ΣLIST(l)-g(a)-g(b))*(b-a)/(2*n);
   ELSE return ("f must be symbolic or function!");
  END;
END;
#end


#cas
rightsum(g,a,b,n):=
BEGIN
local l;
IF (type(g)==DOM_SYMBOLIC  OR type(g)== DOM_FUNC)
  THEN 
   l:=MAKELIST(X,X,a,b,(b-a)/n);
     IF type(g)==DOM_SYMBOLIC THEN
     g:=unapply(g,x);
     END;
   l:=apply(g,l);
   return (ΣLIST(l)-g(a))*(b-a)/n;
   ELSE return ("f must be symbolic or function!");
  END;
END;
#end

#cas
leftsum(g,a,b,n):=
BEGIN
local l;
IF (type(g)==DOM_SYMBOLIC  OR type(g)== DOM_FUNC)
  THEN 
   l:=MAKELIST(X,X,a,b,(b-a)/n);
     IF type(g)==DOM_SYMBOLIC THEN
     g:=unapply(g,x);
     END;
   l:=apply(g,l);
   return (ΣLIST(l)-g(b))*(b-a)/n;
   ELSE return ("f must be symbolic or function!");
  END;
END;
#end

EXPORT NumericIntegr()
BEGIN
local a,N,f,b;
N:=12; a:=1;b:=3;
f:='X^2';
   if input(
     {{f,[8],{20,70,0}},
     {a,[0],{20,30,1}},
     {b,[0],{20,30,2}},
     {N,[0],{20,30,3}}},
     
     "Enter Data",
     {"f(X)=", "a= ", "b= ","N= "
      },
     {
       "Enter the function, upper case X!",
       "Enter the starting point",
       "Enter the endpoint",
       "Enter the amount of intervals"
      
     },
     {f,a,b,N}
   )
then
f:=lower(string(f));
PRINT();
PRINT("Simpsonsumme:   "+simpsonint(f,a,b,N));
PRINT("Trapezsumme:    "+trapezregel(f,a,b,N));
PRINT("Rechtecklinks:  "+leftsum(f,a,b,N));
PRINT("Rechteckrechts: "+rightsum(f,a,b,N));
return 
end;
END;
after you run it once the cas-functions are shown in memory manager whilst the main program can be seen in toolbox user menu (concerning your other thread)
Arno
Find all posts by this user
Quote this message in a reply
07-15-2017, 12:51 AM
Post: #6
RE: is there a way to change the cas check in an existing program
Thank you very much.
Find all posts by this user
Quote this message in a reply
07-18-2017, 07:00 AM
Post: #7
RE: is there a way to change the cas check in an existing program
Hello

"They don't address if I can mix a #cas type program with a conventional EXPORT type program in the same program document."

You can do this, but it might help to understand the subtle differences between home and CAS programs.

In home, Each program is a separate entity that contains it's global variables and functions (exported or not). A program can also be attached to an app. Programs are a grouped entity of object that, in some ways, know about each others...

in CAS, programs are just a chunk of text which gets parsed and evaluated at compile time (when the calculator starts and/or when you change a program text). This chunk of text can change/alter the CAS global state by changing setting and creating/updating global variables (remember that in the CAS, functions (as in a user program function) is a sequence of instruction that is stored in a global variable).

Thus, in HOME, if you declare a global variable, this global variable is "local" to this program, and 2 different programs can declare 2 non-conflicting global variable (or functions) with the same name without conflicts and issues. Not so much in the CAS where global variables re CAS global and not program global. So 2 cas programs can conflict with each others!

This being taken into concideration, you can create a mixed CAS/Home "program" (as in a source code that contains both home and CAS stuff) by using the #cas #end pairs as many times as you want.

Note that the stuff in between the #cas/#end gets parsed AND EVALUATED as soon as the #end is met!
This means that any symbols created in this area (even if they are created programmatically) are valid for the parsing of the following HOME code!

Cyrille

Although I work for the HP calculator group, the views and opinions I post here are my own. I do not speak for HP.
Find all posts by this user
Quote this message in a reply
Post Reply 




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