Post Reply 
INPUT CMD partially operating on CAS code
12-03-2016, 05:30 PM (This post was last modified: 12-04-2016 03:18 PM by compsystems.)
Post: #1
INPUT CMD partially operating on CAS code
The INPUT CMD is a DIALOG BOXES and is partially operating

if the variables are declared as local (coef1_a, coef2_b, coef3_c, coef4_d) do not work.

Commented the LOCAL VARIABLES
PHP Code:
#cas
    
INPUTtest( ) := 
    
begin
        
//local coef1_a, coef2_b, coef3_c, coef4_d; 
        //coef1_a := 9; coef2_b := 8; coef3_c := 7; coef4_d := 6;

        //local reset_coef1_a, reset_coef2_b, reset_coef3_c, reset_coef4_d; 
        //reset_coef1_a := 3; reset_coef2_b := 2; reset_coef3_c := 1; reset_coef4_d := 0;

        
local ObjectType_AllAllowed := -1;
        
local ObjectType_Real := 0;
        
local ObjectType_Integer := 1;
        
local ObjectType_String := 2;  
        
local ObjectType_Complex := 3;  
        
local ObjectType_Matrix := 4;
        
local ObjectType_List := 6;
        
local ObjectType_Function := 8;  
        
local ObjectType_Unit := 9;  
        
local ObjectType_CAS := 14;

        
local ok := 1;
        
local cancel := !ok;
        
local keyPress := 0;

        
local equequ1;
        
purgeab);

        print; 
// Clear Terminal Window
        
print( "Use cursor keys ↑↓ to move the output screen" );
        print( 
"Another key to continue after PAUSE" );
        print( 
"" );
        print( 
"[PAUSE]" ); wait();

        print; 
// Clear Terminal Window again
        
print( "***** Deduction Quadratic Formula *****" ); // Title
        
print( "" );

        print( 
"assume(a>0);" );
        
assumea>);

        
equ:= (a*x^2+b*x+c) = 0
        print( 
stringequ ) );
        print ( 
"[PAUSE]" ); wait( );

        
keyPress := msgboxequtrue );
        
//print( "Key press for MSGBOX CMD: " + ifte( keyPress == ok, keyPress + "=[OK/ENTER]", keyPress +  "=[ESC]" ) ); wait( );// 0 for [CANCEL], 1 for [OK/ENTER]
        
if keyPress == ok then

            
print( "Ans*4*a" );
            
equ := equ 4*a;         // ((a*x^2+b*x+c)*4*a) = 0 
            
print( stringequ ) );
            print( 
"" );
            
            print( 
"expand(Ans)" );
            
equ := expandequ );     // (4*a^2*x^2+4*a*b*x+4*a*c) = 0
            
print( stringequ ) );
            print( 
"" );

            print( 
"Ans+b^2" );    
            
equ := equ b^2;         // (4*a^2*x^2 +4*a*b*x + 4*a*c+b^2 ) = (b^2)
            
print( stringequ ) );
            print( 
"" );

            print( 
"Ans-4*a*c" );    
            
equ := equ 4*a*c;       // (4*a^2*x^2+4*a*b*x+4*a*c+b^2-4*a*c) = (b^2-4*a*c)
            
print( stringequ ) );
            print( 
"" );

            print( 
"simplify(Ans)" );    
            
equ := simplifyequ );   // (4*a^2*x^2+4*a*b*x+b^2) = (-4*a*c+b^2)  
            
print( stringequ ) );
            print( 
"" );

            print( 
"factor(Ans)" );    
            
equ := factorequ );     // (2*a*x+b)^2) = (-4*a*c+b^2)
            
print( stringequ ) );
            print( 
"" );

            print( 
"√(Ans)" ); 
            
assumeb>); assumec>);
            
equ := equ );          // (abs(2*a*x+b)) = (√(-4*a*c+b^2))
            
print( stringequ ) );
            print( 
"" );

            
            
equ := exprreplacestringequ ), "abs""" ) ); // (2*a*x+b) = (√(-4*a*c+b^2))
            
print( stringequ ) );
            print( 
"" );

            print( 
"Ans-b" );    
            
equ := equ b;           // (2*a*x+b-b) = (√(-4*a*c+b^2)-b)
            
print( stringequ ) );
            print( 
"" );

            print( 
"simplify(Ans)" );    
            
equ := simplifyequ );   // (2*a*x-b) = (√(-4*a*c+b^2)-2*b)
            
print( stringequ ) );
            print( 
"" );

            print( 
"Ans/(2*a)" );      
            
equ := equ / ( 2*);       // (2*a*x/(2*a)) = (-b+√(-4*a*c+b^2))/(2*a)
            
print( stringequ )  );
            print( 
""  );

            print( 
"simplify(Ans)"  );    
            
equ := simplifyequ );   // x1 = (-b+√(-4*a*c+b^2))/(2*a)
            
equ := exprreplacestringequ ), "x""x1" ) );
            print( 
stringequ )  );
            print( 
""  );

            print( 
"expr(replace(string(equ),"-b+","-b-"))" );
            
equ1 := exprreplacestringequ ), "-b+""-b-" ) ); // x2 = (-b-√[b^2-4*a*c])/(2*a) 
            
equ1 := exprreplacestringequ1 ), "x1""x2" ) );    
            print( 
stringequ1 )  ); 

            print( 
"[PAUSE]"  ); wait( );

            
//keyPress := 1;
            
keyPress := input( { {coef1_a, [ObjectType_Real]}, {coef2_b, [ObjectType_Real]}, {coef3_c, [ObjectType_Real]}, {coef4_d, [ObjectType_Real] } }, "1a x² + b x + c = 0 ? ax²+bx=d",  {"a:""b:""c:""d:"}, {"Enter coeff a""Enter coeff b""Enter coeff c""Enter coeff d"} , {reset_coef1_a,0,0,0}, {coef1_a,2,3,4} ) ;
            if 
keyPress == ok then
                a 
:= 1;
                
:= 2;
                
:= 3;
                
//a := coef1_a; 
                //b := coef2_b;
                //coef3_c := coef3_c-coef3_d; // => ax²+bx+c=0
                //c := coef3_c;
                
return([ eval(equ), eval(equ1) ]);
            
end;
        
end;

        return 
"done";
    
end;
#end 
INPUTtest(); [enter] open the INPUT DialogBox, but then [enter] returns "Error: Bad argument type" Why?

Now without comment do not execute anything
PHP Code:
#cas
    
INPUTtest():= 
    
begin
      local coef1_a
coef2_bcoef3_ccoef4_d
      
coef1_a:=9coef2_b:=8coef3_c:=7coef4_d:=6;

      
local reset_coef1_areset_coef2_breset_coef3_creset_coef4_d
      
reset_coef1_a:=3reset_coef2_b:=2reset_coef3_c:=1reset_coef4_d:=0;

      
local ObjectType_Real := 0;

      
input( { {coef1_a, [ObjectType_Real]}, {coef2_b, [ObjectType_Real]}, {coef3_c, [ObjectType_Real]}, {coef4_d, [ObjectType_Real] } }, "1a x² + b x + c = 0 ∨ ax²+bx=d",  {"a:""b:""c:""d:"}, {"Enter coeff a""Enter coeff b""Enter coeff c""Enter coeff d"} , {reset_coef1_a,0,0,0}, {coef1_a,2,3,4} ) ;
     
//...
      
return "done";
    
end;
#end 
INPUTtest(); [enter] INPUTtest() ?
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
INPUT CMD partially operating on CAS code - compsystems - 12-03-2016 05:30 PM
RE: INPUT CMD on CAS code - Han - 12-04-2016, 04:13 AM
RE: - compsystems - 12-04-2016, 02:09 PM
RE: INPUT CMD on CAS code - DrD - 12-04-2016, 03:12 PM



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