DECLARE STRUCTURE struct2: 2 OF NUMERIC
DECLARE MESSAGE buff OF struct2
PARACT part1
OPTION ARITHMETIC NATIVE
DECLARE NUMERIC left,right,h
START part2
LET left = -2
LET right= .8                             
LET h = (right - left) 
SET WINDOW left, right,-h/2,h/2  
DRAW axes  
SET POINT STYLE 1
DECLARE NUMERIC px,py
ASK PIXEL SIZE(left,-h/2;right,h/2) px,py
SEND TO buff FROM px,py
DECLARE EXTERNAL SUB mandelb
call mandelb(0,int(px/2),int(py/2),py)
END PARACT

PARACT part2
OPTION ARITHMETIC NATIVE
DECLARE NUMERIC px,py
RECEIVE FROM buff TO px,py
DECLARE EXTERNAL SUB mandelb
CALL mandelb(INT(px/2)+1,px,INT(py/2),py)
END PARACT

EXTERNAL SUB mandelb(a0,a1,b0,b1)
OPTION ARITHMETIC NATIVE
DECLARE NUMERIC a,b,u,v,x,y,n,x1,y1
FOR a=a0 TO a1
   LET u=problemx(a)
   FOR b=b0 TO b1
      LET v=problemy(b)
      LET x = 0                                
      LET y = 0                                
      WHEN EXCEPTION IN
         FOR n = 1 TO 250
            LET x1 = x^2 - y^2 + u
            LET y1 = 2 * x * y + v
            LET x = x1
            LET y = y1
         NEXT n
         PLOT POINTS: u,v
         PLOT POINTS: u,-v
      USE
      END WHEN
   NEXT b
NEXT a                                        
END SUB


