Post Reply 
Wow tried putting this program in the HP Guide:
05-19-2019, 01:51 PM
Post: #1
Wow tried putting this program in the HP Guide:
Program Listing
local x1:=160, x2:=299, x3:=21 local y1:=0, y2:=240, y3:=240 local xn:=160, yn:=0;
local a, b, color;
EXPORT Sierpinski()
BEGIN
RECT();
FOR a FROM 1 TO 10000 STEP 1 DO
b:=RANDINT(2)+1;
CASE
IF b=1 THEN xn:=(xn+x1)/2; yn:=(yn+y1)/2;END; IF b=2 THEN xn:=(xn+x2)/2; yn:=(yn+y2)/2;END; IF b=3 THEN xn:=(xn+x3)/2; yn:=(yn+y3)/2;END; END;
color:=RGB(255-a/40,0,a/40); PIXON_P(IP(xn),IP(yn),color); END;
WAIT;
END;

/////

Well, it didn't work couldn't get by line 2 with an error code?
Find all posts by this user
Quote this message in a reply
05-19-2019, 02:21 PM
Post: #2
RE: Wow tried putting this program in the HP Guide:
Line 2 is missing semicolons before the LOCAL keywords;

Code:
local x1:=160, x2:=299, x3:=21; local y1:=0, y2:=240, y3:=240; local xn:=160, yn:=0;

or more aesthetically pleasing
Code:
local x1:=160, x2:=299, x3:=21;
local y1:=0, y2:=240, y3:=240;
local xn:=160, yn:=0;

Or just put all 8 variables in one LOCAL declaration.
Code:
local x1:=160, x2:=299, x3:=21, y1:=0, y2:=240, y3:=240, xn:=160, yn:=0;

Eight is the max though. If you have more than eight, you have to split them into separate LOCAL statements.

I couldn't find this program in the User Guide. What page is it on?
Find all posts by this user
Quote this message in a reply
05-19-2019, 02:42 PM
Post: #3
RE: Wow tried putting this program in the HP Guide:
Code:

local x1:=160, x2:=299, x3:=21;
local y1:=0, y2:=240, y3:=240;
local xn:=160, yn:=0;
local a, b, color;

EXPORT Sierpinski()
BEGIN
  RECT();
  FOR a FROM 1 TO 10000 STEP 1 DO
    b:=RANDINT(2)+1;
   CASE
     IF b=1 THEN xn:=(xn+x1)/2; yn:=(yn+y1)/2;END;
     IF b=2 THEN xn:=(xn+x2)/2; yn:=(yn+y2)/2;END;
     IF b=3 THEN xn:=(xn+x3)/2; yn:=(yn+y3)/2;END;
   END; 
   color:=RGB(255-a/40,0,a/40);
   PIXON_P(IP(xn),IP(yn),color);
  END;
  WAIT;
END;
Find all posts by this user
Quote this message in a reply
05-19-2019, 02:57 PM
Post: #4
RE: Wow tried putting this program in the HP Guide:
How about 10 of them?

Code:

local x1:=160, x2:=299, x3:=21;
local y1:=0, y2:=240, y3:=240;
local xn:=160, yn:=0;
local a, b, color;

EXPORT Sierpinski()
BEGIN
  RECT();
  FOR N FROM 1 TO 10 DO
    FOR a FROM 1 TO 10000 STEP 1 DO
      b:=RANDINT(2)+1;
     CASE
       IF b=1 THEN xn:=(xn+x1)/2; yn:=(yn+y1)/2;END;
       IF b=2 THEN xn:=(xn+x2)/2; yn:=(yn+y2)/2;END;
       IF b=3 THEN xn:=(xn+x3)/2; yn:=(yn+y3)/2;END;
     END; 
     color:=RGB(255-a/40,0,a/40);
     PIXON_P(IP(xn),IP(yn),color);
    END;
    WAIT(2);
  END;  
END;
Find all posts by this user
Quote this message in a reply
05-19-2019, 04:44 PM
Post: #5
RE: Wow tried putting this program in the HP Guide:
(05-19-2019 02:57 PM)DrD Wrote:  How about 10 of them?

Code:

local x1:=160, x2:=299, x3:=21;
local y1:=0, y2:=240, y3:=240;
local xn:=160, yn:=0;
local a, b, color;

EXPORT Sierpinski()
BEGIN
  RECT();
  FOR N FROM 1 TO 10 DO
    FOR a FROM 1 TO 10000 STEP 1 DO
      b:=RANDINT(2)+1;
     CASE
       IF b=1 THEN xn:=(xn+x1)/2; yn:=(yn+y1)/2;END;
       IF b=2 THEN xn:=(xn+x2)/2; yn:=(yn+y2)/2;END;
       IF b=3 THEN xn:=(xn+x3)/2; yn:=(yn+y3)/2;END;
     END; 
     color:=RGB(255-a/40,0,a/40);
     PIXON_P(IP(xn),IP(yn),color);
    END;
    WAIT(2);
  END;  
END;

/////
It works thank you know I know it's me.
Find all posts by this user
Quote this message in a reply
05-20-2019, 04:43 AM
Post: #6
RE: Wow tried putting this program in the HP Guide:
Hello,

export Sier2()
begin
rect;
local a=#0;
while a<#160 do
local b= #0;
while b<#160 do
pixon_p(a and b, a or b, 0);
b:= b+#1;
end;
a:= a+#1;
end;
freeze;
end;

Cyrille

Although I work for the HP calculator group, the views and opinions I post here are my own. I do not speak for HP.
Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 1 Guest(s)