The solution to the puzzle for those that are interested. Should work in both PBWIN and PBCC.
Code:
#COMPILE EXE
#DIM ALL
'#DEBUG DISPLAY ON
#INCLUDE ONCE "WIN32API.INC"
%north =0
%east =1
%south =2
%west =3
%odd =1
%even =0
TYPE plotter
x AS LONG
y AS LONG
klr AS LONG
END TYPE
MACRO grp = GRAPHIC PRINT
MACRO gsp = GRAPHIC SET POS
MACRO gpx = GRAPHIC GET POS
FUNCTION PBMAIN () AS LONG
LOCAL gWin, fnt, ndx1, cx, cy, xxx, yyy, clr, stp, bmp, side, klr, nwin, x, y AS LONG
LOCAL top_side, pixl, lap, ndx, last, mx, mn, most, fn AS LONG
LOCAL north(),east(), south(), west() AS LONG
LOCAL plot(), asis() AS plotter
top_side = 400
last=FIX(top_side/2)
FONT NEW "Lucida Console", 12, 0 TO fnt
GRAPHIC WINDOW NEW "", 10,10,400,400 TO gWin
hndled gwin 'hndled without the parameter is now equal to gWin and globally available
GRAPHIC SET OVERLAP 1
GRAPHIC SET FONT fnt
GRAPHIC RENDER BITMAP "puzzle1.bmp"; (0,0)-(399,399)
REDIM asis(1 TO (top_side*top_side)) AS plotter
'get and store each pixel from the puzzle image and replace colour with black
FOR ndx=1 TO (top_side*top_side)
asis(ndx).x=x
asis(ndx).y=y
GRAPHIC GET PIXEL (asis(ndx).x, asis(ndx).y) TO asis(ndx).klr
GRAPHIC SET PIXEL (asis(ndx).x, asis(ndx).y), %BLACK
INCR x
IF x=400 THEN
INCR y
x=0
END IF
NEXT ndx
'calculate the pixel target locations
most= top_side-1
mx= last-1
mn= 0
REDIM north(0 TO mx,1 TO 2)
yyy=0
FOR ndx=mn TO mx
north(ndx,1)=ndx
north(ndx,2)=most
DECR most
NEXT ndx
most= top_side-1
REDIM east(0 TO mx,1 TO 2)
xxx=most
FOR ndx=mn TO mx
east(ndx,1)=ndx+1
east(ndx,2)=most
DECR most
NEXT ndx
most= top_side-2
REDIM south(0 TO mx,1 TO 2)
yyy=top_side-1
FOR ndx=mn TO mx
south(ndx,1)= most
south(ndx,2)= ndx
DECR most
NEXT ndx
mx=last-2
most= top_side-2
REDIM west(0 TO mx,1 TO 2)
xxx=mn
FOR ndx=mn TO mx
west(ndx,1)= most
west(ndx,2)= ndx+1
DECR most
NEXT ndx
'put the target locations in an array
REDIM plot(1 TO (top_side*top_side)) AS plotter
yyy=0
DO
SELECT CASE AS LONG side
CASE %north
IF lap>UBOUND(north,1) THEN EXIT
FOR ndx1=north(lap,1) TO north(lap,2)
INCR pixl
xxx=ndx1
plot(pixl).x=xxx
plot(pixl).y=yyy
NEXT ndx1
INCR side
CASE %east
FOR ndx1=east(lap,1) TO east(lap,2)
INCR pixl
yyy =ndx1
plot(pixl).x=xxx
plot(pixl).y=yyy
NEXT ndx1
INCR side
CASE %south
FOR ndx1=south(lap,1) TO south(lap,2) STEP -1
INCR pixl
xxx =ndx1
plot(pixl).x=xxx
plot(pixl).y=yyy
NEXT ndx1
INCR side
CASE %west
IF lap>UBOUND(west,1) THEN EXIT
FOR ndx1=west(lap,1) TO west(lap,2) STEP -1
INCR pixl
yyy =ndx1
plot(pixl).x=xxx
plot(pixl).y=yyy
NEXT ndx1
INCR side
CASE 4
INCR lap
side=0
END SELECT
LOOP WHILE pixl < (top_side*top_side)
GRAPHIC WINDOW NEW "", 410,10,400,400 TO nwin
GRAPHIC SET OVERLAP 1
hndled2 nwin
show_it plot(), asis()
message " X"
GRAPHIC WINDOW END hndled
GRAPHIC WINDOW END hndled2
TXT.END
END FUNCTION
SUB show_it (plot() AS plotter, asis() AS plotter)
LOCAL ndx AS LONG
message "Continue"
GRAPHIC ATTACH hndled2,0
FOR ndx=LBOUND(asis()) TO UBOUND(asis())
GRAPHIC SET PIXEL (plot(ndx).x,plot(ndx).y), asis(ndx).klr
NEXT ndx
END SUB
FUNCTION hndled(OPT value AS LONG) AS LONG ' only use optional parameter to set the feature
STATIC vault AS LONG
IF ISMISSING(value) THEN
IF vault=0 THEN
EXIT FUNCTION 'get outta here
ELSE
FUNCTION = vault
EXIT FUNCTION
END IF
ELSEIF value=0 THEN
EXIT FUNCTION
ELSE
IF vault=0 THEN ' prevent further assignments to vault
vault=value
END IF
END IF
FUNCTION = vault
END FUNCTION
FUNCTION hndled2(OPT value AS LONG) AS LONG ' only use optional parameter to set the feature
STATIC vault AS LONG
IF ISMISSING(value) THEN
IF vault=0 THEN
EXIT FUNCTION 'get outta here
ELSE
FUNCTION = vault
EXIT FUNCTION
END IF
ELSEIF value=0 THEN
EXIT FUNCTION
ELSE
IF vault=0 THEN ' prevent further assignments to vault
vault=value
END IF
END IF
FUNCTION = vault
END FUNCTION
SUB message(alert AS STRING)
LOCAL bmp, fnt, wx, wy, ww, wh, ax, ay, tw, ty, a, b, c, d, e AS LONG
LOCAL f AS POINT
FONT NEW "Lucida Console", 12, 1 TO fnt
IF UCASE$(TRIM$(alert))= "X" THEN e=1 ' upper case x to exit
alert=WRAP$(alert, " ", " ")
GRAPHIC TEXT SIZE alert TO tw, ty
GRAPHIC ATTACH hndled, 0
GRAPHIC SET FONT fnt
GRAPHIC TEXT SIZE alert TO tw, ty
GRAPHIC GET SIZE TO ww, wh
GRAPHIC GET LOC TO wx, wy
ClientToScreen(hndled, f)
ax=ww-tw+f.x-10
ay=f.y
GRAPHIC WINDOW NEW "", 3000, ay, tw, ty TO bmp
GRAPHIC WINDOW HIDE bmp
SetWindowPos(bmp, %HWND_TOPMOST, ax, ay, tw, ty, %SWP_NOMOVE OR %SWP_NOSIZE)
' keep this window on top of main window
GRAPHIC ATTACH bmp, 0
GRAPHIC SET FONT fnt
IF ISTRUE e THEN
GRAPHIC COLOR %BLACK, %RED ' for program exit purposes
ELSE
GRAPHIC COLOR %BLACK, %YELLOW ' for other uses
END IF
GRAPHIC PRINT alert
GRAPHIC WINDOW NORMALIZE bmp
GRAPHIC SET LOC ax, ay
GRAPHIC SET FOCUS
DO
SLEEP 0
GRAPHIC INSTAT TO d ' message
GRAPHIC WINDOW CLICK TO c, a, b ' mouse click
LOOP WHILE ISFALSE (c OR d)
FONT END fnt
GRAPHIC WINDOW END bmp
GRAPHIC ATTACH hndled, 0
FONT NEW "Lucida Console", 12, 0 TO fnt
GRAPHIC SET FOCUS
END SUB