How to save the definition of a CAS program or CAS function ?



#2

Hi,

I have a few questions...

1)If I define a CAS function or a CAS program then I can edit the code on the a physical calc from the program editor but CAS programs never appear in the "programmed" tab from Connectivity Kit.


2) All my work on CAS programs disappear after a simple "shift clear" on CAS view history!!! How to save the definition of a CAS program or CAS function ?

Thanks for your help...


#3

Quote:
1)If I define a CAS function or a CAS program then I can edit the code on the a physical calc from the program editor but CAS programs never appear in the "programmed" tab from Connectivity Kit.

2) All my work on CAS programs disappear after a simple "shift clear" on CAS view history!!! How to save the definition of a CAS program or CAS function ?


Also happens with virtual calculator, the file transfer program (HP-Connectivity Kit) is not detecting CAS mode programs, I expect a urgent update of software Connection, also all the programs I am writing from physical calculator I can lose, with the current version I can not send the programs I have written in CAS mode

Any alternative way to send the following code to my physical calculator

main( ):=
BEGIN
CONJUGATE() := BEGIN true; END;
SYMBOLIC() := BEGIN true; END;
RETURN( OK );
END;


getType( Data0 ):=
BEGIN
LOCAL TypeN, TypeID, RealType, ObjStr;

TypeID := type( Data0 );

IFERR
TYPE( Data0 )
THEN
RealType := "ERROR";
ObjStr := "ERROR";
ELSE
TypeN := TYPE( Data0 );
ObjStr := STRING( Data0 );
END;

CASE
IF TypeID == DOM_FLOAT
THEN
RealType := "RealNumber";
END;

IF TypeID == DOM_INT
THEN
RealType := "IntegerNumber";
END;

IF TypeID == DOM_COMPLEX
THEN
IF inString( ObjStr,"(" ) >= 1
THEN
RealType := "CooComplexNumber";
ELSE
RealType := "AlgComplexNumber";
END;
END;

IF TypeID == DOM_RAT
THEN
IF inString( ObjStr, string( i ) ) >= 1
THEN
RealType := "RatComplexNumber";
ELSE
RealType := "RationalNumber";
END;
END;

IF TypeID == DOM_SYMBOLIC
THEN
IF inString( string( Data0 ), "=" ) >= 1
THEN
RealType := "Equation";
ELSE
RealType := "AlgExpression";
END;
END;

IF TypeID == DOM_IDENT
THEN
RealType := "Identifier";
END;


IF TypeID == DOM_STRING
THEN
RealType := "String";
END;

IF TypeID == DOM_FUNC
THEN
RealType := "Function";
END;

IF TypeID == DOM_LIST
THEN
CASE
IF inString( ObjStr, "poly1[" ) >= 1
THEN
RealType := "PolynomialCoeff";
END;

IF inString( ObjStr, "set[" )>= 1
THEN
RealType := "Set";
END;

IF inString( ObjStr, "[[" ) >= 1
THEN
RealType := "Matrix";
END;

IF inString( ObjStr, "[" ) >= 1
THEN
RealType := "Vector";
END;

IF inString( ObjStr, "{" ) >= 1 OR inString( ObjStr, "{[" ) >= 1
THEN
RealType := "List";
END;

DEFAULT RealType := "Other Type LIST";

END;
END;

IF TypeN == 8
THEN
RealType := "Unit";
END;

IF TypeID == 21
THEN
RealType := "HMS";
END;


IF TypeN == 1
THEN

CASE
IF inString( ObjStr, "d" ) >= 1
THEN
RealType := "DecNumber";
END;

IF inString( ObjStr, "b" ) >= 1
THEN
RealType := "BinNumber";
END;

IF inString( ObjStr, "h" ) >= 1
THEN
RealType := "HexNumber";
END;

IF inString( ObjStr, "o" ) >= 1
THEN
RealType := "OctNumber";
END;

DEFAULT RealType := "Other Base";

END;

END;

DEFAULT RealType := "Other";

END;

RETURN( RealType );

END;

partString( Str0, StrP ):=
BEGIN
LOCAL FlagBadArg;
FlagBadArg:= "false";

IF NOT( ( getType( Str0 ) == "String" ) AND ( NOT( Str0 == "" ) ) )
THEN
FlagBadArg := "true";
IF NOT( MSGBOX( "partString: Invalid Data Type for 1 Arg", true ) )
THEN kill;
END;
END;

IF NOT( ( getType( StrP ) == "String" ) AND ( NOT( StrP == "" ) ) )
THEN
FlagBadArg := "true";
IF NOT( MSGBOX( "partString: Invalid Data Type for 2 Arg", true ) )
THEN kill;
ELSE kill;
END;
END;


IF FlagBadArg == "false"
THEN
RETURN( convertToRealBoolean( inString( Str0, StrP ) ) );
ELSE
RETURN( "Invalid Data Type" );
END;

END;

convertToRealBoolean( Object0 ):=
BEGIN
IF isBooleanDataType( Object0 ) == "true"
THEN

IF getType( Object0 ) == "String"
THEN
Object0 := expr( Object0 );
END;
IF Object0 <= 0
THEN
RETURN( "false" );
ELSE
RETURN( "true" );
END;

ELSE
IF NOT( MSGBOX( "convertToRealBoolean: Invalid Data Type", true ) )
THEN kill;
ELSE kill;
END;
END;

END;

isBooleanDataType( Object ):=
BEGIN
LOCAL FlagBadArg, ObjectType;
FlagBadArg:= "false";

ObjectType := getType( Object );
IF NOT( POS( { "RealNumber", "IntegerNumber", "RationalNumber", "String" }, ObjectType ) )
THEN
FlagBadArg := "true";
END;

IF FlagBadArg == "true"
THEN
RETURN( "false" );
ELSE
IF ObjectType == "String"
THEN
ObjectType:= expr( Object );
IF isNumber( ObjectType ) == "true"
THEN RETURN( "true" );
ELSE RETURN( "false" );
END;
ELSE
RETURN( "true" );
END;
END;
END;

isNumber( Object ):=
BEGIN
LOCAL ObjectType;
ObjectType:= getType( Object );

IF POS( { "RealNumber", "IntegerNumber", "RationalNumber" }, ObjectType )
THEN
RETURN( "true" );
ELSE
RETURN( "false" );
END;
END;

isComplexNumber( Object ):=
BEGIN
LOCAL ObjectType;
ObjectType:= getType( Object );

IF POS( { "CooComplexNumber", "AlgComplexNumber", "RatComplexNumber" }, ObjectType )
THEN
RETURN( "true" );
ELSE
RETURN( "false" );
END;
END;

isEquation( Object ):=
BEGIN
LOCAL FitObject;
IFERR
EVAL( Object );
THEN
FitObject := Object;
ELSE
FitObject := EVAL( Object );
END;

IF getType( FitObject ) == "Equation"
THEN
RETURN( "true" );
ELSE
RETURN( "false" );
END;
END;

eqToExpr( Eq ):=
BEGIN
IF isEquation( Eq ) == "true"
THEN
RETURN( expr( replace( string( Eq ), "=" , "-(" ) + ")" ) );
ELSE
RETURN( Eq );
END;
END;

transpose2( Array, Test0 ):=
BEGIN
LOCAL FlagBadArg;
FlagBadArg:= "false";

IF NOT( POS( { "Vector", "Matrix" }, getType( Array ) ) )
THEN
FlagBadArg := "true";
IF NOT( MSGBOX( "transpose2: Invalid Data Type for 1 arg", true ) )
THEN kill;
END;
END;

IF NOT( isBooleanDataType( Test0 ) == "true" )
THEN
FlagBadArg := "true";
IF NOT( MSGBOX( "transpose2: Invalid Data Type for 2 arg", true ) )
THEN kill;
ELSE kill;
END;
ELSE
Test0 := convertToRealBoolean( Test0 );
END;

IF FlagBadArg == "false"
THEN
IF Test0 == "true"
THEN
RETURN( TRN( Array ) );
ELSE
RETURN( transpose( Array ) );
END;
ELSE
RETURN( "Invalid Data Type" );
END;

END;


toPoly1var( Object, Var, Test ):=
BEGIN
LOCAL FlagBadArg, FitPoly, ObjectType;
FlagBadArg:= "false";

ObjectType := getType( Object );

IF NOT( POS( { "AlgExpression", "Equation", "Identifier", "RealNumber", "IntegerNumber",
"AlgComplexNumber", "RatComplexNumber", "RationalNumber", "PolynomialCoeff", "Vector" }, ObjectType ) )
THEN
FlagBadArg := "true";
IF NOT( MSGBOX( "toPoly1var: Invalid Data Type for 1 arg", true ) )
THEN kill;
END;
END;

IF NOT( getType( Var ) == "Identifier" )
THEN
FlagBadArg := "true";
IF NOT( MSGBOX( "toPoly1var: Invalid Data Type for 2 arg", true ) )
THEN kill;
END;
END;

IF NOT( isBooleanDataType( Test ) == "true" )
THEN
FlagBadArg := "true";
IF NOT( MSGBOX( "toPoly1var: Invalid Data Type for 3 arg", true ) )
THEN kill;
ELSE kill;
END;
ELSE
Test := convertToRealBoolean( Test );
END;


IF FlagBadArg == "false"
THEN
CASE

IF ObjectType == "PolynomialCoeff"
THEN
IF Test == "true"
THEN
RETURN( poly2symb( ObjectType, Var ) );
ELSE
RETURN( ObjectType );
END;
END;

IF ObjectType == "Vector"
THEN
FitPoly := expr( "poly1" + Object );
IF Test == "true"
THEN
RETURN( poly2symb( FitPoly, Var ) );
ELSE
RETURN( FitPoly );
END;
END;

IF isEquation( Object ) == "true"
THEN
FitPoly := eqToExpr( Object );
IF Test == "false"
THEN
RETURN( symb2poly( FitPoly, Var ) );
ELSE
RETURN( FitPoly );
END;
END;

DEFAULT
IF Test == "false"
THEN
RETURN( symb2poly( Object, Var ) );
ELSE
RETURN( Object );
END;
END;

ELSE
RETURN( "Invalid Data Type" );
END;
END;


polyCoeffToArray( Poly ):=
BEGIN
LOCAL FlagBadArg;
FlagBadArg:= "false";

IF NOT( POS( { PolynomialCoeff }, getType( Poly ) ) )
THEN
FlagBadArg := "true";
IF NOT( MSGBOX( "polyCoeffToArray: Invalid Data Type for 1 arg", true ) )
THEN kill;
END;
END;

IF FlagBadArg == "false"
THEN
RETURN := expr( replace( string( Poly ), "poly1" , "" ) );
ELSE
RETURN( "Invalid Data Type" );
END;

END;

collectPolTerms( Poly, Var ):=
BEGIN
LOCAL FlagBadArg;
FlagBadArg:= "false";

IF NOT( POS( { "AlgExpression", "Equation", "Identifier", "RealNumber", "IntegerNumber",
"AlgComplexNumber", "RationalNumber", "RatComplexNumber" }, getType( Poly ) ) )
THEN
FlagBadArg := "true";
IF NOT( MSGBOX( "collectPolTerms:Invalid Data Type for 1 arg", true ) )
THEN kill;
END;
END;

IF NOT( getType( Var ) == "Identifier" )
THEN
FlagBadArg := "true";
IF NOT( MSGBOX( "collectPolTerms:Invalid Data Type for 2 arg", true ) )
THEN kill;
ELSE kill;
END;
END;

IF FlagBadArg == "false"
THEN
IF isEquation( Poly ) == "true"
THEN
Poly := toEq( eqToExpr );
END;
RETURN( sum( coeff( Poly, Var ) .* seq( Var^k, k, degree( Poly ), 0, 1 ) ));
ELSE
RETURN( "Invalid Data Type" );
END;
END;

randPoly2( Pdim, Il, Sl, Var, Test ):=
BEGIN
LOCAL Rp;
Rp := randPoly( Pdim, expr( Il + ".." + Sl ) );
RETURN( toPoly1var( Rp, Var, Test ));
END;


polyToCoeff( Poly, Var ):=
BEGIN
LOCAL PolyFnt, Out, Cnt0, Temp0;
purge( Pol );

IF isEquation( Poly ) == "true"
THEN
Poly := eqToExpr( Poly );
END;
expr( Pol(Var)+":="+string( Poly ) );
Out := MAKELIST( 0, Cnt1, degree( Poly ), 0, 1 );
Cnt0:=0;
WHILE Pol(Var) <> 0 DO
Temp0 := Pol(Var) / (Cnt0!) ;
Out[ Cnt0 ] := ( Temp0 | Var=0 );
Cnt0 := Cnt0 + 1;

Pol(Var) := diff( Pol(Var), Var);

END;
Out := expr( "poly1[" + string( REVERSE(Out) ) + "]");
RETURN( Out );
END;


#4

There was a lengthy discussion about CAS programs a while back, but I think the general consensus was that users wanted to have the ability to create CAS programs with the program editor (and not by command line).

Let's hope in the next firmware that we see not only this feature, but the ability to save CAS programs as well (see Compsystem's post).


#5

Han, CompSystems thanks for your fast answer !

Sorry to reopen this discussion. I did not follow. Not always easy to find an old discussion on this forum ...


Possibly Related Threads...
Thread Author Replies Views Last Post
  HP Prime: CAS taylor Alberto Candel 5 372 12-13-2013, 09:45 PM
Last Post: Alberto Candel
  HP50g: Writing a function that returns a function Chris de Castro 2 264 12-10-2013, 06:49 PM
Last Post: Han
  HP Prime CAS curiosity bluesun08 11 576 12-10-2013, 01:03 PM
Last Post: Han
  WP-34S (Emulator Program Load/Save) Barry Mead 1 194 12-09-2013, 05:29 PM
Last Post: Marcus von Cube, Germany
  [HP-Prime CAS] "Warning, ^ (Command) Is ambiguous on non square matrices"?? CompSystems 1 229 12-07-2013, 07:15 PM
Last Post: CompSystems
  HP Prime: complex numbers in CAS. Alberto Candel 1 187 12-06-2013, 02:36 PM
Last Post: parisse
  HP Prime: Proper Use of Home View and CAS View James Williams 9 511 12-05-2013, 02:44 PM
Last Post: James Williams
  [HP Prime] plotfunc() bug in CAS Chris Pem10 2 227 12-04-2013, 02:46 PM
Last Post: Chris Pem10
  HP Prime: Home/CAS? Alasdair McAndrew 11 568 11-26-2013, 02:48 PM
Last Post: Alberto Candel
  HP Prime numerical precision in CAS and HOME Javier Goizueta 5 336 11-16-2013, 03:51 AM
Last Post: Paul Dale

Forum Jump: