HP Forums
error editing a CAS program outside the program editor - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html)
+--- Forum: HP Prime (/forum-5.html)
+--- Thread: error editing a CAS program outside the program editor (/thread-14410.html)



error editing a CAS program outside the program editor - compsystems - 01-25-2020 12:36 AM

Hello

There was an error editing a CAS program outside the program editor.
Steps to reproduce the error.

press the keys [shift]+[1] + Menu: [new]
Name: fract1
CAS: ✔
then [ok]
PHP Code:
#cas
fract1():=
BEGIN
|
END;
#end 
Position the cursor between BEGIN ... END;
if you are operating the simulator copy and paste the next code (Mandelbrot fractal)

In HPConnectivity Kit program editor (2020) still does not allow to put a template for functions of type CAS ={

PHP Code:
EXPORT fract1()
BEGIN

END

the EXPORT statement must be removed, then add the #cas directive and the assignment operator :=
In other words, better select all, and delete the template and start writing.


// Mandelbrot fractal
PHP Code:
#cas
fract1(X_,Y_,Nmax):=
BEGIN
  local x
,y,z,c,j,w,h,res1,res2;
  
freeze;
  
w:=2.7/X_;
  
h:=-1.87/Y_;
  
res1:=[]; 
  
Y_:=Y_-1;
  for 
y from 0 to Y_ do
    
c:=-2.1+i*(h*y+0.935);
    for 
x from 0 to X_-do
      
z:=0;
      for 
j from 0 to Nmax-do
        if 
abs(z:=z^2+c)>2 then break; end;
      
end;
      
res1.append(pixon_p(x,y,126*j+2079));
      
c:=c+w;
    
end;
   
end;
   return 
"Done"
END;
#end 

fract1(320,240,10) [enter] correctly draw the fractal [esc] for exit
then
[shift]+[mem] CAS Vars [enter]
fract1 [edit]
the code is shown as
PHP Code:
(X_,Y_,Nmax)->BEGIN  
 LOCAL x
,y,z,c,j,w,h,res1,res2
  
freeze;  
  
w:=(2.7/X_);  
  
h:=(−1.87/Y_);  
  
res1:=copy(NULL);  
  
Y_:=Y_-1;  
  FOR 
y FROM 0 TO Y_ DO  
  
c:=−2.1+i*(h*y+0.935); 
  FOR 
x FROM 0 TO X_-DO  
  
z:=0
  FOR 
j FROM 0 TO Nmax-DO IF (ABS(z:=z^2+c))>2 THEN BREAK ;  END 
  
END;; 
  
res1::append(pixon_p(x,y,126*j+2079)); 
  
c:=c+w
  
END;; 
  
END;;  
  RETURN(
Done);  
END
[enter] [edit] [enter] [esc]

fract1(320,240,10) [enter] stays in an infinite cycle
[esc] "append(res1,pixon_p(x,y,126*j+2079)) in fract1(320,240,10) instruction #15 error, try debug(fract1(320,240,10))
Error: Bad Argument Value"

I think the problem is that the COPY() Xcas function is not yet incorporated into the more recent firmware

when writing
PHP Code:
res1:=[]; 

it is recoded as
PHP Code:
res1:=copy(NULL); 

In HPConnectivity Kit shown as
PHP Code:
res1:=undef