10 rem Portability enhancement by David Meyer (2012/2/4)
 20 def FNA(P,Q)=-1*P*Q
 30 def FNO(P,Q)=SGN(P+Q)
 40 def FNN(P)=-1*P-1
 50 def FNI(P,A,B)=ABS(P)*A+ABS(FNN(P))*B
 60 def FNI$(P,A$,B$)=LEFT$(A$,ABS(P)*LEN(A$))+LEFT$(B$,ABS(FNN(P))*LEN(B$))
 70 def FNY(A$,Q)=FNI(LEN(A$)=0,Q,FNO(LEFT$(A$,1)="Y",LEFT$(A$,1)="y"))
 80 print tab(28);"AMAZING PROGRAM"
 90 print tab(15);"CREATIVE COMPUTING  MORRISTOWN, NEW JERSEY"
100 print
110 print
120 print
130 print
140 input "WHAT ARE YOUR WIDTH AND LENGTH";H,L
150 if FNA(H<>1,L<>1) then goto 180
160 print "MEANINGLESS DIMENSIONS.  TRY AGAIN."
170 goto 140
180 dim W(H,L),V(H,L)
190 print
200 print
210 print
220 print
230 Q=0
240 Z=0
250 X=INT(RND*H+1)
260 for I=1 to H
270   if I=X then goto 300
280   print ".--";
290   goto 310
300   print ".  ";
310 next I
320 print "."
330 C=1
340 W(X,1)=C
350 C=C+1
360 R=X : S=1
370 goto 480
380 if R<>H then goto 460
390 if S<>L then goto 430
400 R=1
410 S=1
420 goto 470
430 R=1
440 S=S+1
450 goto 470
460 R=R+1
470 if W(R,S)=0 then goto 380
480 if R-1=0 then goto 830
490 if W(R-1,S)<>0 then goto 830
500 if S-1=0 then goto 650
510 if W(R,S-1)<>0 then goto 650
520 if R=H then goto 560
530 if W(R+1,S)<>0 then goto 560
540 X=INT(RND(1)*3+1)
550 on X goto 1210,1280,1350
560 if S<>L then goto 600
570 if Z=1 then goto 630
580 Q=1
590 goto 610
600 if W(R,S+1)<>0 then goto 630
610 X=INT(RND*3+1)
620 on X goto 1210,1280,1440
630 X=INT(RND*2+1)
640 on X goto 1210,1280
650 if R=H then goto 750
660 if W(R+1,S)<>0 then goto 750
670 if S<>L then goto 700
680 if Z=1 then goto 730
690 Q=1 : goto 710
700 if W(R,S+1)<>0 then goto 730
710 X=INT(RND*3+1)
720 on X goto 1210,1350,1440
730 X=INT(RND*2+1)
740 on X goto 1210,1350
750 if S<>L then goto 790
760 if Z=1 then goto 820
770 Q=1
780 goto 800
790 if W(R,S+1)<>0 then goto 820
800 X=INT(RND*2+1)
810 on X goto 1210,1440
820 goto 1210
830 if S-1=0 then goto 1040
840 if W(R,S-1)<>0 then goto 1040
850 if R=H then goto 960
860 if W(R+1,S)<>0 then goto 960
870 if S<>L then goto 910
880 if Z=1 then goto 940
890 Q=1
900 goto 920
910 if W(R,S+1)<>0 then goto 940
920 X=INT(RND*3+1)
930 on X goto 1280,1350,1440
940 X=INT(RND*2+1)
950 on X goto 1280,1350
960 if S<>L then goto 1000
970 if Z=1 then goto 1030
980 Q=1
990 goto 1010
1000 if W(R,S+1)<>0 then goto 1030
1010 X=INT(RND*2+1)
1020 on X goto 1280,1440
1030 goto 1280
1040 if R=H then goto 1140
1050 if W(R+1,S)<>0 then goto 1140
1060 if S<>L then goto 1100
1070 if Z=1 then goto 1130
1080 Q=1
1090 goto 1290
1100 if W(R,S+1)<>0 then goto 1130
1110 X=INT(RND*2+1)
1120 on X goto 1350,1440
1130 goto 1350
1140 if S<>L then goto 1180
1150 if Z=1 then goto 1200
1160 Q=1
1170 goto 1190
1180 if W(R,S+1)<>0 then goto 1200
1190 goto 1440
1200 goto 1610
1210 W(R-1,S)=C
1220 C=C+1
1230 V(R-1,S)=2
1240 R=R-1
1250 if C=H*L+1 then goto 1620
1260 Q=0
1270 goto 480
1280 W(R,S-1)=C
1290 C=C+1
1300 V(R,S-1)=1
1310 S=S-1
1320 if C=H*L+1 then goto 1620
1330 Q=0
1340 goto 480
1350 W(R+1,S)=C
1360 C=C+1
1370 if V(R,S)=0 then goto 1400
1380 V(R,S)=3
1390 goto 1410
1400 V(R,S)=2
1410 R=R+1
1420 if C=H*L+1 then goto 1620
1430 goto 830
1440 if Q=1 then goto 1510
1450 W(R,S+1)=C : C=C+1 : if V(R,S)=0 then goto 1480
1460 V(R,S)=3
1470 goto 1490
1480 V(R,S)=1
1490 S=S+1 : if C=H*L+1 then goto 1620
1500 goto 480
1510 Z=1
1520 if V(R,S)=0 then goto 1560
1530 V(R,S)=3
1540 Q=0
1550 goto 1610
1560 V(R,S)=1
1570 Q=0
1580 R=1
1590 S=1
1600 goto 470
1610 goto 380
1620 for J=1 to L
1630   print "I";
1640   for I=1 to H
1650     if V(I,J)<2 then goto 1680
1660     print "   ";
1670     goto 1690
1680     print "  I";
1690   next I
1700   print
1710   for I=1 to H
1720     if V(I,J)=0 then goto 1760
1730     if V(I,J)=2 then goto 1760
1740     print ":  ";
1750     goto 1770
1760     print ":--";
1770   next I
1780   print "."
1790 next J
1800 end