The Museum of HP Calculators

HP Forum Archive 21

[ Return to Index | Top of Index ]

Prime Error or Mine?
Message #1 Posted by toml_12953 on 20 Oct 2013, 10:36 p.m.

When I run the following program, the emulator crashes and the real calc reboots. What's the problem?

EXPORT HAT()
BEGIN
LOCAL XP,XL;
XP:=4;
XL:=INT(v(XP));
END;

This is part of a larger program but I cut it down to the part that causes the error. N.B. v is the square root sign.

Edited: 20 Oct 2013, 10:37 p.m.

      
Re: Prime Error or Mine?
Message #2 Posted by Michael de Estrada on 20 Oct 2013, 10:55 p.m.,
in response to message #1 by toml_12953

Try XL:=INT(v XP); or XL:=INT(sqrt(XP));

            
Re: Prime Error or Mine?
Message #3 Posted by toml_12953 on 20 Oct 2013, 11:03 p.m.,
in response to message #2 by Michael de Estrada

Well, sqrt seems to have worked. I wonder why the square root symbol crashes the program!

Thanks for the workaround.

Tom L

                  
Re: Prime Error or Mine?
Message #4 Posted by Michael de Estrada on 20 Oct 2013, 11:13 p.m.,
in response to message #3 by toml_12953

The reason is that INT stands for integral, whereas I assume you meant integer part, which is IP.

                  
Re: Prime Error or Mine?
Message #5 Posted by Tim Wessman on 21 Oct 2013, 1:16 a.m.,
in response to message #3 by toml_12953

The root cause of the crash had to do with a use of a local variable, inside a numerical command, inside a cas command, inside a numerical program. It was quite a difficult one to track down.

TW

      
Re: Prime Error or Mine?
Message #6 Posted by toml_12953 on 21 Oct 2013, 2:27 a.m.,
in response to message #1 by toml_12953

Thanks to all! I got the program working and here it is: (the v is the square root symbol)

EXPORT HAT()
BEGIN
LOCAL P,Q,XP,XR,YP,YR,ZP,ZF;
LOCAL XF,YF,ZF;
LOCAL ZI,ZT,ZZ,XL,XI,XT,XX,YY;
LOCAL X1,Y1; 
Xmin:=0;Xmax:=320;
Ymin:=0;Ymax:=240;
RECT();
P:=160;
Q:=100;
XP:=144;
XR:=1.5*PI;
YP:=56;
YR:=1;
ZP:=64;
XF:=XR/XP;
YF:=YP/YR;
ZF:=XR/ZP;
FOR ZI FROM -Q TO Q-1 DO
   IF ZI >= -ZP AND ZI <= ZP THEN
      ZT:=ZI*XP/ZP;
      ZZ:=ZI;
      XL:=IP(.5+v(XP*XP-ZT*ZT));
      FOR XI FROM -XL TO XL DO
         XT:=v(XI*XI+ZT*ZT)*XF;
         XX:=XI;
         YY:=(SIN(XT)+.4*SIN(3*XT))*YF;
         X1:=XX+ZZ+P;
         Y1:=YY-ZZ+Q;
         PIXON(X1,Y1,#FF0000h);
         IF Y1 <> 0 THEN
            LINE(X1,Y1-1,X1,0,#FFFFFFh)
         END;
      END;
   END;
END;
WAIT;
END;

Edited: 25 Oct 2013, 8:19 a.m. after one or more responses were posted

            
Re: Prime Error or Mine?
Message #7 Posted by Tim Wessman on 21 Oct 2013, 10:23 a.m.,
in response to message #6 by toml_12953

Nice! Can I buy one like that?

TW

            
Re: Prime Error or Mine?
Message #8 Posted by CompSystems on 21 Oct 2013, 12:55 p.m.,
in response to message #6 by toml_12953

The code with NTHROOT ready to be copied to the program editor =)

EXPORT HAT()
BEGIN
	LOCAL P,Q,XP,XR,YP,YR,ZP,ZF;
	LOCAL XF,YF,ZF;
	LOCAL ZI,ZT,ZZ,XL,XI,XT,XX,YY;
	LOCAL X1,Y1;
	Xmin:=0;Xmax:=320;
	Ymin:=0;Ymax:=240;
	RECT();
	P:=160;
	Q:=100;
	XP:=144;
	XR:=1.5*PI;
	YP:=56;
	YR:=1;
	ZP:=64;
	XF:=XR/XP;
	YF:=YP/YR;
	ZF:=XR/ZP;
	FOR ZI FROM -Q TO Q-1 DO
		IF ZI >= -ZP AND ZI <= ZP 
		THEN
				ZT:=ZI*XP/ZP;
				ZZ:=ZI;
				XL:=IP(0.5+2 NTHROOT (XP*XP-ZT*ZT));
				FOR XI FROM -XL TO XL DO
					XT:=2 NTHROOT (XI*XI+ZT*ZT)*XF;
					XX:=XI;
					YY:=(SIN(XT)+0.4*SIN(3*XT))*YF;
					X1:=XX+ZZ+P;
					Y1:=YY-ZZ+Q;
					PIXON(X1,Y1,#FF0000h);
					IF Y1 <> 0 
					THEN
							LINE(X1,Y1-1,X1,0,#FFFFFFh)
					END;
				END;
		 END;
	END;
	WAIT;
END;

for CAS MODE #FF0000h => RGB() =(

HAT():=
BEGIN
	LOCAL P,Q,XP,XR,YP,YR,ZP,ZF;
	LOCAL XF,YF,ZF;
	LOCAL ZI,ZT,ZZ,XL,XI,XT,XX,YY;
	LOCAL X1,Y1; 
	Xmin:=0;Xmax:=320;
	Ymin:=0;Ymax:=240;
	RECT();
	P:=160;
	Q:=100;
	XP:=144;
	XR:=1.5*PI;
	YP:=56;
	YR:=1;
	ZP:=64;
	XF:=XR/XP;
	YF:=YP/YR;
	ZF:=XR/ZP;
	FOR ZI FROM -Q TO Q-1 DO
		IF ZI >= -ZP AND ZI <= ZP 
		THEN
				ZT:=ZI*XP/ZP;
				ZZ:=ZI;
				XL:=IP(0.5+2 NTHROOT (XP*XP-ZT*ZT));
				FOR XI FROM -XL TO XL DO
					XT:=2 NTHROOT (XI*XI+ZT*ZT)*XF;
					XX:=XI;
					YY:=(SIN(XT)+0.4*SIN(3*XT))*YF;
					X1:=XX+ZZ+P;
					Y1:=YY-ZZ+Q;
					PIXON(X1,Y1,RGB(0,0,0) );
					IF Y1 <> 0 
					THEN
							LINE(X1,Y1-1,X1,0,RGB(255,255,255))
					END;
				END;
		 END;
END;
WAIT;
END;

Edited: 21 Oct 2013, 1:53 p.m.

                  
Re: Prime Error or Mine?
Message #9 Posted by toml_12953 on 21 Oct 2013, 3:37 p.m.,
in response to message #8 by CompSystems

Wow! When you indent, you REALLY indent!

Thanks for the alternative to hard to print characters.

Tom L

                        
Re: Prime Error or Mine?
Message #10 Posted by CompSystems on 21 Oct 2013, 4:00 p.m.,
in response to message #9 by toml_12953

>> Wow! When you indent, you REALLY indent!

Use the TAB character, in this forum is decoded with many spaces =(

                              
Re: Prime Error or Mine?
Message #11 Posted by Michael de Estrada on 21 Oct 2013, 4:20 p.m.,
in response to message #10 by CompSystems

What is the TAB character ?

Edited: 21 Oct 2013, 4:20 p.m.

                                    
Re: Prime Error or Mine?
Message #12 Posted by CompSystems on 21 Oct 2013, 5:26 p.m.,
in response to message #11 by Michael de Estrada

copy the following string in the entry line of the emulator

ASC("	")

ASC("	"); => {9}

Edited: 21 Oct 2013, 5:27 p.m.

                                          
Re: Prime Error or Mine?
Message #13 Posted by toml_12953 on 22 Oct 2013, 10:35 a.m.,
in response to message #12 by CompSystems

Quote:
copy the following string in the entry line of the emulator

ASC("	")

ASC("	"); => {9}


OK, that works. So how do we use the tab character to enter programs?

Tom L

Edited: 22 Oct 2013, 10:37 a.m.


[ Return to Index | Top of Index ]

Go back to the main exhibit hall