The Museum of HP Calculators

HP Forum Archive 21

[ Return to Index | Top of Index ]

[HP-Prime xCAS] My first program
Message #1 Posted by CompSystems on 29 Aug 2013, 11:40 a.m.

What generates an error when calculating the sum of polynomials?

Quote:
EXPORT PolynomialsTools() // Syntax: () // Command Info: Polynomials Tools // Author: CompSystems // Version: 0.07 Sep 5 2013 BEGIN

Local RedColor := { 255, 0, 0 }; // Declara y define los valores del RED Color Local RedBlack := { 0, 0, 0 }; // Declara y define los valores del Black Color Local RedWhite := { 255, 255, 255 }; // Declara y define los valores del WhiteColor Local Font_12 := 2; // Fuente de texto de alto Local Font_14 := 3; Local Font_16 := 4; Local mult:=18; // multiplicador para aumentar a la siguiente linea de texto

Local polyCoef1, polyCoef2, operPCoeff1_2, operType, ChooseOut1, InputOut1, InputOut2, ExprAsStr; // Declara variables locales

Rect_p(); // Limpia la ventana de graficos usada como salida del programa FREEZE(); // Congela la ventana de graficos RECT_P( 1, 1, 318, 238, RGB( 0, 0, 0 ), RGB( 255, 255, 255 ) ); // Dibuja un rectangulo de fondo RECT_P( 1, 1, 318, 16, RGB( 0, 0, 0 ), RGB( 0, 0, 0 ) ); // Dibuja un rectangulo para el titulo

//LOCAL COO1:= { 0, 0 }, COO2:= { 319, 239 }; // Definicion de coordenadas //RECT_P( { 0, 0 } , { 319, 239 } , RGB( WhiteColor ), RGB( RedColor ); // no acepta lista de coordenadas =( //RECT_P( COO1 , COO2 , RGB( WhiteColor ), RGB( RedColor ); // ni llamar a un avarible como coordenada =(

TEXTOUT_P( "PolynomialsTools", 3, 3, Font_12, RGB( 0,148,255 ) ); wait(2);

// ChooseOut1: = Choose( operType, "Choose Operation", { { " Addition", "+" } , { " Difference", "-" }, { " Mul", "*" } , { " Div", "/" } } ); // sentencia aun no soportada =( // If ChooseOut1 == true ... // sirve para reutilizar el valor de ChooseOut1 mas abajo // Then // WAIT(); // para visualizar la entrada en el campo superior // Else kill; // End; //If

If Choose( operType, "Choose Operation", { { " Addition", "+" } , { " Difference", "-" }, { " Mul", "*" } , { " Div", "/" } } ) Then Case // Como choose actualmente no admite listas con varios parametros tengo que hacer un selector para llevar el # a una opcion =( If operType == 1 Then operType := "+"; End; If operType == 2 Then operType := "-"; End; If operType == 3 Then operType := "*"; End; If operType == 4 Then operType := "/"; End; // Default End; End;//If

// Asigna a las variables anteriores por una caja de dialogo

InputOut1:= Input( polyCoef1, "Polynomials Tools", "PolyCoef1 = ", "Input coeffs of a poly1 c1*x^n + c2*x^n-1 +...+ c3*x + c4" ); If InputOut1 == true Then WAIT(); // para visualizar la entrada en el campo superior Else kill; End; //If

InputOut2 := Input( polyCoef2, "Polynomials Tools", "PolyCoef2 = ", "Input coeffs of a poly2 c1*x^n + c2*x^n-1 +...+ c3*x + c4" ); If InputOut2 == true Then WAIT(); // para visualizar la entrada en el campo superior Else kill; End; //If

Rect_p(); // Limpia la ventana de graficos usada como salida del programa FREEZE(); // Congela la ventana de graficos

// Redibuja la ventana por que comando CHOOSE se sale de la actual, espero que HP solucione esto en la proxima version RECT_P( 1, 1, 318, 238, RGB( 0, 0, 0 ), RGB( 255, 255, 255 ) ); // Dibuja un rectangulo de fondo RECT_P( 1, 1, 318, 16, RGB( 0, 0, 0 ), RGB( 0, 0, 0 ) ); // Dibuja un rectangulo para el titulo TEXTOUT_P( "PolynomialsTools", 3, 3, Font_12, RGB( 0,148,255 ) );

If operType == "/" Then ExprAsStr:= "polyCoef1 " + "," + " polyCoef2"; //operPCoeff1_2 := expr( propfrac(ExprAsStr) ) ; // calcula la operacion operPCoeff1_2 := "expr( propfrac(" + ExprAsStr + ")" ; // calcula la operacion TEXTOUT_P( "polyCoef1 " + operType + " polyCoef2: " , 3, mult, Font_14, RGB( 0, 0, 0 ) ); // Despliega la operacion calculada entre los polinomios Else ExprAsStr:= "polyCoef1 " + operType + " polyCoef2 "; operPCoeff1_2 := expr( ExprAsStr ) ; // calcula la operacion TEXTOUT_P( ExprAsStr + ": " , 3, mult, Font_14, RGB( 0, 0, 0 ) ); // Despliega la operacion calculada entre los polinomios End;//If

TEXTOUT_P( polyCoef1 + " " + operType + " " + polyCoef2 + " = " + operPCoeff1_2, 3, mult*2, Font_16, RGB( 0, 0, 0 ) ); // Despliega el valor de la operacion de los polinomios, forma de coeficientes

// la siguiente sentencia falla en la version actual del emulador 2013/8/13 =( TEXTOUT_P( "poly2Symb(polyCoef1)" + " " + operType + " " + "poly2Symb(polyCoef2)" + " = " + operPCoeff1_2, 3, mult*3, Font_16, RGB( 0, 0, 0 ) ); // Despliega el valor de la operacion de los polinomios, forma de expresion math

//CAS; // or // CAS(); // retorna a la pantalla o ventana CAS

// ejemplos

// (x^2+3)+(x) => x^2+x+3 // como expresion algebraica // [ 1, 0, 3 ] + [ 1, 0 ] => [ 1, 1, 3 ]

// (x^2+3)/(x) => x+(3/x) // como expresion algebraica // [ 1, 0, 3 ] / [ 1, 0 ] => { [1,0], 3/[1,0] }

END;


http://www.adictoshp.org/topic/413-hp-prime-xcas-my-first-program/

Edited: 5 Sept 2013, 1:06 p.m. after one or more responses were posted

      
Re: [HP-Prime xCAS] My first program
Message #2 Posted by Pal G. on 29 Aug 2013, 3:32 p.m.,
in response to message #1 by CompSystems

Nice program. Sorry it is not working.

Can you tell me if the HP connectivity kit for prime is available so we can duplicate your program? It looks easier to use than the emulator for programming.

Thank you,

PG

            
Re: [HP-Prime xCAS] My first program
Message #3 Posted by Namir on 29 Aug 2013, 5:12 p.m.,
in response to message #2 by Pal G.

Using the emulator you can enter programs from source text files using the following steps:

1. Type in the program in your favorite text edit. You can also copy a program from another source. I recommend that you paste it in your favorite text editor to detect ad remove control and extended ASCII character.

2. Copy the text in your editor.

3. Using the HP emulator, create a program with the same name.

4. Edit the program and delete all that the emulator has created.

5. Use the edit | Paste command to paste the source code.

6. Click the Check button to make sure that the program you pasted has no errors detectable by the emulator.

7. Correct any errors that are flagged.

8 Exit the emulator's editor.

9. Run the program

            
Re: [HP-Prime xCAS] My first program
Message #4 Posted by debrouxl on 30 Aug 2013, 1:51 a.m.,
in response to message #2 by Pal G.

Yup, the connectivity kit (HP_Connectivity_Kit.zip) is available from the same location as the firmware upgrades, a location which was previously leaked to this forum :)

      
Re: [HP-Prime xCAS] My first program
Message #5 Posted by CompSystems on 31 Aug 2013, 11:41 a.m.,
in response to message #1 by CompSystems

updated to version 0.03 =)

            
Re: [HP-Prime xCAS] My first program
Message #6 Posted by CompSystems on 5 Sept 2013, 1:06 p.m.,
in response to message #5 by CompSystems

updated to version 0.07 =)

                  
Re: [HP-Prime xCAS] My first program
Message #7 Posted by Pier Aiello on 5 Sept 2013, 2:04 p.m.,
in response to message #6 by CompSystems

A small OT: i don't analyze your request/bug report on this forum but your reports seems "serious", so i feel that i should acknowledge your commitment to the hp prime.


[ Return to Index | Top of Index ]

Go back to the main exhibit hall