The Museum of HP Calculators

HP Forum Archive 21

[ Return to Index | Top of Index ]

How to save the definition of a CAS program or CAS function ?
Message #1 Posted by dg1969 on 19 Oct 2013, 9:48 a.m.

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...

      
Re: How to save the definition of a CAS program or CAS function ?
Message #2 Posted by CompSystems on 19 Oct 2013, 10:37 a.m.,
in response to message #1 by dg1969

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;

      
Re: How to save the definition of a CAS program or CAS function ?
Message #3 Posted by Han on 19 Oct 2013, 1:31 p.m.,
in response to message #1 by dg1969

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).

            
Re: How to save the definition of a CAS program or CAS function ?
Message #4 Posted by dg1969 on 19 Oct 2013, 1:48 p.m.,
in response to message #3 by Han

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 ...


[ Return to Index | Top of Index ]

Go back to the main exhibit hall