 Testing ANSWER cmd - 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: Testing ANSWER cmd (/thread-7683.html) Testing ANSWER cmd - compsystems - 01-29-2017 05:37 PM Hello, the following statements Written on CAS history print("test ANS cmd"); id0:=0+1; print("ans1: "+Ans); // ans1: 1 id0:=1+1; print("ans2: "+Ans); // ans2: 2 id0:=2+1; print("ans3: "+Ans); // ans3: 3 show in the terminal view test ANS cmd ans1: 1 ans2: 2 ans3: 3 But within a program PHP Code: `#cas    anscmd():=    begin                       print;          print("test ANS cmd");        id0:=0+1;        print("ans1: "+Ans); // ans1: 1        id0:=1+1;        print("ans2: "+Ans); // ans2: 2        id0:=2+1;        print("ans3: "+Ans); // ans3: 3#end ` test ANS cmd ans1: 0 ans2: 0 ans3: 0 Why? The following CAS code Requires storing each statement in an identifier, and you can not use 'Ans' Cmd =( PHP Code: `#cas  script1():=  begin    local eq1, eq2, sol, answer;      print;    purge(x,y);      print("Find the dimensions of a rectangle whose area is 45 and its perimeter 28");    print("METHOD 1 (Algebraic solution, stepwise)");        print("Let x = long, y = width");   print("");        print("The equations are:");        eq1:=x*y=45;        print("eq1: "+eq1);     eq2:=2x+2y=28;     print("eq2: "+eq2);     print("");    answer:=factor(eq2); // -> (2*(x+y)) = 28    print("factor(eq2): "+answer);    print("");    answer:=answer/2; // ->(2*(x+y)/2) = 14    print("Ans/2: "+answer);    answer:=simplify(answer); // -> (x+y) = 14    print("simplify(Ans): "+answer);    print("");    sol:= y=solve(answer,y); //  y = (-x+14)    print("sol(Ans,y): "+sol);    print("");    //answer:= (eq1|sol);    answer:=subst(eq1,sol); //  -> (x*(-x+14)) = 45    print("subst(eq1,answer): "+answer);    answer:=simplify(answer); // -> (-x^2+14*x) = 45    print("simplify(Ans): "+answer);    print("");    sol:=solve(answer,x); // -> {5,9}    print("sol(Ans,x): x1,2="+sol);    print("");    print("test solutions");    answer:=(eq1|{x=sol, y=sol});    print("eq1: "+answer);    answer:=evalBool(answer,'=','==');    print("eq1: "+answer);    print("");    answer:=(eq2|{x=sol, y=sol});    print("eq2: "+answer);    answer:=evalBool(answer,'=','==');    print("eq2: "+answer);    return "Done";  end;#end#cas  evalBool( expr1, str1, str2 ):=  begin   return( ifte( subst(expr1, str1, str2 ), "TRUE", "FALSE") );  end;#end ` RE: Testing ANSWER cmd - KeithB - 01-30-2017 05:07 PM I think ANS is a keyboard only thing that is there for convenience. It does not work on my HP71B, either, though that has a much clearer demarcation between "BASIC mode" and "CALC mode". Though, I really like the () notation to get ans into an equation.