Post by Admin on Jan 16, 2020 4:38:21 GMT
How to use:
Copy and paste this program in BBC BASIC editor and save it to a WRITEABLE location you can find easy
In the BLUE rectangular area there is a TEXT BOX
USE the reference to the left and the color bar to help you make your designs
Once done press z in the TEXT BOX and press enter and a file called "data.bas" will be created
OPEN the file called "data.bas" and you will find your generated code
ADD
MODE 8
to the top of the program AND
END
at the base of the program
THEN
add the TURTLE LIBRARY to the end of the program (it is located in this forum)
Copy and paste this program in BBC BASIC editor and save it to a WRITEABLE location you can find easy
In the BLUE rectangular area there is a TEXT BOX
USE the reference to the left and the color bar to help you make your designs
Once done press z in the TEXT BOX and press enter and a file called "data.bas" will be created
OPEN the file called "data.bas" and you will find your generated code
ADD
MODE 8
to the top of the program AND
END
at the base of the program
THEN
add the TURTLE LIBRARY to the end of the program (it is located in this forum)
MODE 8
REM dw$(100) is word commands and dn%(100) is the amt%
DIM dw$(100),dn%(100)
cou%=0:REM this is counter for dim commands
amt%=0
A=OPENOUT(@usr$+"data.bas")
VDU 5
REM created January 15, 2020
GCOL 15
REM set up color ref
PROCcolorref(5,400)
PROCturtle("m",600)
PROCturtle("d",1)
REPEAT
REPEAT
mmm$= FNinput(500,500,20)
UNTIL LEN(mmm$)>1 :REM trying to stop user error
PROCwd(mmm$,cmd$,amt%)
dw$(cou%)=cmd$:dn%(cou%)=amt%
finfo$= "PROCt("+CHR$(34)+dw$(cou%)+CHR$(34)+","+STR$(dn%(cou%))+")"+CHR$(13)
BPUT#A,finfo$+CHR$(10);
PROCturtle(cmd$,amt%)
cou%+=1:REM INCREASE DIMENSION
UNTIL FALSE
END
REM * color reference
DEF PROCcolorref(x%,y%)
LOCAL h%,c%,h%,v%,o%
o%=y%:REM preserve y% info
FOR c% = 0 TO 15
GCOL c%
FOR h%=0 TO 20
LINE x%+h%,y%,x%+h%,y%+20
NEXT
MOVE x%+30,y%+25:GCOL 15:PRINT STR$(c%)
y%+=40:REM space for text info
NEXT c%
LINE x%,o%-5,x%+65,o%-5:LINE x%+65,o%-5,x%+65,y%+26
LINE x%,o%-6,x%+490,o%-6:LINE x%+490,o%-6,x%+490,y%+26
LINE x%,o%-6,x%+830,o%-6:LINE x%+830,o%-6,x%+830,y%+26
MOVE x%+75,y%-20: PRINT "COMMAND EXAMPLES"
MOVE x%+75,y%-50: PRINT "u - pen up"
MOVE x%+75,y%-80: PRINT "d - pen down"
MOVE x%+75,y%-110:PRINT "f25 - draw forward 25"
MOVE x%+75,y%-140:PRINT"l90 - left 90 degrees"
MOVE x%+75,y%-170:PRINT"r90 - right 90 degrees"
MOVE x%+73,y%-200:PRINT"c15 - set draw color to 15"
MOVE x%+73,y%-230:PRINT"p - fill with color"
MOVE x%+73,y%-260:PRINT"s10 - dot size 10 "
MOVE x%+73,y%-290:PRINT"m100 - move to 100,100"
MOVE x%+73,y%-320:PRINT"z - make data file"
MOVE 0,0
ENDPROC
REM I know some may ask why I am reinventing a word tool. Answer (do you like my coding structure?)
REM Its custom. Just saying, I will try to cover any possible user issues.
DEFPROCwd(info$,RETURN cmd$,RETURN amt%)
LOCAL l%,cur$,p$,n%
p$="1"
l%=1
REPEAT
cur$=MID$(info$,l%)
wor$=wor$+cur$
n%=VAL(cur$)
IF MID$(info$,1,1)="d" THEN info$="d1"
IF MID$(info$,1,1)="u" THEN info$="u1"
IF MID$(info$,1,1)="p" THEN info$="p1"
IF MID$(info$,1,1)="c" THEN IF MID$(info$,2,1)="0" THEN n%=16:amt%=16
IF MID$(info$,1,1)="m" THEN info$="m1"
IF MID$(info$,1,1)="z" THEN PROCmakefile:END
l%=l%+1
UNTIL n%>0
amt%=n%
cmd$=MID$(info$,1,l%-2)
ENDPROC
DEFPROCturtle(mess$,amt%)
PRIVATE angle,x%,y%,pen$,dracol%,sz%
IF sz%<1 THEN sz=1
GCOL dracol%
IF pen$="" THEN pen$="down"
IF mess$= "r" THEN angle=angle - amt%
IF mess$= "l" THEN angle=angle + amt%
IF mess$= "f" THEN VDU 23,23,sz%|:PROC_turtle(amt%,angle,pen$,x%,y%)
IF mess$= "u" THEN pen$="up"
IF mess$= "d" THEN pen$="down"
IF mess$= "p" THEN FILL x%,y%
IF mess$= "c" THEN IF amt%=16 THEN amt%=0
IF mess$= "c" THEN GCOL amt%:dracol%=amt%
IF mess$= "s" THEN sz%=amt%
VDU 23,23,sz%|
IF mess$= "m" THEN
x%=amt%:y%=amt%
pen$="move"
ENDIF
PROC_turtle(0,angle,pen$,x%,y%)
ENDPROC
DEFPROCmakefile
CLOSE#A
GCOL 15:PRINT "SAVED to file data.BBC --- close program please"
ENDPROC
DEFPROC_turtle(coun%,angle,pen$,RETURN x%,RETURN y%)
PRIVATE sx%,sy%
IF pen$="move" THEN sx%=x%:sy%=y%
IF pen$="up" OR pen$="down" THEN
sx%+=coun%*COS(RAD(angle))
sy%+=coun%*SIN(RAD(angle))
IF pen$="down" THEN LINE x%,y%,sx%,sy%
ENDIF
x%=sx%:y%=sy%
ENDPROC
REM H,V,TEXTLIMIT (simpler?)
DEF FNinput(bx,by,textlimit)
LOCAL fill,MESSAGE$,bg%,fg%,moux%,mouy%,moub%
VDU 23,23,1|
bg%=12:REM bg% is background color *********
fg%=15:REM fg% is foreground color *********
initialx%=0:sl%=0:key$="":MESSAGE$="":MES$=""
initialx%=textlimit*16.2
FOR fill=1 TO 58
GCOL bg%:LINE bx-4,by+20-fill,bx+initialx%,by+20-fill
NEXT fill
GCOL fg%:LINE bx+3,by+20,bx+initialx%,by+20:LINE bx+3,by+20-fill,bx+initialx%,by+20-fill
REPEAT
REPEAT
key$ =INKEY$(1)
GCOL fg%
MOVE bx,by:PRINT MESSAGE$;"_" :* REFRESH
sl%=LEN(MESSAGE$)
WAIT 5
UNTIL key$ <>""
sl%=LEN(MESSAGE$)
IF INKEY(-48) sl%=LEN(MESSAGE$)-1:key$=""
REPEAT UNTIL INKEY(0)=-1
IF sl%<LEN(MESSAGE$) THEN
GCOL bg%
MOVE bx,by
PRINT MESSAGE$;"_"
ENDIF
MES$=MID$(MESSAGE$,0,sl%)
MESSAGE$=MES$
GCOL bg%:MOVE bx,by:PRINT MESSAGE$;"_"
IF LEN(key$) = 1 THEN
IF LEN(MESSAGE$)<textlimit THEN GCOL bg%:MOVE bx,by:PRINT MESSAGE$;"_": MESSAGE$=MESSAGE$+key$:* REFRESH OFF
REM (jump)
ENDIF
UNTIL INKEY(-74)
* REFRESH ON
=MESSAGE$