The Museum of HP Calculators

HP Forum Archive 21

[ Return to Index | Top of Index ]

HP PRIME - Crash with "REPLACE" cmd ?
Message #1 Posted by dg1969 on 21 Oct 2013, 3:25 p.m.

Hi,

These code sometime crash the emulator sometime not...

If in the input saisie() I place : "1/((1+X)*(1+10*X))"

The REPLACE command in saisie():

REPLACE("1/((1+X)*(1+10*X))","X","(i*X)") works great !

but at the next stage in bode() :

REPLACE("1/((1+(i*X))*(1+10*(i*X)))","X","ALOG(X)")

The emulator crash !

If I place a basic transfert function on input promp "1/(1+X)" every thing go well...

Who have an idea ?

Another question if someone can help... This program can be run from any APP but in the end we are left either in black or bode APP.

Will he has a way of storing what is the active applet at launch ? In order to activate this app at the end.

Assumes that applets "Bode" and "Black" were created derived from function app for Bode and parametric app for Black. Here is my actuel code... The manipulation of symbolic expressions inside a program is very confusing for me.

saisie();
bode();
black();
EXPORT FT;

// main program which ask first for transfer function and then for type of plots EXPORT SLDI()

BEGIN LOCAL choix;

FT:=""; saisie(); RECT(); CHOOSE(choix,"Quel tracé ?", "BODE", "BLACK"); CASE IF choix==1 THEN bode(); END; IF choix==2 THEN black(); END; END; END;

// Ask for a transfert function but in a string form ! double quotes ! saisie() BEGIN input(FT,"Entrez la fonction de transfert","FT(X)=","Utilisation des guillemets ! "); FT:=REPLACE(FT,"X","(i*X)"); END;

// Creation of module and agr functions then start "Bode" APP bode() BEGIN LOCAL fc:=0, FF:=""; FF:=REPLACE(FT,"X","ALOG(X)"); Bode.F1:="20*LOG(ABS(" + FF + "))"; Bode.F2:="ARG("+ FF + ")"; STARTAPP("Bode"); UNCHECK(0); UNCHECK(2); CHECK(1); //Look for 3dB drop pulsation and look around fc:=ROOT(ABS(Bode.F1(-1000)-Bode.F1(X))-3,0); Bode.Xmin:=fc-1.5; Bode.Xmax:=fc+1.5; STARTVIEW(10); END;

black() BEGIN LOCAL fc:=0, FF:=""; FF:=REPLACE(FT,"X","T"); Black.X1:="ARG("+FF+")"; Black.Y1:="20*LOG(ABS(" + FF + "))"; STARTAPP("Black"); CHECK(1); //looking for 3dB drop pulsation fc:=ROOT(ABS(Black.Y1(0)-Black.Y1(X))-3,1); Black.Tmin:=0; Black.Tmax:=10*fc; STARTVIEW(10); END;

Edited: 22 Oct 2013, 6:36 a.m.


[ Return to Index | Top of Index ]

Go back to the main exhibit hall