02-26-2017, 03:53 PM
HELLO
I'm trying to port a code, to replace IF THEN ELSE END, by IFTE
1: in many cases you must enclose the field to true and false between (), when you try it in history view
fail
ok
Original Code
2: A new IFT command is required, on a future firmware
The field for the false condition, I put an empty string, but this is rubbish and when running in the history view it looks bad
->
3: Now if the field of true or false have more than one statement the compiler generates an error, how to solve this?, I try to group sentences between [], but fails =(
All of the above for the purpose of running a CAS program step by step, placing each instruction in the history view
I'm trying to port a code, to replace IF THEN ELSE END, by IFTE
1: in many cases you must enclose the field to true and false between (), when you try it in history view
fail
PHP Code:
ifte( type(expr2) <> DOM_SYMBOLIC , partn:=string(expr2), partn:=conv2RPN3(expr2) );
ok
PHP Code:
ifte( type(expr2) <> DOM_SYMBOLIC , ( partn:=string(expr2) ), ( partn:=conv2RPN3(expr2) ) );
Original Code
PHP Code:
#pragma mode( separator(.,;) integer(h32) )
#cas
conv2RPN2(expr1):=
begin
local rpnStr, oper, partn, parts, partJ, expr2;
rpnStr:="";
oper:="";
partn:="";
if (type(expr1) <> DOM_SYMBOLIC) then
rpnStr:=string(expr1);
return(rpnStr);
end;
oper:=part(expr1,0);
parts:=part(expr1);
for partJ from 1 to parts do
expr2:=part(expr1,partJ);
if (type(expr2) <> DOM_SYMBOLIC) then
partn:=string(expr2);
else
partn:=conv2RPN2(expr2);
end;
if (partJ > 1) then rpnStr:=rpnStr + " "; end;
rpnStr:=rpnStr + partn;
if ((partJ > 1) or (parts == 1)) then
rpnStr:=rpnStr + " " + oper;
end;
end;
return(rpnStr);
end;
#end
PHP Code:
// convToRPN3(x^3);
#pragma mode( separator(.,;) integer(h32) )
#cas
convToRPN3(expr1):=
begin
local rpnStr, oper, partn, parts, partJ, expr2;
rpnStr:="";
oper:="";
partn:="";
ifte( type(expr1) <> DOM_SYMBOLIC, [ rpnStr:=string(expr1), return(rpnStr) ] );
oper:=part(expr1,0);
parts:=part(expr1);
for partJ from 1 to parts do
expr2:=part(expr1,partJ);
ifte( type(expr2) <> DOM_SYMBOLIC , ( partn:=string(expr2) ), ( partn:=conv2RPN3(expr2) ) );
ifte( partJ > 1 , ( rpnStr:=rpnStr + " " ), "" );
rpnStr:=rpnStr + partn;
if ((partJ > 1) or (parts == 1)) then
rpnStr:=rpnStr + " " + oper;
end;
end;
return(rpnStr);
end;
#end
2: A new IFT command is required, on a future firmware
The field for the false condition, I put an empty string, but this is rubbish and when running in the history view it looks bad
PHP Code:
ifte( partJ > 1 , ( rpnStr:=rpnStr + " " ), "" );
->
PHP Code:
ift( partJ > 1 , ( rpnStr:=rpnStr + " " ) );
3: Now if the field of true or false have more than one statement the compiler generates an error, how to solve this?, I try to group sentences between [], but fails =(
PHP Code:
ifte( type(expr1) <> DOM_SYMBOLIC, [ rpnStr:=string(expr1), return(rpnStr) ], "" );
All of the above for the purpose of running a CAS program step by step, placing each instruction in the history view