home *** CD-ROM | disk | FTP | other *** search
- 10000 '
- 10010 ' Z3BAS.LIB
- 10020 '
- 10030 ' Version: 1.0. Date: 6/7/90
- 10040 ' Author: Lee Bradley, Sysop, Z-Node 12, 203-665-1100
- 10050 '
- 10060 ' Include these routines in your program and reference them
- 10070 ' when you need to determine environment address, load a tcap
- 10080 ' string, position the cursor, determine the status of the
- 10090 ' wheel byte, quiet flag etc.
- 10100 '
- 10110 ' ---
- 10120 ' Load ENV with environment address.
- 10130 ' ---
- 10140 '
- 10150 IF CHR$(PEEK(&H103))+CHR$(PEEK(&H104))="Z3" THEN 10220
- 10160 ' ==> NOTE! Edit &H value below. Will be used under MBASIC.
- 10170 ENV=&HE780+65536! ' Note need to make positive by adding 2^16
- 10180 ENV1=PEEK(ENV+&H1B)+256*PEEK(ENV+&H1C)
- 10190 IF ENV1=ENV THEN 10290
- 10200 PRINT:PRINT "ZCPR3 required. If running ZCPR3, change statement"
- 10210 PRINT "ENV=&H ... above.":SYSTEM
- 10220 IF PEEK(&H10A)<> 0 THEN 10250
- 10230 PRINT "If not ZCPR3 version ZCPR33+ you must use Z3INS "
- 10240 PRINT "ZCPR33+ was not found. ":ENV=0:GOTO 10290
- 10250 ENV=PEEK(&H109)+256*PEEK(&H10A)
- 10260 ENV1=PEEK(ENV+&H1B)+256*PEEK(ENV+&H1C)
- 10270 IF ENV1=ENV THEN 10290
- 10280 PRINT:PRINT "Environment self-reference error detected":END
- 10290 RETURN
- 10300 '
- 10310 ' ---
- 10320 ' Load X$ with tcap string based on TINDEX, a tcap string "index"
- 10330 ' and ENV, the environment address.
- 10340 ' X$ will hold terminal id string if TINDEX is 0
- 10350 ' X$ will hold clear screen string if TINDEX is 1. Etc.
- 10360 ' ---
- 10370 '
- 10380 J=128 ' Start at beginning of tcap segment
- 10390 IF TINDEX=0 THEN 10480 ' No need to skip anything if looking for id
- 10400 J=J+16+4+3 ' Get past id, arrow and delay bytes
- 10410 IF TINDEX=1 THEN 10480 ' No need to skip any more if clear scr wanted
- 10420 FOR I=1 TO TINDEX-1 ' Skip the strings we don't want
- 10430 IF CHR$(PEEK(ENV+J))<>"\" THEN 10450 ' Catch literals
- 10440 J=J+2 ' advance to next character
- 10450 IF PEEK(ENV+J)<>0 THEN J=J+1:GOTO 10430 ' Loop till null found
- 10460 J=J+1 ' Advance and move to next string
- 10470 NEXT
- 10480 ' Build tcap string
- 10490 X$="" ' Null out work string
- 10500 IF CHR$(PEEK(ENV+J))<>"\" THEN 10520 ' Catch literals
- 10510 J=J+1:GOTO 10550 ' Advance to literal
- 10520 IF J=128+13 AND TINDEX=0 THEN RETURN ' Get out if id complete
- 10530 IF PEEK(ENV+J)<>0 THEN 10550 ' If null
- 10540 RETURN ' return
- 10550 X$=X$+CHR$(PEEK(ENV+J)):J=J+1:GOTO 10500 ' else, grab it and loop
- 10560 '
- 10570 ' ---
- 10580 ' Cursor motion macro interpreter
- 10590 ' Input: R,C,CM$ (row,col,cursor motion macro)
- 10600 ' Output: CMO$ (string to output to the terminal)
- 10610 ' Ref: ZCPR3 The Manual, Richard Conn, Ch 22.
- 10620 ' ---
- 10630 '
- 10640 DIM OFFSET(2),PREINFIX$(2),RC(2),CMD$(2)
- 10650 WK$="":PCTR=0:I1=0:OFFSET(1)=0:OFFSET(2)=0 ' Initialize
- 10660 PREINFIX$(1) = "":PREINFIX$(2) = "":RC(1)=R:RC(2)=C ' Initialize
- 10670 I1=I1+1:IF I1>LEN(CM$) THEN 10980 ' Top of loop
- 10680 CMC$=MID$(CM$,I1,1) ' Load cursor motion macro char.
- 10690 IF CMC$<>"%" THEN 10950 ' If not a %, tack onto work string
- 10700 I1=I1+1:CMC$=MID$(CM$,I1,1) ' Advance
- 10710 RI=INSTR("RrIi",CMC$)
- 10720 IF RI=1 OR RI=2 THEN CB4R$="ON":GOTO 10670 ' Handle R,I commands
- 10730 IF RI=3 OR RI=4 THEN HOME=1:GOTO 10670
- 10740 PCTR=PCTR+1 ' Update % counter
- 10750 PREINFIX$(PCTR)=WK$ ' Save work string
- 10760 WK$="" ' Null out for future build
- 10770 IF CMC$<>"." THEN 10800 ' Binary ?
- 10780 CMD$(PCTR)=CHR$(RC(PCTR)+HOME)
- 10790 GOTO 10670 ' Loop
- 10800 D23=INSTR("D23d",CMC$):IF D23=0 THEN 10860 ' Ascii?
- 10810 CMD$(PCTR)=MID$(STR$(RC(PCTR)+HOME),2)
- 10820 IF LEN(CMD$(PCTR))=1 AND D23=2 THEN CMD$(PCTR)="0"+CMD$(PCTR) ' Fix
- 10830 IF LEN(CMD$(PCTR))=1 AND D23=3 THEN CMD$(PCTR)="00"+CMD$(PCTR)
- 10840 IF LEN(CMD$(PCTR))=2 AND D23=3 THEN CMD$(PCTR)="0"+CMD$(PCTR)
- 10850 GOTO 10670 ' Loop
- 10860 IF CMC$<>"+" THEN 10910 ' Offset?
- 10870 I1=I1+1:CMC$=MID$(CM$,I1,1)
- 10880 OFFSET(PCTR)=ASC(CMC$)
- 10890 CMD$(PCTR)=CHR$(RC(PCTR)+HOME+OFFSET(PCTR))
- 10900 GOTO 10670 ' Loop
- 10910 IF CMC$<>">" THEN PRINT "Error in cursor motion macro ... ":END
- 10920 I1=I1+1:CMC1$=MID$(CM$,I1,1):I1=I1+1:CMC$=MID$(CM$,I1,1)
- 10930 IF CHR$(RC(PCTR))>CMC1$ THEN 10880 ELSE 10890
- 10940 ' Compute conditional offset, then use "+" code
- 10950 ' We have a character that's not part of a % command. Just add it
- 10960 WK$=WK$+CMC$
- 10970 GOTO 10670 ' Loop
- 10980 ' All done. Anything left (in WK$) is the postfix part.
- 10990 IF CB4R$="ON" THEN SWAP CMD$(1),CMD$(2) ' If col before row, swap
- 11000 CMO$=PREINFIX$(1)+CMD$(1)+PREINFIX$(2)+CMD$(2)+WK$ ' Build CMO$
- 11010 RETURN
- 11020 '
- 11030 ' ---
- 11040 ' Load variables (QUIET, WHEEL etc.) based on ENV,
- 11050 ' the environment address.
- 11060 ' ---
- 11070 '
- 11080 QUIET=PEEK(ENV+&H28):RETURN
- 11090 WHLA=PEEK(ENV+&H29)+256*PEEK(ENV+&H2A):RETURN
- 11100 WHEEL=PEEK(WHLA):RETURN
- 11110 MHZ=PEEK(ENV+&H2B):RETURN
- 11120 MAXD=PEEK(ENV+&H2C):RETURN
- 11130 MAXU=PEEK(ENV+&H2D):RETURN
- 11140 DUOK=PEEK(ENV+&H2E):RETURN
- 11150 '
- V+&H2B):RETURN
- 11120 MAXD=PEEK(ENV+&H2C):RETURN
- 11130 MAXU=PEEK(ENV+&H2D):RETURN
- 11140 DUOK=PEEK(ENV+&H2E