' DIGITISE = a program to convert x/y digitiser input to ASCII files, ' with interactive setup, graphical feedback, and ' optional title lines for line segments. ' ' Second module DIGIT2.BAS is an integral part of this program! ' DIGITISE.MAK is a reminder to BASIC that both DIGITISE.BAS and ' DIGIT2.BAS are needed for a complete source code. ' ' Written for Microsoft Basic Professional Development System 7.1. ' Be sure to start QBX with option /C:32767 to allow large input buffer ' when compiling! ' ' (C) 1991, 1992, 1996 by Peter Bird, Department of Earth & Space Sciences, ' University of California, Los Angeles, CA 90024. ' DECLARE SUB TitleScreen () DECLARE SUB RemedyScreen () DECLARE SUB Blanker (R1%, R2%, C1%, C2%) DECLARE SUB SetProgPath (Outs, DefaultDrive$, CD$, ProgPath$) DECLARE SUB GetFileName (Text$, LineN%, NewName$) DECLARE SUB OpenCOM (LineOpen%, PN%, Baud$, Parity$, DataBits$, StopBits$, StartCol%, UseRow%) DECLARE SUB ChangeHot (Hot%, i%, SkipLines%, ShortColumn%, Short$(), LongColumn%, Long$()) DECLARE SUB FaintBox (TopRow%, BottomRow%, LeftColumn%, RightColumn%) DECLARE SUB RUNMENU (LastL%, Number%, Short$(), Initial$(), Long$(), SLen%, LLen%, OK%(), Hot%) DECLARE SUB SETMENU (LastL%, Number%, Short$(), Initial$(), Long$(), SLen%, LLen%, OK%(), Hot%) DECLARE SUB BoldBox (TopRow%, BottomRow%, LeftColumn%, RightColumn%) DECLARE SUB GSETMENU (LastL%, Number%, Short$(), Initial$(), Long$(), SLen%, LLen%, OK%(), Hot%) DECLARE SUB Shadow (Cast%, TopRow%, BottomRow%, LeftColumn%, RightColumn%) DECLARE SUB GRUNMENU (LastL%, Number%, Short$(), Initial$(), Long$(), SLen%, LLen%, OK%(), Hot%) DECLARE SUB GChangeHot (Hot%, i%, SkipLines%, ShortColumn%, Short$(), LongColumn%, Long$()) DECLARE FUNCTION ATAN2F! (y!, x!) ' OPTION BASE 1 CONST N4K% = 4096 'Note: use of a CONST dimension forces dynamic storage in the far heap ' for this array; DGROUP is full. REM $STATIC DIM Memory!(1 TO 2, 1 TO 4096) '(storage for temporary variables and strings is static, in DGROUP) ' COMMON SHARED FALSE%, True%, BestMode%, Foreground%, Background%, CDstr$, CSstr$, DSstr$, OPstr$ FALSE% = 0: True% = NOT FALSE% '--------------------------------------------------------------------- 'Code to find highest-resolution graphics mode available ' by trial-and (trapped) error ' ON ERROR GOTO BadMode GOTO Beginning: BadMode: RESUME TryAgain Beginning: DIM Modes%(12), Page%(12) FOR i% = 1 TO 6 Page%(i%) = 1 NEXT i% FOR i% = 7 TO 12 Page%(i%) = 0 NEXT i% Modes%(1) = 12 'VGA + color Modes%(2) = 11 'VGA + monochrome Modes%(3) = 9 'EGA + color Modes%(4) = 10 'EGA + monochrome Modes%(5) = 3 'Hercules Modes%(6) = 2 'CGA FOR i% = 7 TO 12 Modes%(i%) = Modes%(i% - 6) NEXT i% ModeNum% = 0 TryAgain: ModeNum% = ModeNum% + 1 BestMode% = Modes%(ModeNum%) HighPage% = Page%(ModeNum%) ' When ready for graphics, enter: SCREEN BestMode%, , HighPage%, HighPage% SCREEN BestMode%, , HighPage%, HighPage% CLS ON ERROR GOTO AnyError 'turn off special handler; use generic one. SELECT CASE BestMode% CASE IS = 2 Nx% = 640 Ny% = 200 Foreground% = 7 Background% = 0 CASE IS = 3 Nx% = 720 Ny% = 348 Foreground% = 7 Background% = 0 CASE IS = 9 Nx% = 640 Ny% = 350 Foreground% = 15 Background% = 1 CASE IS = 10 Nx% = 640 Ny% = 350 Foreground% = 7 Background% = 0 CASE IS = 11 Nx% = 640 Ny% = 480 Foreground% = 15 Background% = 1 CASE IS = 12 Nx% = 640 Ny% = 480 Foreground% = 15 Background% = 1 END SELECT ColorIt% = (BestMode% = 12) OR (BestMode% = 9) 'allows yellow and green on graphics screen ' '--------------------------------------------------------------- ' COLOR Foreground%, Background% CALL TitleScreen ' '---------------------------------------------------------------- ' CALL SetProgPath(Outs, DefaultDrive$, CD$, ProgPath$) '----------------------------------------------------------------------- ' TurnOn: 'Remind user to turn on digitiser. CLS COLOR Background% + 16, Foreground% LOCATE 3, 8 PRINT " PLEASE CHECK THAT THE DIGITISER IS CONNECTED AND TURNED ON. " COLOR Foreground%, Background% LOCATE 6, 9 PRINT "You may connect via any serial port (COM1, or COM2 if you have one)." LOCATE 8, 9 PRINT "Follow digitiser instructions to initialize it." LOCATE 9, 9 PRINT "Note that it is not necessary to set the origin or scale," LOCATE 10, 12 PRINT "as this program will do that for you." LOCATE 25, 8 COLOR Background%, Foreground% PRINT " Press any key after digitiser is connected and running .... "; DO UNTIL INKEY$ <> "": LOOP COLOR Foreground%, Background% ' '------------------------------------------------------------- ' 'initialize parameters with default values ' CDstr$ = ",CD300" 'allow 300 milliseconds for Data Carrier Detect (DCD) line to go high. CSstr$ = ",CS300" 'allow 300 milliseconds for Clear To Send (CTS) line to go high. DSstr$ = ",DS300" 'allow 300 milliseconds for Data Set Ready (DSR) line to go high. OPstr$ = ",OP700" 'allow 700 milliseconds for Open to be completed. LineOpen% = FALSE% PNHot% = 1 ' hot port number = COM1 Baud$ = "9600" BAHot% = 1 Parity$ = "N" PAHot% = 1 DataBits$ = "7" DBHot% = 2 StopBits$ = "1" SBHot% = 3 FOHot% = 5 StopMode% = 1 'default is CR+LF at end of each record, to determine length. StopByte$ = CHR$(10) 'LF character. ZAHot% = 1 'ditto XLeft% = 1 XLen% = 5 'trial values for positions and lengths of YLeft% = 6 ' ascii substrings representing X and Y YLen% = 5 ' in one digitiser input record. RecordL% = 12 'input record length in bytes per (x,y) point, including padding. WasteSome% = FALSE% ' no pen-up marker byte will be in use. WasteMark$ = "0" '(but define the marker anyway, so a .MOD file can be written) CheckHere% = 1 '(ditto) Recycling% = FALSE% ' no end-of-line marker is defined EjectMark$ = "0" '(but define the marker anyway, so a .MOD file can be written) Trigger% = 1 '(ditto) TempName$ = "TEMP8106.DIG" DIM MAOk%(7) MAOk%(2) = FALSE% MAOk%(3) = FALSE% 'no other setup parameter can be changed until MAOk%(4) = FALSE% ' the COM port has been chosen. MAOk%(5) = FALSE% MAOk%(6) = FALSE% DIM MMOk%(3) MMHot% = 1 MMOk%(1) = True% MMOk%(2) = FALSE% MMOk%(3) = True% DIM SUOK%(6) SUOK%(3) = True% SUOK%(4) = FALSE% SUOK%(5) = FALSE% SUOK%(6) = True% Fil$ = ProgPath$ + "\*.MOD" IF LEN(DIR$(Fil$)) = 0 THEN SUOK(2) = FALSE% SUHot% = 3 ELSE SUOK%(2) = True% SUHot% = 2 END IF Fil$ = ProgPath$ + "\LASTUSED.MOD " IF LEN(DIR$(Fil$)) = 0 THEN SUOK%(1) = FALSE% ELSE SUOK%(1) = True% SUHot% = 1 END IF MAHot% = 1 LastRec$ = "" DIM DIOk%(7) DIOk%(1) = True% DIOk%(2) = True% DIOk%(3) = True% DIOk%(4) = FALSE% DIOk%(5) = True% DIOk%(6) = FALSE% DIOk%(7) = True% DIHot% = 2 OutPath$ = CD$ OutChosen% = FALSE% SeeChosen% = FALSE% SeeFileN$ = "" EndMark$ = "*** end of line segment ***" Titles% = 0 TitleMark$ = "" Scaled% = FALSE% LSHot% = 1 DIM FirstFive$(5) FirstFive$(1) = "" FirstFive$(2) = "" FirstFive$(3) = "" FirstFive$(4) = "" FirstFive$(5) = "" ' '---------------------------------------------------------------- ' MainMenu: '(MM) 'basic options: Set-up, Digitise, Exit ' CLS COLOR Foreground%, Background% LOCATE 1, 35 PRINT "MAIN MENU" LOCATE 3, 20 PRINT "Use arrow keys or initial letter to select," LOCATE 4, 29 PRINT "then press Return/Enter." MMNumber% = 3 DIM MMShort$(3), MMLong$(3), MMInitial$(3) MMShort$(1) = " Set-up " MMShort$(2) = "Digitise" MMShort$(3) = " Exit " MMInitial$(1) = "S" MMInitial$(2) = "D" MMInitial$(3) = "E" MMLong$(1) = "(adjust communication mode and format parameters) " MMLong$(2) = "(create files, and fill with digitised data) " MMLong$(3) = "(save files, then exit this program; return to DOS)" IF MMOk%(2) THEN MMHot% = 2 MMSLen% = LEN(MMShort$(1)) MMLLen% = LEN(MMLong$(1)) CALL SETMENU(25, MMNumber%, MMShort$(), MMInitial$(), MMLong$(), MMSLen%, MMLLen%, MMOk%(), MMHot%) CALL RUNMENU(25, MMNumber%, MMShort$(), MMInitial$(), MMLong$(), MMSLen%, MMLLen%, MMOk%(), MMHot%) IF MMHot% = 1 THEN GOTO SetUp ELSEIF MMHot% = 2 THEN GOTO Digitise ELSEIF MMHot% = 3 THEN IF LineOpen% THEN CLOSE #1 ' COM port (digitiser) LineOpen% = FALSE% END IF CLOSE #2 '.MOD file CLOSE #3 '.DIG file CLOSE #4 'extra .DIG file for display only GOTO Termination END IF ' '------------------------------------------------------------------ ' SetUp: '(SU) 'establish communication mode and format parameters ' CLS COLOR Foreground%, Background% LOCATE 1, 35 PRINT "SET-UP MENU" LOCATE 3, 20 PRINT "Use arrow keys or initial letter to select," LOCATE 4, 29 PRINT "then press Return/Enter." DIM SUShort$(6), SULong$(6), SUInitial$(6) SUNumber% = 6 SUShort$(1) = " Repeat " SUShort$(2) = " File " SUShort$(3) = " Manual " SUShort$(4) = " Test " SUShort$(5) = " Save " SUShort$(6) = " Exit " SUInitial$(1) = "R" SUInitial$(2) = "F" SUInitial$(3) = "M" SUInitial$(4) = "T" SUInitial$(5) = "S" SUInitial$(6) = "E" SULong$(1) = "(use parameters and format from last digitizing session)" SULong$(2) = "(load file of parameters and format from disk) " SULong$(3) = "(select parameters and format from menus) " SULong$(4) = "(test transmission of single points, and view input) " SULong$(5) = "(save current parameters in a file for future use) " SULong$(6) = "(exit to Main Menu, to digitise or return to DOS) " SUSLen% = LEN(SUShort$(1)) SULLen% = LEN(SULong$(1)) SUOK%(3) = True% SUOK%(6) = True% CALL SETMENU(25, SUNumber%, SUShort$(), SUInitial$(), SULong$(), SUSLen%, SULLen%, SUOK%(), SUHot%) CALL RUNMENU(25, SUNumber%, SUShort$(), SUInitial$(), SULong$(), SUSLen%, SULLen%, SUOK%(), SUHot%) IF SUHot% = 1 THEN FileN$ = ProgPath$ + "\LASTUSED.MOD" OPEN FileN$ FOR INPUT AS #2 INPUT #2, PNHot%, Baud$, BAHot%, Parity$, PAHot%, DataBits$, DBHot%, StopBits$, SBHot% INPUT #2, StopMode%, ZAHot%, RecordL%, T1%, XLeft%, XLen%, YLeft%, YLen%, WasteSome%, T2%, CheckHere%, Recycling%, T3%, Trigger% CLOSE #2 StopByte$ = CHR$(T1%): WasteMark$ = CHR$(T2%): EjectMark$ = CHR$(T3%) MMOk%(2) = True% SUOK%(4) = True% SUOK%(5) = True% SUHot% = 6 MAOk%(2) = True% MAOk%(3) = True% MAOk%(4) = True% MAOk%(5) = True% MAOk%(6) = True% GOTO SetUp ELSEIF SUHot% = 2 THEN CLS LOCATE 1, 12 PRINT "LOADING COMMUNICATION PARAMETERS AND FORMAT FROM A FILE"; LOCATE 3, 1: PRINT "Here are any existing .MOD files:"; PRINT : PRINT FileN$ = ProgPath$ + "\*.MOD" FILES FileN$ LOCATE 5, 1: PRINT ProgPath$; " contains ... "; Text$ = "Enter an existing filename (1-8 characters, no extension): " Ehh: CALL GetFileName(Text$, 21, NewName$) FileN$ = ProgPath$ + "\" + NewName$ + ".MOD" IF LEN(DIR$(FileN$)) = 0 THEN BEEP GOTO Ehh: END IF FileN$ = ProgPath$ + "\" + NewName$ + ".MOD" OPEN FileN$ FOR INPUT AS #2 INPUT #2, PNHot%, Baud$, BAHot%, Parity$, PAHot%, DataBits$, DBHot%, StopBits$, SBHot% INPUT #2, StopMode%, ZAHot%, RecordL%, T1%, XLeft%, XLen%, YLeft%, YLen%, WasteSome%, T2%, CheckHere%, Recycling%, T3%, Trigger% StopByte$ = CHR$(T1%): WasteMark$ = CHR$(T2%): EjectMark$ = CHR$(T3%) MMOk%(2) = True% SUOK%(4) = True% SUOK%(5) = True% MAOk%(2) = True% MAOk%(3) = True% MAOk%(4) = True% MAOk%(5) = True% MAOk%(6) = True% CLOSE #2 GOTO SetUp ELSEIF SUHot% = 3 THEN GOTO Manual ELSEIF SUHot% = 4 THEN GOTO Test ELSEIF SUHot% = 5 THEN CLS LOCATE 1, 10 PRINT "SAVING COMMUNICATION PARAMETERS AND FORMAT TO A NAMED FILE"; FileN$ = ProgPath$ + "\*.MOD" IF LEN(DIR$(FileN$)) THEN LOCATE 3, 1: PRINT "Here are the existing .MOD files:"; PRINT : PRINT FileN$ = ProgPath$ + "\*.MOD" FILES FileN$ LOCATE 5, 1: PRINT ProgPath$; " contains ... "; END IF Text$ = "Enter new or existing filename (1-8 characters, no extension): " CALL GetFileName(Text$, 21, NewName$) FileN$ = ProgPath$ + "\" + NewName$ + ".MOD" OPEN FileN$ FOR OUTPUT AS #2 WRITE #2, PNHot%, Baud$, BAHot%, Parity$, PAHot%, DataBits$, DBHot%, StopBits$, SBHot% WRITE #2, StopMode%, ZAHot%, RecordL%, ASC(LEFT$(StopByte$, 1)), XLeft%, XLen%, YLeft%, YLen%, WasteSome%, ASC(LEFT$(WasteMark$, 1)), CheckHere%, Recycling%, ASC(LEFT$(EjectMark$, 1)), Trigger% CLOSE #2 SUOK%(2) = True% GOTO SetUp ELSEIF SUHot% = 6 THEN FileN$ = ProgPath$ + "\LASTUSED.MOD" OPEN FileN$ FOR OUTPUT AS #2 WRITE #2, PNHot%, Baud$, BAHot%, Parity$, PAHot%, DataBits$, DBHot%, StopBits$, SBHot% WRITE #2, StopMode%, ZAHot%, RecordL%, ASC(LEFT$(StopByte$, 1)), XLeft%, XLen%, YLeft%, YLen%, WasteSome%, ASC(LEFT$(WasteMark$, 1)), CheckHere%, Recycling%, ASC(LEFT$(EjectMark$, 1)), Trigger% CLOSE #2 MMOk%(2) = True% SUOK%(1) = True% SUHot% = 1 SUOK%(5) = True% GOTO MainMenu END IF ' '------------------------------------------------------------------ ' Manual: '(MA) 'select COM port (first), then baud, parity, data bits, stop bits, ' record length, and locations of x and y within record. ' COLOR Foreground%, Background% CLS LOCATE 1, 28 PRINT "COMMUNICATION PARAMETERS" LOCATE 3, 20 PRINT "Use arrow keys or initial letter to select," LOCATE 4, 29 PRINT "then press Return/Enter." MANumber% = 7 DIM MAShort$(7), MALong$(7), MAInitial$(7) MAShort$(1) = "Comport#" MAShort$(2) = " Baud " MAShort$(3) = " Parity " MAShort$(4) = "Databits" MAShort$(5) = "Stopbits" MAShort$(6) = " Format " MAShort$(7) = " Exit " MAInitial$(1) = "C" MAInitial$(2) = "B" MAInitial$(3) = "P" MAInitial$(4) = "D" MAInitial$(5) = "S" MAInitial$(6) = "F" MAInitial$(7) = "E" MALong$(1) = "(choose Com port number for connection to digitiser) " MALong$(2) = "(check or change Baud rate [bits/second]) " MALong$(3) = "(check or change Parity-checking convention) " MALong$(4) = "(check or change number of Data bits per byte) " MALong$(5) = "(check or change number of Stop bits per byte) " MALong$(6) = "(check or change Format [record-length; x,y positions])" MALong$(7) = "(Exit and return to setup menu, to test or digitise) " MASLen% = LEN(MAShort$(1)) MALLen% = LEN(MALong$(1)) MAOk%(1) = True% MAOk%(7) = True% CALL SETMENU(24, MANumber%, MAShort$(), MAInitial$(), MALong$(), MASLen%, MALLen%, MAOk%(), MAHot%) CALL RUNMENU(24, MANumber%, MAShort$(), MAInitial$(), MALong$(), MASLen%, MALLen%, MAOk%(), MAHot%) IF MAHot% = 1 THEN GOTO PortNumber ELSEIF MAHot% = 2 THEN GOTO Baud ELSEIF MAHot% = 3 THEN GOTO Parity ELSEIF MAHot% = 4 THEN GOTO DataBits ELSEIF MAHot% = 5 THEN GOTO StopBits ELSEIF MAHot% = 6 THEN GOTO Format ELSEIF MAHot% = 7 THEN SUOK%(4) = True% SUOK%(5) = True% GOTO SetUp ELSE GOTO Manual END IF ' '------------------------------------------------------------------ ' PortNumber: '(PN) 'choose number of COM port to be used. ' CLS COLOR Foreground%, Background% LOCATE 1, 28 PRINT "CHOOSE SERIAL PORT NUMBER" LOCATE 3, 20 PRINT "Use arrow keys or final number to select," LOCATE 4, 29 PRINT "then press Return/Enter." PNNumber% = 2 'According to my Basic 7.0 manual, only 1 & 2 are allowed." 'This may change in the near future, however. DIM PNShort$(7), PNLong$(7), PNOK%(7), PNInitial$(7) PNShort$(1) = " COM1 " PNShort$(2) = " COM2 " PNShort$(3) = " COM3 " PNShort$(4) = " COM4 " PNShort$(5) = " COM5 " PNShort$(6) = " COM6 " PNShort$(7) = " COM7 " PNInitial$(1) = "1" PNInitial$(2) = "2" PNInitial$(3) = "3" PNInitial$(4) = "4" PNInitial$(5) = "5" PNInitial$(6) = "6" PNInitial$(7) = "7" PNLong$(1) = "" PNLong$(2) = "" PNLong$(3) = "" PNLong$(4) = "" PNLong$(5) = "" PNLong$(6) = "" PNLong$(7) = "" PNSLen% = LEN(PNShort$(1)) PNLLen% = LEN(PNLong$(1)) PNOK%(1) = True% PNOK%(2) = True% PNOK%(3) = True% PNOK%(4) = True% PNOK%(5) = True% PNOK%(6) = True% PNOK%(7) = True% CALL SETMENU(25, PNNumber%, PNShort$(), PNInitial$(), PNLong$(), PNSLen%, PNLLen%, PNOK%(), PNHot%) CALL RUNMENU(25, PNNumber%, PNShort$(), PNInitial$(), PNLong$(), PNSLen%, PNLLen%, PNOK%(), PNHot%) MAOk%(2) = True% MAOk%(3) = True% 'now that port is chosen, it's OK to select MAOk%(4) = True% ' other parameters, and/or test communication. MAOk%(5) = True% MAOk%(6) = True% SUOK%(4) = True% GOTO Manual ' '------------------------------------------------------------------ ' Baud: '(BA) 'choose baud rate for COM port ' CLS COLOR Foreground%, Background% LOCATE 1, 26 PRINT "CHOOSE BAUD RATE (bits/second)" LOCATE 3, 20 PRINT "Use arrow keys or initial number to select," LOCATE 4, 29 PRINT "then press Return/Enter." BANumber% = 7 DIM BAShort$(7), BALong$(7), BAOK%(7), BAInitial$(7) BAShort$(1) = " 9600 " BAShort$(2) = " 4800 " BAShort$(3) = " 2400 " BAShort$(4) = " 1200 " BAShort$(5) = " 600 " BAShort$(6) = " 300 " BAShort$(7) = " 110 " BAInitial$(1) = "9" BAInitial$(2) = "4" BAInitial$(3) = "2" BAInitial$(4) = "1" BAInitial$(5) = "6" BAInitial$(6) = "3" BAInitial$(7) = "1" BALong$(1) = "" BALong$(2) = "" BALong$(3) = "" BALong$(4) = "" BALong$(5) = "" BALong$(6) = "" BALong$(7) = "" BASLen% = LEN(BAShort$(1)) BALLen% = LEN(BALong$(1)) BAOK%(1) = True% BAOK%(2) = True% BAOK%(3) = True% BAOK%(4) = True% BAOK%(5) = True% BAOK%(6) = True% BAOK%(7) = True% CALL SETMENU(25, BANumber%, BAShort$(), BAInitial$(), BALong$(), BASLen%, BALLen%, BAOK%(), BAHot%) CALL RUNMENU(25, BANumber%, BAShort$(), BAInitial$(), BALong$(), BASLen%, BALLen%, BAOK%(), BAHot%) IF BAHot% = 1 THEN Baud$ = "9600" ELSEIF BAHot% = 2 THEN Baud$ = "4800" ELSEIF BAHot% = 3 THEN Baud$ = "2400" ELSEIF BAHot% = 4 THEN Baud$ = "1200" ELSEIF BAHot% = 5 THEN Baud$ = "600" ELSEIF BAHot% = 6 THEN Baud$ = "300" ELSEIF BAHot% = 7 THEN Baud$ = "110" END IF GOTO Manual ' '------------------------------------------------------------------ ' Parity: '(PA) 'choose parity-checking convention for input data ' CLS COLOR Foreground%, Background% LOCATE 1, 25 PRINT "CHOOSE PARITY-CHECKING CONVENTION" LOCATE 3, 20 PRINT "Use arrow keys or initial letter to select," LOCATE 4, 29 PRINT "then press Return/Enter." PANumber% = 5 DIM PAShort$(5), PALong$(5), PAOK%(5), PAInitial$(5) IF DataBits$ = "8" THEN PALong$(1) = " None (no parity checking is possible with 8 data bits)" PAOK%(2) = FALSE% PAOK%(3) = FALSE% PAOK%(4) = FALSE% PAOK%(5) = FALSE% ELSE PALong$(1) = "" PAOK%(2) = True% PAOK%(3) = True% PAOK%(4) = True% PAOK%(5) = True% END IF PAShort$(1) = " None " PAShort$(2) = " Even " PAShort$(3) = " Odd " PAShort$(4) = " Space" PAShort$(5) = " Mark " PAInitial$(1) = "N" PAInitial$(2) = "E" PAInitial$(3) = "O" PAInitial$(4) = "S" PAInitial$(5) = "M" PALong$(2) = "" PALong$(3) = "" PALong$(4) = "" PALong$(5) = "" PASLen% = LEN(PAShort$(1)) PALLen% = LEN(PALong$(1)) PAOK%(1) = True% CALL SETMENU(25, PANumber%, PAShort$(), PAInitial$(), PALong$(), PASLen%, PALLen%, PAOK%(), PAHot%) CALL RUNMENU(25, PANumber%, PAShort$(), PAInitial$(), PALong$(), PASLen%, PALLen%, PAOK%(), PAHot%) IF PAHot% = 1 THEN Parity$ = "N" ELSEIF PAHot% = 2 THEN Parity$ = "E" ELSEIF PAHot% = 3 THEN Parity$ = "O" ELSEIF PAHot% = 4 THEN Parity$ = "S" ELSEIF PAHot% = 5 THEN Parity$ = "M" END IF GOTO Manual ' '------------------------------------------------------------------ ' DataBits: '(DB) 'number of data bits in each byte at the serial input port ' CLS COLOR Foreground%, Background% LOCATE 1, 23 PRINT "CHOOSE NUMBER OF DATA BITS/BYTE" LOCATE 3, 20 PRINT "Use arrow keys or number to select," LOCATE 4, 29 PRINT "then press Return/Enter." DBNumber% = 4 DIM DBShort$(4), DBLong$(4), DBOK%(4), DBInitial$(4) DBShort$(1) = " 8 " DBShort$(2) = " 7 " DBShort$(3) = " 6 " DBShort$(4) = " 5 " DBInitial$(1) = "8" DBInitial$(2) = "7" DBInitial$(3) = "6" DBInitial$(4) = "5" DBLong$(2) = "" DBLong$(3) = "" DBLong$(4) = "" DBSLen% = LEN(DBShort$(1)) IF Parity$ = "N" THEN DBOK%(1) = True% DBLong$(2) = "" ELSE DBOK%(1) = FALSE% DBLong$(2) = "(7 bits is limit with parity checking on)" END IF DBOK%(2) = True% DBOK%(3) = True% DBOK%(4) = True% DBLLen% = LEN(DBLong$(2)) CALL SETMENU(25, DBNumber%, DBShort$(), DBInitial$(), DBLong$(), DBSLen%, DBLLen%, DBOK%(), DBHot%) CALL RUNMENU(25, DBNumber%, DBShort$(), DBInitial$(), DBLong$(), DBSLen%, DBLLen%, DBOK%(), DBHot%) IF DBHot% = 1 THEN DataBits$ = "8" ELSEIF DBHot% = 2 THEN DataBits$ = "7" ELSEIF DBHot% = 3 THEN DataBits$ = "6" ELSEIF DBHot% = 4 THEN DataBits$ = "5" END IF GOTO Manual ' '------------------------------------------------------------------ ' StopBits: '(SB) 'number of stop bits in each byte at the serial input port ' CLS COLOR Foreground%, Background% LOCATE 1, 23 PRINT "CHOOSE NUMBER OF STOP BITS/BYTE" LOCATE 3, 13 PRINT "Use arrow keys to select, then press Return/Enter." SBNumber% = 3 DIM SBShort$(3), SBLong$(3), SBOK%(3), SBInitial$(3) SBShort$(1) = " 2 " SBShort$(2) = "1.5" SBShort$(3) = " 1 " SBInitial$(1) = "2" SBInitial$(2) = "Q" SBInitial$(3) = "1" SBLong$(1) = "" SBLong$(2) = "" SBLong$(3) = "" SBSLen% = LEN(SBShort$(1)) SBLLen% = LEN(SBLong$(1)) SBOK%(1) = True% SBOK%(2) = True% SBOK%(3) = True% CALL SETMENU(25, SBNumber%, SBShort$(), SBInitial$(), SBLong$(), SBSLen%, SBLLen%, SBOK%(), SBHot%) CALL RUNMENU(25, SBNumber%, SBShort$(), SBInitial$(), SBLong$(), SBSLen%, SBLLen%, SBOK%(), SBHot%) IF SBHot% = 1 THEN StopBits$ = "2" ELSEIF SBHot% = 2 THEN StopBits$ = "1.5" ELSEIF SBHot% = 3 THEN StopBits$ = "1" END IF GOTO Manual ' '------------------------------------------------------------------ ' Format: ' set record length, and x and y positions in record ' COLOR Foreground%, Background% CLS LOCATE 1, 37 PRINT "FORMAT" LOCATE 2, 7 PRINT "Remember that the actual x and y values during digitizing may extend"; LOCATE 3, 7 PRINT "further left than those received in the test, because of - signs or"; LOCATE 4, 7 PRINT "larger magnitudes. Allow as much space on the left as possible."; LOCATE 5, 1 PRINT " 111111111122222222223333333333444444444455555555556"; LOCATE 6, 1 PRINT "Position: 123456789012345678901234567890123456789012345678901234567890"; LOCATE 8, 1 PRINT "Format:"; CALL FaintBox(7, 9, 11, 73) CALL FaintBox(9, 12, 11, 73) LOCATE 9, 11: PRINT CHR$(195); : LOCATE 9, 73: PRINT CHR$(180); LOCATE 10, 1 PRINT "Last"; LOCATE 11, 1 PRINT "Record:"; FOR i% = 1 TO LEN(LastRec$) Col% = 11 + i% a$ = MID$(LastRec$, i%, 1) IF a$ = CHR$(13) THEN LOCATE 10, Col% PRINT "C"; LOCATE 11, Col% PRINT "R"; ELSEIF a$ = CHR$(10) THEN LOCATE 10, Col% PRINT "L"; LOCATE 11, Col% PRINT "F"; ELSE LOCATE 11, Col% PRINT " "; LOCATE 10, Col% PRINT a$; END IF NEXT i% DIM FOShort$(6), FOInitial$(6) FOShort$(1) = "Record-length" FOShort$(2) = " X-positions " FOShort$(3) = " Y-positions " FOShort$(4) = "Pen-up marker" FOShort$(5) = "New-line mark" FOShort$(6) = " Exit " FOInitial$(1) = "R" FOInitial$(2) = "X" FOInitial$(3) = "Y" FOInitial$(4) = "P" FOInitial$(5) = "N" FOInitial$(6) = "E" FOHot% = 1 CALL BoldBox(14, 16, 1, 15) CALL BoldBox(16, 18, 1, 15): LOCATE 16, 1: PRINT CHR$(204); : LOCATE 16, 15: PRINT CHR$(185); CALL BoldBox(18, 20, 1, 15): LOCATE 18, 1: PRINT CHR$(204); : LOCATE 18, 15: PRINT CHR$(185); CALL BoldBox(20, 22, 1, 15): LOCATE 20, 1: PRINT CHR$(204); : LOCATE 20, 15: PRINT CHR$(185); CALL BoldBox(22, 24, 1, 15): LOCATE 22, 1: PRINT CHR$(204); : LOCATE 22, 15: PRINT CHR$(185); LOCATE 24, 1: PRINT CHR$(204); : LOCATE 24, 15: PRINT CHR$(185); LOCATE 25, 1: PRINT CHR$(186); : LOCATE 25, 15: PRINT CHR$(186); ' NewFormat: COLOR Foreground%, Background% IF WasteSome% THEN T% = ASC(LEFT$(WasteMark$, 1)) IF T% < 8 OR T% > 13 THEN T$ = WasteMark$ + " " ELSE T$ = "[" + STR$(ASC(WasteMark$)) + "] " END IF CALL FaintBox(12, 14, 2, 40) LOCATE 12, 11: PRINT CHR$(193); : LOCATE 12, 40: PRINT CHR$(194); LOCATE 14, 2: PRINT CHR$(205) + CHR$(205) + CHR$(205) + CHR$(205) + CHR$(205) + CHR$(205) + CHR$(205) + CHR$(205) + CHR$(205) + CHR$(205) + CHR$(205) + CHR$(205) + CHR$(205) + CHR$(187); LOCATE 13, 4: PRINT "'Pen' is 'up' when #"; IF CheckHere% < 10 THEN PRINT USING "#"; CheckHere%; ELSE PRINT USING "##"; CheckHere%; END IF PRINT " holds "; T$; ELSE CALL Blanker(12, 12, 2, 10): LOCATE 12, 40: PRINT CHR$(196); CALL Blanker(13, 13, 2, 40) CALL Blanker(14, 14, 16, 40) LOCATE 12, 11: PRINT CHR$(192); : LOCATE 12, 39: PRINT CHR$(196); END IF IF Recycling% THEN T% = ASC(LEFT$(EjectMark$, 1)) IF T% < 8 OR T% > 13 THEN T$ = EjectMark$ + " " ELSE T$ = "[" + STR$(ASC(EjectMark$)) + "] " END IF CALL FaintBox(12, 14, 41, 79) LOCATE 12, 41: PRINT CHR$(194); : LOCATE 12, 73: PRINT CHR$(193); LOCATE 13, 43: PRINT "New line starts if #"; IF Trigger% < 10 THEN PRINT USING "#"; Trigger%; ELSE PRINT USING "##"; Trigger%; END IF PRINT " holds "; T$; ELSE CALL Blanker(12, 14, 41, 79) LOCATE 12, 41 FOR i% = 41 TO 72: PRINT CHR$(196); : NEXT i%: PRINT CHR$(217); END IF IF StopMode% > 0 THEN RecordL% = 60 FOR i% = 1 TO 59 IF MID$(LastRec$, i%, 1) = StopByte$ THEN RecordL% = i% EXIT FOR END IF NEXT i% END IF Overlap% = FALSE% FOR i% = 1 TO 60 IF ((i% >= XLeft%) AND (i% < XLeft% + XLen%)) AND ((i% >= YLeft%) AND (i% < YLeft% + YLen%)) THEN Overlap% = True% NEXT i% IF Overlap% THEN COLOR Background%, Foreground% LOCATE 25, 20 PRINT " PROBABLE ERROR: X and Y RANGES OVERLAP WHERE ? APPEARS! "; ELSE COLOR Foreground%, Background% LOCATE 25, 20 PRINT " "; END IF COLOR Foreground%, Background% LOCATE 8, 12 FOR i% = 1 TO 60 IF i% <= RecordL% THEN COLOR Background%, Foreground% ELSE COLOR Foreground%, Background% END IF PRINT " "; NEXT i% LOCATE 8, 11 + XLeft% FOR i% = 1 TO XLen% IF (XLeft% + i% - 1) <= RecordL% THEN COLOR Background%, Foreground% ELSE COLOR Foreground%, Background% END IF PRINT "X"; NEXT i% LOCATE 8, 11 + YLeft% FOR i% = 1 TO YLen% Col% = YLeft% + i% - 1 IF Col% <= RecordL% THEN COLOR Background%, Foreground% ELSE COLOR Foreground%, Background% END IF IF ((Col% >= XLeft%) AND (Col% < XLeft% + XLen%)) THEN PRINT "?"; ELSE PRINT "Y"; END IF NEXT i% FOR i% = 1 TO 6 IF i% = FOHot% THEN COLOR Background%, Foreground% ELSE COLOR Foreground%, Background% END IF LOCATE 13 + 2 * i%, 2 PRINT FOShort$(i%); NEXT i% OldHot% = FOHot% HoHum: a$ = INKEY$: IF LEN(a$) = 0 THEN GOTO HoHum IF a$ = CHR$(13) THEN 'Enter pressed: take action COLOR Foreground%, Background% IF FOHot% = 1 THEN LOCATE 16, 18 PRINT "HOW CAN THIS PROGRAM IDENTIFY THE END OF A RECORD?"; CALL BoldBox(17, 19, 18, 79) CALL BoldBox(19, 21, 18, 79): LOCATE 19, 18: PRINT CHR$(204); : LOCATE 19, 79: PRINT CHR$(185); CALL BoldBox(21, 23, 18, 79): LOCATE 21, 18: PRINT CHR$(204); : LOCATE 21, 79: PRINT CHR$(185); CALL BoldBox(23, 25, 18, 79): LOCATE 23, 18: PRINT CHR$(204); : LOCATE 23, 79: PRINT CHR$(185); DIM ZAShort$(4) ZAShort$(1) = "Each (x,y) record ends with a CR and a LF " ZAShort$(2) = "Each (x,y) record ends with a CR only " ZAShort$(3) = "Each (x,y) record ends with a different special character " ZAShort$(4) = "All records have equal length [last resort; errors common!] " FOR i% = 1 TO 4 IF i% = ZAHot% THEN COLOR Background%, Foreground% ELSE COLOR Foreground%, Background% END IF LOCATE 16 + 2 * i%, 19 PRINT ZAShort$(i%); NEXT i% COLOR Foreground%, Background% NewZA: OldHot% = ZAHot% ZoHum: a$ = INKEY$: IF LEN(a$) = 0 THEN GOTO ZoHum IF a$ = CHR$(13) THEN 'Enter pressed: take action COLOR Foreground%, Background% CALL Blanker(16, 25, 18, 79) IF ZAHot% = 1 THEN StopMode% = 1 StopByte$ = CHR$(10) ELSEIF ZAHot% = 2 THEN StopMode% = 1 StopByte$ = CHR$(13) ELSEIF ZAHot% = 3 THEN StopMode% = 1 LOCATE 18, 20: PRINT "Enter a single character which marks the record end."; LOCATE 19, 19: PRINT "(If character is not on keyboard, then type its"; LOCATE 20, 20: PRINT "ASCII code, in decimal [base 10], using a leading"; LOCATE 21, 20: PRINT "zero if necessary so that you type at least 2 digits)"; LOCATE 23, 20: PRINT "Stop Byte = "; : COLOR Background%, Foreground%: PRINT " "; LOCATE 23, 32: INPUT ; "", StopByte$ IF LEN(StopByte$) > 1 THEN StopByte$ = CHR$(VAL(StopByte$)) LOCATE 23, 32: T% = ASC(LEFT$(StopByte$, 1)) IF T% < 8 OR T% > 13 THEN T$ = StopByte$ ELSE T$ = "[unprintable]" END IF PRINT T$; COLOR Foreground%, Background%: PRINT " "; LOCATE 24, 20: PRINT "Press any key to continue ..."; ViewSB: a$ = INKEY$: IF LEN(a$) = 0 THEN GOTO ViewSB CALL Blanker(18, 24, 19, 79) ELSEIF ZAHot% = 4 THEN StopByte$ = CHR$(7) 'Bell; something we don't expect to see! LOCATE 18, 20: PRINT "Measure total length of each (x,y) record,"; LOCATE 19, 20: PRINT "in bytes, including ALL leading characters"; LOCATE 20, 20: PRINT "and trailing characters (including funny ones);"; LOCATE 21, 20: PRINT "and enter an integer from 1 to 60:"; COLOR Background%, Foreground% LOCATE 21, 55: PRINT " "; ReadRL: LOCATE 21, 55: INPUT ; "", Trial% IF Trial% >= 1 AND Trial% <= 60 THEN RecordL% = Trial% StopMode% = 0 COLOR Foreground%, Background% CALL Blanker(18, 21, 20, 79) GOTO NewFormat ELSE BEEP GOTO ReadRL END IF END IF GOTO NewFormat ELSEIF ((LEN(a$) = 2) AND (RIGHT$(a$, 1) = "P")) THEN 'Down arrow key ZAHot% = ZAHot% + 1 IF ZAHot% > 4 THEN ZAHot% = 1 COLOR Foreground%, Background% LOCATE 16 + 2 * OldHot%, 19 PRINT ZAShort$(OldHot%); COLOR Background%, Foreground% LOCATE 16 + 2 * ZAHot%, 19 PRINT ZAShort$(ZAHot%); ELSEIF ((LEN(a$) = 2) AND (RIGHT$(a$, 1) = "H")) THEN 'Up arrow key ZAHot% = ZAHot% - 1 IF ZAHot% = 0 THEN ZAHot% = 4 COLOR Foreground%, Background% LOCATE 16 + 2 * OldHot%, 19 PRINT ZAShort$(OldHot%); COLOR Background%, Foreground% LOCATE 16 + 2 * ZAHot%, 19 PRINT ZAShort$(ZAHot%); END IF GOTO NewZA ELSEIF FOHot% = 2 THEN LOCATE 18, 20: PRINT "Enter an integer digit (1-60) which gives"; LOCATE 19, 20: PRINT "the left-most position that MIGHT be part"; LOCATE 20, 20: PRINT "of the X field (including its leading - "; LOCATE 21, 20: PRINT "sign, if one might appear at any time:"; COLOR Background%, Foreground% LOCATE 21, 59: PRINT " "; ReadX1: LOCATE 21, 59: INPUT ; "", Trial% IF Trial% >= 1 AND Trial% <= 60 THEN XLeft% = Trial% CALL Blanker(18, 21, 20, 79) LOCATE 18, 20: PRINT "Enter the length of the X-field (1-27):"; COLOR Background%, Foreground% LOCATE 18, 59: PRINT " "; ReadX2: LOCATE 18, 59: INPUT ; "", Trial% IF Trial% >= 1 AND Trial% <= 27 THEN XLen% = Trial% CALL Blanker(18, 21, 20, 79) GOTO NewFormat ELSE BEEP GOTO ReadX2 END IF ELSE BEEP GOTO ReadX1 END IF ELSEIF FOHot% = 3 THEN LOCATE 18, 20: PRINT "Enter an integer digit (1-60) which gives"; LOCATE 19, 20: PRINT "the left-most position that MIGHT be part"; LOCATE 20, 20: PRINT "of the Y field (including its leading - "; LOCATE 21, 20: PRINT "sign, if one might appear at any time:"; COLOR Background%, Foreground% LOCATE 21, 59: PRINT " "; ReadY1: LOCATE 21, 59: INPUT ; "", Trial% IF Trial% >= 1 AND Trial% <= 60 THEN YLeft% = Trial% CALL Blanker(18, 21, 20, 79) LOCATE 18, 20: PRINT "Enter the length of the Y-field (1-27):"; COLOR Background%, Foreground% LOCATE 18, 59: PRINT " "; ReadY2: LOCATE 18, 59: INPUT ; "", Trial% IF Trial% >= 1 AND Trial% <= 27 THEN YLen% = Trial% CALL Blanker(18, 21, 20, 79) GOTO NewFormat ELSE BEEP GOTO ReadY2 END IF ELSE BEEP GOTO ReadY1 END IF ELSEIF FOHot% = 4 THEN 'pen-up mark COLOR Foreground%, Background% LOCATE 18, 20: PRINT "Some digitisers have a 'stream' or 'machine-gun' mode."; LOCATE 19, 20: PRINT "Of these, some do not send data unless the 'pen' is 'down'."; LOCATE 20, 20: PRINT "However, others send the useless points, but mark them in"; LOCATE 21, 20: PRINT "some way. Does your digitiser EVER send useless points?"; CALL BoldBox(22, 24, 30, 36) CALL BoldBox(22, 24, 65, 70) DIM YNShort$(2): YNShort$(1) = " YES ": YNShort$(2) = " NO " YNHot% = 1 NewYesNo: FOR i% = 1 TO 2 IF i% = YNHot% THEN COLOR Background%, Foreground% ELSE COLOR Foreground%, Background% END IF LOCATE 23, i% * 35 - 4: PRINT YNShort$(i%); NEXT i% YesNoEh: a$ = INKEY$: IF LEN(a$) = 0 THEN GOTO YesNoEh IF a$ = CHR$(13) OR a$ = "Y" OR a$ = "y" OR a$ = "N" OR a$ = "n" THEN IF a$ = "Y" OR a$ = "y" THEN YNHot% = 1 ELSEIF a$ = "N" OR a$ = "n" THEN YNHot% = 2 END IF IF YNHot% = 1 THEN WasteSome% = True% CALL Blanker(18, 24, 20, 79) LOCATE 18, 20: PRINT "Enter a single character which marks unwanted records."; LOCATE 19, 19: PRINT "(If character is not on keyboard, then type its"; LOCATE 20, 20: PRINT "ASCII code, in decimal [base 10], using a leading"; LOCATE 21, 20: PRINT "zero if necessary so that you type at least 2 digits)"; LOCATE 23, 20: PRINT "WasteMark = "; : COLOR Background%, Foreground%: PRINT " "; LOCATE 23, 32: INPUT ; "", WasteMark$ IF LEN(WasteMark$) > 1 THEN WasteMark$ = CHR$(VAL(WasteMark$)) LOCATE 23, 32: T% = ASC(LEFT$(WasteMark$, 1)) IF T% < 8 OR T% > 13 THEN T$ = WasteMark$ ELSE T$ = "[unprintable]" END IF PRINT T$; COLOR Foreground%, Background%: PRINT " "; LOCATE 24, 20: PRINT "Press any key to continue ..."; DO UNTIL INKEY$ <> "": LOOP CALL Blanker(18, 24, 19, 79) LOCATE 18, 20: PRINT "Which position in the record would hold this"; LOCATE 19, 20: PRINT "mark of an unwanted point, if there was one?"; LOCATE 21, 20: PRINT " Enter an integer from 1 to 60:"; COLOR Background%, Foreground% LOCATE 21, 55: PRINT " "; ReadWP: LOCATE 21, 55: INPUT ; "", Trial% IF Trial% >= 1 AND Trial% <= 60 THEN CheckHere% = Trial% COLOR Foreground%, Background% CALL Blanker(18, 21, 20, 79) GOTO NewFormat ELSE BEEP GOTO ReadWP END IF ELSE WasteSome% = FALSE% END IF CALL Blanker(18, 24, 20, 79) GOTO NewFormat ELSE YNHot% = 3 - YNHot% GOTO NewYesNo END IF ELSEIF FOHot% = 5 THEN 'New-line mark COLOR Foreground%, Background% LOCATE 18, 20: PRINT "If you do not intend to use headers for line segments,"; LOCATE 19, 20: PRINT "it may be convenient to begin new segments from the"; LOCATE 20, 20: PRINT "digitiser, rather than returning to the keyboard."; LOCATE 21, 20: PRINT "Would you like to designate a signal byte for new lines?"; CALL BoldBox(22, 24, 30, 36) CALL BoldBox(22, 24, 65, 70) YNShort$(1) = " YES ": YNShort$(2) = " NO " YNHot% = 1 RadYesNo: FOR i% = 1 TO 2 IF i% = YNHot% THEN COLOR Background%, Foreground% ELSE COLOR Foreground%, Background% END IF LOCATE 23, i% * 35 - 4: PRINT YNShort$(i%); NEXT i% YesNoEx: a$ = INKEY$: IF LEN(a$) = 0 THEN GOTO YesNoEx IF a$ = CHR$(13) OR a$ = "Y" OR a$ = "y" OR a$ = "N" OR a$ = "n" THEN IF a$ = "Y" OR a$ = "y" THEN YNHot% = 1 ELSEIF a$ = "N" OR a$ = "n" THEN YNHot% = 2 END IF IF YNHot% = 1 THEN Recycling% = True% CALL Blanker(18, 24, 20, 79) LOCATE 18, 20: PRINT "Enter a single character which marks the end of a line."; LOCATE 19, 19: PRINT "(If character is not on keyboard, then type its"; LOCATE 20, 20: PRINT "ASCII code, in decimal [base 10], using a leading"; LOCATE 21, 20: PRINT "zero if necessary so that you type at least 2 digits)"; LOCATE 23, 20: PRINT "EjectMark = "; : COLOR Background%, Foreground%: PRINT " "; LOCATE 23, 32: INPUT ; "", EjectMark$ IF LEN(EjectMark$) > 1 THEN EjectMark$ = CHR$(VAL(EjectMark$)) LOCATE 23, 32: T% = ASC(LEFT$(EjectMark$, 1)) IF T% < 8 OR T% > 13 THEN T$ = EjectMark$ ELSE T$ = "[unprintable]" END IF PRINT T$; COLOR Foreground%, Background%: PRINT " "; LOCATE 24, 20: PRINT "Press any key to continue ..."; DO UNTIL INKEY$ <> "": LOOP CALL Blanker(18, 24, 19, 79) LOCATE 18, 20: PRINT "Which position in the record would hold this"; LOCATE 19, 20: PRINT "mark of the end of a line, if there was one?"; LOCATE 21, 20: PRINT " Enter an integer from 1 to 60:"; COLOR Background%, Foreground% LOCATE 21, 55: PRINT " "; ReadEP: LOCATE 21, 55: INPUT ; "", Trial% IF Trial% >= 1 AND Trial% <= 60 THEN Trigger% = Trial% COLOR Foreground%, Background% CALL Blanker(18, 21, 20, 79) GOTO NewFormat ELSE BEEP GOTO ReadEP END IF ELSE Recycling% = FALSE% END IF CALL Blanker(18, 24, 20, 79) GOTO NewFormat ELSE YNHot% = 3 - YNHot% GOTO RadYesNo END IF ELSEIF FOHot% = 6 THEN GOTO Manual END IF GOTO NewFormat ELSEIF ((LEN(a$) = 2) AND (RIGHT$(a$, 1) = "P")) THEN 'Down arrow key FOHot% = FOHot% + 1 IF FOHot% > 6 THEN FOHot% = 1 COLOR Foreground%, Background% LOCATE 13 + 2 * OldHot%, 2 PRINT FOShort$(OldHot%); COLOR Background%, Foreground% LOCATE 13 + 2 * FOHot%, 2 PRINT FOShort$(FOHot%); ELSEIF ((LEN(a$) = 2) AND (RIGHT$(a$, 1) = "H")) THEN 'Up arrow key FOHot% = FOHot% - 1 IF FOHot% = 0 THEN FOHot% = 6 COLOR Foreground%, Background% LOCATE 13 + 2 * OldHot%, 2 PRINT FOShort$(OldHot%); COLOR Background%, Foreground% LOCATE 13 + 2 * FOHot%, 2 PRINT FOShort$(FOHot%); ELSE a$ = UCASE$(a$) FOR i% = 1 TO 6 IF a$ = FOInitial$(i%) THEN FOHot% = i% COLOR Foreground%, Background% LOCATE 13 + 2 * OldHot%, 2 PRINT FOShort$(OldHot%); COLOR Background%, Foreground% LOCATE 13 + 2 * FOHot%, 2 PRINT FOShort$(FOHot%); END IF NEXT i% END IF GOTO NewFormat ' '------------------------------------------------------------------ ' Test: '(T) interactive test of data transmission 'basic options: Clear buffer/display, Interpret, Exit to SetUp ' COLOR Foreground%, Background% CLS LOCATE 12, 20 PRINT "Attempting to open requested serial port ..." UseRow% = 13 StartCol% = 31 CALL OpenCOM(LineOpen%, PNHot%, Baud$, Parity$, DataBits$, StopBits$, StartCol%, UseRow%) COLOR Foreground%, Background% CLS LOCATE 1, 24 PRINT "TEST OF SINGLE-POINT TRANSMISSION" LOCATE 3, 20 PRINT "Use arrow keys or initial letter to select," LOCATE 4, 29 PRINT "then press Return/Enter." TNumber% = 3 DIM TShort$(3), TLong$(3), TOK%(3), TInitial$(3) TShort$(1) = " Clear " TShort$(2) = "Interpret" TShort$(3) = " Exit " TInitial$(1) = "C" TInitial$(2) = "I" TInitial$(3) = "E" TLong$(1) = "(clear the display below before each test) " TLong$(2) = "(read contents of buffer and display below) " TLong$(3) = "(exit to Set-Up menu, to change or save settings)" TSLen% = LEN(TShort$(1)) TLLen% = LEN(TLong$(1)) TOK%(1) = True% TOK%(2) = FALSE% TOK%(3) = True% THot% = 1 Interactive: CALL SETMENU(13, TNumber%, TShort$(), TInitial$(), TLong$(), TSLen%, TLLen%, TOK%(), THot%) LOCATE 14, 1 FOR i% = 1 TO 80: PRINT CHR$(205); : NEXT i% LOCATE 15, 3 PRINT "To conduct a test: (1) press Clear to clear buffer and display; (2) click"; LOCATE 16, 3 PRINT "digitiser ONCE; (3) wait a few seconds; (4) press Interpret to see record."; LOCATE 17, 1 FOR i% = 1 TO 80: PRINT CHR$(205); : NEXT i% CALL RUNMENU(13, TNumber%, TShort$(), TInitial$(), TLong$(), TSLen%, TLLen%, TOK%(), THot%) IF THot% = 1 THEN GOSUB ClearBuffer LOCATE 18, 10 PRINT "Note: Highlights show current Format settings; adjust to fit!"; LOCATE 19, 1 PRINT " 111111111122222222223333333333444444444455555555556"; LOCATE 20, 1 PRINT "Position: 123456789012345678901234567890123456789012345678901234567890"; LOCATE 22, 1 PRINT "ASCII:"; LOCATE 21, 12 COLOR Background%, Foreground% FOR j% = 1 TO 60 IF j% = (RecordL% + 1) THEN COLOR Foreground%, Background% PRINT " "; NEXT j% COLOR Background%, Foreground% LOCATE 22, 12 TempString$ = " Send data, then select Interpret and press Enter/Return " FOR j% = 1 TO 60 IF j% = (RecordL% + 1) THEN COLOR Foreground%, Background% PRINT MID$(TempString$, j%, 1); NEXT j% COLOR Foreground%, Background% LOCATE 23, 1 PRINT "Hex (Left):"; COLOR Background%, Foreground% FOR j% = 1 TO 60 IF j% = (RecordL% + 1) THEN COLOR Foreground%, Background% PRINT " "; NEXT j% LOCATE 24, 1 COLOR Foreground%, Background% PRINT "Hex(Right):"; COLOR Background%, Foreground% FOR j% = 1 TO 60 IF j% = (RecordL% + 1) THEN COLOR Foreground%, Background% PRINT " "; NEXT j% LOCATE 25, 1 COLOR Foreground%, Background% PRINT "Interpreted as: X = , Y = "; COLOR Background%, Foreground% LOCATE 25, 21 FOR j% = 1 TO 27 IF j% = (XLen% + 1) THEN COLOR Foreground%, Background% PRINT " "; NEXT j% COLOR Background%, Foreground% LOCATE 25, 54 FOR j% = 1 TO 27 IF j% = (YLen% + 1) THEN COLOR Foreground%, Background% PRINT " "; NEXT j% COLOR Foreground%, Background% TOK%(2) = True% THot% = 2 GOTO Interactive ELSEIF THot% = 2 THEN LastOne% = LOC(1) IF LastOne% > 60 THEN LastOne% = 60 LastRec$ = INPUT$(LastOne%, #1) IF StopMode% > 0 THEN RecordL% = 60 FOR i% = 1 TO 59 IF MID$(LastRec$, i%, 1) = StopByte$ THEN RecordL% = i% EXIT FOR END IF NEXT i% END IF COLOR Background%, Foreground% FOR i% = 1 TO 60 Col% = 11 + i% IF i% = (RecordL% + 1) THEN COLOR Foreground%, Background% IF i% <= LastOne% THEN a$ = MID$(LastRec$, i%, 1) IF a$ = CHR$(13) THEN LOCATE 21, Col% PRINT "C"; LOCATE 22, Col% PRINT "R"; ELSEIF a$ = CHR$(10) THEN LOCATE 21, Col% PRINT "L"; LOCATE 22, Col% PRINT "F"; ELSE LOCATE 21, Col% PRINT " "; LOCATE 22, Col% PRINT a$; END IF a% = CVI(a$ + a$) MOD 256 AH$ = HEX$(a%) IF LEN(AH$) = 1 THEN AH$ = "0" + AH$ AHL$ = LEFT$(AH$, 1) AHR$ = RIGHT$(AH$, 1) LOCATE 23, Col% PRINT AHL$; LOCATE 24, Col% PRINT AHR$; ELSE LOCATE 21, Col%: PRINT " "; LOCATE 22, Col%: PRINT " "; LOCATE 23, Col%: PRINT " "; LOCATE 24, Col%: PRINT " "; END IF NEXT i% x$ = MID$(LastRec$, XLeft%, XLen%) y$ = MID$(LastRec$, YLeft%, YLen%) COLOR Background%, Foreground% LOCATE 25, 21 FOR i% = 1 TO 27 IF i% = (XLen% + 1) THEN COLOR Foreground%, Background% T$ = MID$(x$, i%, 1) IF (T$ = CHR$(13)) OR (T$ = CHR$(10)) THEN T$ = CHR$(20) PRINT T$; NEXT i% COLOR Background%, Foreground% LOCATE 25, 54 FOR i% = 1 TO 27 IF i% = (YLen% + 1) THEN COLOR Foreground%, Background% T$ = MID$(y$, i%, 1) IF (T$ = CHR$(13)) OR (T$ = CHR$(10)) THEN T$ = CHR$(20) PRINT T$; NEXT i% COLOR Foreground%, Background% TOK%(2) = FALSE% THot% = 1 GOTO Interactive ELSEIF THot% = 3 THEN IF LineOpen% THEN CLOSE #1 LineOpen% = FALSE% END IF GOTO SetUp END IF ' '------------------------------------------------------------------ ' ' '---------------------------------------------------------------- ' Digitise: '(DI) 'define directories, filenames, formats, and scaling, then go to work ' IF LineOpen% THEN CLOSE #1 '(possibly opened by Scaling or Test submenus) LineOpen% = FALSE% END IF SCREEN 0 COLOR Foreground%, Background% CLS LOCATE 1, 33 PRINT "DIGITIZING MENU" LOCATE 3, 7 PRINT "Use arrow keys or initial letter to select, then press Return/Enter." LOCATE 4, 1 PRINT "*** You MUST designate an Output file and set Scaling before Going to Work. ***"; DINumber% = 7 DIM DIShort$(7), DILong$(7), DIInitial$(7) DIShort$(1) = " Chdir " DIShort$(2) = "Output-file " DIShort$(3) = "Display-file" DIShort$(4) = " Headers " DIShort$(5) = " Scaling " DIShort$(6) = "Go to work !" DIShort$(7) = " Exit " DIInitial$(1) = "C" DIInitial$(2) = "O" DIInitial$(3) = "D" DIInitial$(4) = "H" DIInitial$(5) = "S" DIInitial$(6) = "G" DIInitial$(7) = "E" DILong$(1) = "Check or Change directory in which files reside " DILong$(2) = "set name of Output-file (mandatory!) " DILong$(3) = "set name of Display-file to show as background (optional) " DILong$(4) = "set Headers for line segments (titles? end-marker?) " DILong$(5) = "set Scaling, from digitiser units to map units (mandatory!) " DILong$(6) = "digitise line segments " DILong$(7) = "Exit to main menu, to correct set-up or to terminate a session" DISLen% = LEN(DIShort$(1)) DILLen% = LEN(DILong$(1)) DIOk%(6) = OutChosen% AND Scaled% CALL SETMENU(25, DINumber%, DIShort$(), DIInitial$(), DILong$(), DISLen%, DILLen%, DIOk%(), DIHot%) CALL RUNMENU(25, DINumber%, DIShort$(), DIInitial$(), DILong$(), DISLen%, DILLen%, DIOk%(), DIHot%) IF DIHot% = 1 THEN CLS LOCATE 1, 21: PRINT "SETTING CURRENT DIRECTORY FOR DATA FILES"; GetOutPath: LOCATE 10, 16: COLOR Foreground%, Background% PRINT "Output file(s) resulting from digitizing reside in"; LOCATE 11, 16 COLOR Background%, Foreground% Blanks$ = " " Pad% = 40 - LEN(OutPath$) Display$ = OutPath$ + RIGHT$(Blanks$, Pad%) LOCATE 11, 16 PRINT Display$ LOCATE 12, 16 COLOR Foreground%, Background% PRINT "(Return/Enter to accept, or type preferred path)" COLOR Background%, Foreground% LOCATE 11, 16 GetFirst: First$ = INKEY$: IF LEN(First$) = 0 THEN GOTO GetFirst IF First$ = CHR$(13) THEN COLOR Foreground%, Background% GOTO Digitise ELSE LOCATE 11, 16 PRINT Blanks$ LOCATE 11, 16 PRINT First$; INPUT ; "", Rest$ Trial$ = UCASE$(First$ + Rest$) IF RIGHT$(Trial$, 1) = "\" THEN Trial$ = LEFT$(Trial$, LEN(Trial$) - 1) ON ERROR GOTO Oops: IF MID$(Trial$, 2, 1) = ":" THEN CHDRIVE LEFT$(Trial$, 2) CHDIR Trial$ '------------------------ GOTO Around: Oops: BEEP CHDRIVE DefaultDrive$ CHDIR CD$ RESUME GetOutPath: Around: ON ERROR GOTO AnyError '------------------------ OutPath$ = Trial$ END IF LOCATE 24, 21 COLOR Background%, Foreground% PRINT "OK. Press any key to continue ..."; DO UNTIL INKEY$ <> "": LOOP COLOR Foreground%, Background% GOTO Digitise ELSEIF DIHot% = 2 THEN GetOutFile: COLOR Foreground%, Background% CLS LOCATE 1, 25: PRINT "Setting name of the OUTPUT-File"; FileN$ = OutPath$ + "\*.DIG" IF LEN(DIR$(FileN$)) THEN LOCATE 3, 1: PRINT "Here are the existing .DIG files:"; PRINT : PRINT FILES FileN$ LOCATE 5, 1: PRINT OutPath$; " contains ... "; END IF Text$ = "Enter new or existing filename (1-8 characters, no extension): " CALL GetFileName(Text$, 21, NewName$) OutFileN$ = OutPath$ + "\" + NewName$ + ".DIG" IF OutFileN$ = SeeFileN$ THEN BEEP LOCATE 23, 10 PRINT "THIS NAME ALREADY CHOSEN AS DISPLAY-FILE"; WaitTime! = 1!: StartTime! = TIMER: DO: TimeNow! = TIMER: LOOP UNTIL (TimeNow! - StartTime!) > WaitTime! GOTO GetOutFile END IF IF LEN(DIR$(OutFileN$)) = 0 THEN CLOSE #3 OPEN OutFileN$ FOR OUTPUT AS #3 EmptyOut% = True% DIOk%(4) = True% ' format can be freely changed ELSE CALL Blanker(2, 20, 1, 80) LOCATE 3, 27: PRINT "*** FILE ALREADY EXISTS ***"; DIM FEShort$(3), FEInitial$(3), FELong$(3), FEOK%(3) FEShort$(1) = " Change filename " FEShort$(2) = "Append data at end" FEShort$(3) = " Overwrite file " FEInitial$(1) = "C": FEInitial$(2) = "A": FEInitial$(3) = "O" FELong$(1) = "": FELong$(2) = "": FELong$(3) = "" FESLen% = LEN(FEShort$(1)): FELLen% = LEN(FELong$(1)) FEOK%(1) = True%: FEOK%(2) = True%: FEOK%(3) = True%: FEHot% = 1 CALL SETMENU(20, 3, FEShort$(), FEInitial$(), FELong$(), FESLen%, FELLen%, FEOK%(), FEHot%) CALL RUNMENU(20, 3, FEShort$(), FEInitial$(), FELong$(), FESLen%, FELLen%, FEOK%(), FEHot%) IF FEHot% = 1 THEN GOTO GetOutFile ELSEIF FEHot% = 2 THEN OPEN OutFileN$ FOR INPUT AS #3 ' number of titles and nature of endmark must be inferred: PastTitles% = FALSE% Titles% = 0 DO UNTIL EOF(3) LINE INPUT #3, Rec$ TwoBit$ = LEFT$(Rec$, 2) IF (TwoBit$ = " +") OR (TwoBit$ = " -") THEN ANumber% = True% ELSE ANumber% = FALSE% END IF IF ANumber% THEN PastTitles% = True% ELSE IF PastTitles% THEN EndMark$ = Rec$ EXIT DO ELSE Titles% = Titles% + 1 END IF END IF LOOP EWidth% = LEN(EndMark$) CLOSE #3 ' reread file to count segments and get last title set OPEN OutFileN$ FOR INPUT AS #3 TitleNo% = 0 SegsDone% = 0 DO UNTIL EOF(3) LINE INPUT #3, Rec$ TitleNo% = TitleNo% + 1 IF TitleNo% <= Titles% THEN FirstFive$(TitleNo%) = Rec$ IF LEFT$(Rec$, EWidth%) = EndMark$ THEN SegsDone% = SegsDone% + 1 Points% = TitleNo% - 1 - Titles% TitleNo% = 0 END IF LOOP CLOSE #3 IF SegsDone% > 0 THEN EmptyOut% = FALSE% DIOk%(4) = FALSE% 'can't change format while appending ELSE EmptyOut% = True% DIOk%(4) = True% END IF ELSEIF FEHot% = 3 THEN CLOSE #3 KILL OutFileN$ OPEN OutFileN$ FOR OUTPUT AS #3 EmptyOut% = True% DIOk%(4) = True% END IF END IF OutChosen% = True% GOTO Digitise ELSEIF DIHot% = 3 THEN GetSeeFile: COLOR Foreground%, Background% CLS LOCATE 1, 20: PRINT "Setting name of the DISPLAY-File (optional)"; FileN$ = OutPath$ + "\*.DIG" IF LEN(DIR$(FileN$)) THEN LOCATE 3, 1: PRINT "Here are the existing .DIG files:"; PRINT : PRINT FILES FileN$ LOCATE 5, 1: PRINT OutPath$; " contains ... "; END IF LOCATE 21, 10 PRINT "If you do not want to display any of these files, press ESCape now."; LOCATE 22, 10 PRINT "If you do, press any other key to continue ..."; CheckESC: a$ = INKEY$: IF LEN(a$) = 0 THEN GOTO CheckESC IF a$ = CHR$(27) THEN SeeFileN$ = "" SeeChosen% = FALSE% GOTO Digitise END IF CALL Blanker(21, 22, 1, 80) Text$ = "Enter an existing filename (1-8 characters, no extension): " CALL GetFileName(Text$, 21, NewName$) SeeFileN$ = OutPath$ + "\" + NewName$ + ".DIG" IF SeeFileN$ = OutFileN$ THEN BEEP LOCATE 23, 10 PRINT "THIS NAME ALREADY CHOSEN AS OUTPUT-FILE"; WaitTime! = 1!: StartTime! = TIMER: DO: TimeNow! = TIMER: LOOP UNTIL (TimeNow! - StartTime!) > WaitTime! GOTO GetSeeFile END IF IF LEN(DIR$(SeeFileN$)) = 0 THEN BEEP GOTO GetSeeFile ELSE CLOSE #4 OPEN SeeFileN$ FOR INPUT AS #4 ' number of titles and nature of endmark must be inferred: PastTitles% = FALSE% SeeTitles% = 0 DO UNTIL EOF(4) LINE INPUT #4, Rec$ TwoBit$ = LEFT$(Rec$, 2) IF (TwoBit$ = " +") OR (TwoBit$ = " -") THEN ANumber% = True% ELSE ANumber% = FALSE% END IF IF ANumber% THEN PastTitles% = True% ELSE IF PastTitles% THEN SeeEndMark$ = Rec$ EXIT DO ELSE SeeTitles% = SeeTitles% + 1 END IF END IF LOOP SeeEWidth% = LEN(SeeEndMark$) CLOSE #4 END IF SeeChosen% = True% GOTO Digitise ELSEIF DIHot% = 4 THEN COLOR Foreground%, Background% CLS LOCATE 1, 29: PRINT "HEADERS in Output File" PRINT PRINT "Every output file contains one or more line segments" PRINT " (although some 'lines' may contain only a single point)." PRINT "Graphically, a segment ends where the 'pen' is 'lifted' to break the line." PRINT "Procedurally, you begin a new segment by touching the keyboard," PRINT " or by sending a special marker character from the digitiser." PRINT PRINT "Now, choose the character or character-string that you wish to use to signal" PRINT " the end of each line-segment in the output file;" PRINT "either press Enter to accept the suggestion, or type your preferred marker:" PRINT " (in either case, the marker is preceded and followed by CR and LF)" COLOR Background%, Foreground% PRINT EndMark$ LOCATE 13, 1: INPUT ; "", Trial$ IF Trial$ = "" THEN LOCATE 13, 1: PRINT EndMark$; ELSE EndMark$ = Trial$ LOCATE 13, 1: PRINT EndMark$; COLOR Foreground%, Background% Pad% = 81 - POS(999) FOR i% = 1 TO Pad%: PRINT " "; : NEXT i% END IF COLOR Foreground%, Background% LOCATE 15, 1 PRINT "How many title/comment lines should precede each line segment (0-5): " PRINT " (if you choose 0, you may be able to enter multiple segments without" PRINT " returning to the keyboard: see Setup/Manual/Format/New segment marker)" Get125: LOCATE 15, 70 PRINT USING "#"; Titles%; : LOCATE 15, 70: INPUT ; "", Titles$ IF Titles$ <> "" THEN Titles% = VAL(Titles$) IF Titles% < 0 OR Titles% > 5 THEN BEEP LOCATE 15, 70: PRINT " "; IF Titles% > 5 THEN Titles% = 5 ELSE Titles% = 0 GOTO Get125 END IF IF Titles% > 0 THEN LOCATE 19, 1 PRINT "Enter any character or character-string that you wish to use to signal" PRINT " the beginning of title lines in the output file: "; LOCATE 21, 4 PRINT "(or just press Enter if you don't want any)" COLOR Background%, Foreground% LOCATE 20, 54: PRINT TitleMark$ LOCATE 20, 54: INPUT ; "", Trial$ IF Trial$ = "" THEN LOCATE 20, 54: PRINT TitleMark$; ELSE TitleMark$ = Trial$ LOCATE 20, 54: PRINT TitleMark$; COLOR Foreground%, Background% Pad% = 81 - POS(999) FOR i% = 1 TO Pad%: PRINT " "; : NEXT i% END IF END IF WaitTime! = 2!: StartTime! = TIMER: DO: TimeNow! = TIMER: LOOP UNTIL (TimeNow! - StartTime!) > WaitTime! COLOR Foreground%, Background% GOTO Digitise ELSEIF DIHot% = 5 THEN UseRow% = 24 StartCol% = 31 CALL OpenCOM(LineOpen%, PNHot%, Baud$, Parity$, DataBits$, StopBits$, StartCol%, UseRow%) COLOR Foreground%, Background% CLS PRINT " y" PRINT " " + CHR$(179) PRINT " YMAX " + CHR$(197); : FOR i% = 1 TO 34: PRINT CHR$(196); : NEXT i%: PRINT CHR$(197); "" PRINT " " + CHR$(179) + "[UL] [UR]" + CHR$(179) PRINT " " + CHR$(179) + " " + CHR$(179) PRINT " " + CHR$(179) + " " + CHR$(179) PRINT " " + CHR$(179) + " " + CHR$(179) PRINT " " + CHR$(179) + "[LL] [LR]" + CHR$(179) PRINT " YMIN " + CHR$(197); : FOR i% = 1 TO 34: PRINT CHR$(196); : NEXT i%: PRINT CHR$(197) + CHR$(196) + CHR$(196) + CHR$(196) + CHR$(196) + " x" PRINT " XMIN XMAX"; LOCATE 12, 1 PRINT "Your original needs an accurate rectangle around the area to be digitised." PRINT "Please draw one now, if it does not already exist." COLOR Background%, Foreground% LOCATE 15, 1 PRINT "PLEASE DIGITISE THE LOWER LEFT CORNER [LL] POINT NOW ..."; COLOR Background% + 16, Foreground% LOCATE 9, 19: PRINT CHR$(197); 'corner will blink in reverse lettering COLOR Foreground%, Background% IF StopMode% THEN BytesNeeded% = YLeft% + YLen% - 1 B2% = XLeft% + XLen% - 1 IF B2% > BytesNeeded% THEN BytesNeeded% = B2% IF WasteSome% THEN IF CheckHere% > BytesNeeded% THEN BytesNeeded% = CheckHere% END IF ELSE BytesNeeded% = RecordL% END IF DO GOSUB GetPair LOOP WHILE (WasteSome% AND (MID$(Rec$, CheckHere%, 1) = WasteMark$)) LOCATE 9, 19: PRINT CHR$(197); 'clear blinking corner PLAY "ML T180 O3 L4 EC" 'Thank You WaitTime! = 1!: StartTime! = TIMER: DO: TimeNow! = TIMER: LOOP UNTIL (TimeNow! - StartTime!) > WaitTime! GOSUB ClearBuffer XLL$ = MID$(Rec$, XLeft%, XLen%): YLL$ = MID$(Rec$, YLeft%, YLen%) LOCATE 16, 1 COLOR Foreground%, Background%: PRINT "In digitiser units, X = "; COLOR Background%, Foreground%: PRINT XLL$; COLOR Foreground%, Background%: PRINT " and Y = "; COLOR Background%, Foreground%: PRINT YLL$ COLOR Foreground%, Background% LOCATE 18, 1: PRINT "If there is a gross error, press ESCape, and go adjust Set-Up."; LOCATE 19, 1: PRINT "Else, press any other key to continue ..."; GetA: a$ = INKEY$: IF LEN(a$) = 0 THEN GOTO GetA IF a$ = CHR$(27) THEN DIHot% = 7 GOTO Digitise END IF XLL! = VAL(XLL$): YLL! = VAL(YLL$) CALL Blanker(15, 19, 1, 80) LOCATE 15, 1: PRINT "Now, you may either Scale the digitiser output to map units, or leave it" PRINT "in Raw form. One advantage to Scaling is that the digitiser input will be" PRINT "automatically corrected if the map is not square on the digitiser bed."; CALL BoldBox(19, 21, 30, 36) CALL BoldBox(19, 21, 65, 70) DIM SRShort$(2): SRShort$(1) = "Scale": SRShort$(2) = " Raw" SRHot% = 1 NewSR: FOR i% = 1 TO 2 IF i% = SRHot% THEN COLOR Background%, Foreground% ELSE COLOR Foreground%, Background% END IF LOCATE 20, i% * 35 - 4: PRINT SRShort$(i%); NEXT i% SREh: a$ = INKEY$: IF LEN(a$) = 0 THEN GOTO SREh IF a$ = CHR$(13) OR a$ = "S" OR a$ = "s" OR a$ = "R" OR a$ = "r" THEN IF a$ = "S" OR a$ = "s" THEN SRHot% = 1 ELSEIF a$ = "R" OR a$ = "r" THEN SRHot% = 2 END IF IF SRHot% = 1 THEN ScaleIt% = True% CALL Blanker(15, 23, 1, 80) COLOR Background%, Foreground% LOCATE 15, 1 PRINT "PLEASE DIGITISE THE LOWER RIGHT CORNER [LR] POINT NOW ..."; COLOR Background% + 16, Foreground% LOCATE 9, 54: PRINT CHR$(197); 'corner will blink in reverse lettering COLOR Foreground%, Background% GOSUB ClearBuffer DO GOSUB GetPair LOOP WHILE (WasteSome% AND (MID$(Rec$, CheckHere%, 1) = WasteMark$)) LOCATE 9, 54: PRINT CHR$(197); 'clear blinking PLAY "ML T180 O3 L4 EC" 'Thank You WaitTime! = 1!: StartTime! = TIMER: DO: TimeNow! = TIMER: LOOP UNTIL (TimeNow! - StartTime!) > WaitTime! GOSUB ClearBuffer XLR$ = MID$(Rec$, XLeft%, XLen%): YLR$ = MID$(Rec$, YLeft%, YLen%) XLR! = VAL(XLR$): YLR! = VAL(YLR$) CALL Blanker(15, 23, 1, 80) LOCATE 15, 1 COLOR Background%, Foreground% PRINT "PLEASE DIGITISE THE UPPER LEFT CORNER [UL] POINT NOW ..."; COLOR Background% + 16, Foreground% LOCATE 3, 19: PRINT CHR$(197); 'corner will blink in reverse lettering COLOR Foreground%, Background% GOSUB ClearBuffer DO GOSUB GetPair LOOP WHILE (WasteSome% AND (MID$(Rec$, CheckHere%, 1) = WasteMark$)) LOCATE 3, 19: PRINT CHR$(197); 'clear blinking PLAY "ML T180 O3 L4 EC" 'Thank You WaitTime! = 1!: StartTime! = TIMER: DO: TimeNow! = TIMER: LOOP UNTIL (TimeNow! - StartTime!) > WaitTime! GOSUB ClearBuffer XUL$ = MID$(Rec$, XLeft%, XLen%): YUL$ = MID$(Rec$, YLeft%, YLen%) XUL! = VAL(XUL$): YUL! = VAL(YUL$) CALL Blanker(15, 18, 1, 80) XRot! = 57.298 * ATAN2F((YLR! - YLL!), (XLR! - XLL!)) YRot! = 57.298 * ATAN2F((YUL! - YLL!), (XUL! - XLL!)) - 90! IF ABS(XRot! - YRot!) > 180! THEN YRot! = YRot! + 360! LOCATE 15, 1 PRINT "Apparent X-axis misalignment is ......................... "; PRINT USING "###.#"; XRot!; : PRINT " degrees."; LOCATE 16, 1 PRINT "Apparent Y-axis misalignment (which should be similar) is "; PRINT USING "###.#"; YRot!; : PRINT " degrees."; LOCATE 17, 1 PRINT "Automatic correction will be made for misalignment of ... "; PRINT USING "###.#"; .5 * (XRot! + YRot!); : PRINT " degrees."; LOCATE 19, 1: PRINT "If there is a gross error, press ESCape, and go adjust Set-Up."; LOCATE 20, 1: PRINT "Else, press any other key to continue ..."; GetC: a$ = INKEY$: IF LEN(a$) = 0 THEN GOTO GetC IF a$ = CHR$(27) THEN DIHot% = 7 GOTO Digitise END IF CALL Blanker(15, 24, 1, 80) LOCATE 15, 1 PRINT "Enter the coordinates of these points in LOGICAL or MAP units,"; LOCATE 16, 4: PRINT "not physical or digitiser units!"; LOCATE 18, 10: INPUT ; "X value at XMIN [LL] = ", MXLL! LOCATE 18, 33: PRINT MXLL!; " "; LOCATE 19, 10: INPUT ; "X value at XMAX [LR] = ", MXLR! LOCATE 19, 33: PRINT MXLR!; " "; LOCATE 20, 10: INPUT ; "Y value at YMIN [LL] = ", MYLL! LOCATE 20, 33: PRINT MYLL!; " "; LOCATE 21, 10: INPUT ; "Y value at YMAX [UL] = ", MYUL! LOCATE 21, 33: PRINT MYUL!; " "; LOCATE 23, 1: PRINT "If there is a gross error, press ESCape, and repeat Scaling."; LOCATE 24, 1: PRINT "Else, press any other key to continue ..."; GetD: a$ = INKEY$: IF LEN(a$) = 0 THEN GOTO GetD IF a$ = CHR$(27) THEN DIHot% = 5 GOTO Digitise END IF Rot! = .5 * (XRot! + YRot!) / 57.298 M11! = COS(Rot!): M22! = M11! 'simple rotation matrix (about dig. origin) M12! = SIN(Rot!): M21! = -M12! XLLR! = M11! * XLL! + M12! * YLL! 'apply rotation to reference points YLLR! = M21! * XLL! + M22! * YLL! XLRR! = M11! * XLR! + M12! * YLR! YLRR! = M21! * XLR! + M22! * YLR! XULR! = M11! * XUL! + M12! * YUL! YULR! = M21! * XUL! + M22! * YUL! XScale! = (MXLR! - MXLL!) / (XLRR! - XLLR!) 'determine axis-stretches YScale! = (MYUL! - MYLL!) / (YULR! - YLLR!) M11! = M11! * XScale!: M12! = M12! * XScale! 'matrix is now a general M21! = M21! * YScale!: M22! = M22! * YScale! 'linear transform. XLLT! = M11! * XLL! + M12! * YLL! 'apply transform to LL corner YLLT! = M21! * XLL! + M22! * YLL! XAdd! = MXLL! - XLLT! 'correct the origin YAdd! = MYLL! - YLLT! GXScale! = CSNG(Nx% - 1) / (MXLR! - MXLL!) 'just fitting in x direction GYScale! = CSNG(1 - Ny%) / (MYUL! - MYLL!) 'just fitting in y direction Ratio! = ABS((YULR! - YLLR!) / (XLRR! - XLLR!)) 'aspect ratio of original IF Ratio! < (7.7 / 9.7) THEN ' wide original; doesn't fill whole height GYScale! = GYScale! * Ratio! / (7.7 / 9.7) 'shrink height C1% = 0 C2% = Nx% - 1 R1% = CINT(.5 * CSNG(Ny% - 1) - GYScale! * .5 * (MYUL! - MYLL!)) R2% = CINT(.5 * CSNG(Ny% - 1) + GYScale! * .5 * (MYUL! - MYLL!)) ELSE 'tall original GXScale! = GXScale! * (7.7 / 9.7) / Ratio! 'shrink width R1% = 0 R2% = Ny% - 1 C1% = CINT(.5 * CSNG(Nx% - 1) - GXScale! * .5 * (MXLR! - MXLL!)) C2% = CINT(.5 * CSNG(Nx% - 1) + GXScale! * .5 * (MXLR! - MXLL!)) END IF GXAdd! = .5 * CSNG(Nx% - 1) - GXScale! * .5 * (MXLL! + MXLR!) 'and GYAdd! = .5 * CSNG(Ny% - 1) - GYScale! * .5 * (MYLL! + MYUL!) 'center it Scaled% = True% DIHot% = 6 GOTO Digitise ELSEIF SRHot% = 2 THEN ScaleIt% = FALSE% CALL Blanker(15, 25, 1, 80) COLOR Background%, Foreground% LOCATE 15, 1 PRINT "PLEASE DIGITISE THE UPPER RIGHT CORNER [UR] POINT NOW ..."; COLOR Background% + 16, Foreground% LOCATE 3, 54: PRINT CHR$(197); 'corner blinks COLOR Foreground%, Background% GOSUB ClearBuffer DO GOSUB GetPair LOOP WHILE (WasteSome% AND (MID$(Rec$, CheckHere%, 1) = WasteMark$)) LOCATE 3, 54: PRINT CHR$(197); 'blinking suppressed PLAY "ML T180 O3 L4 EC" 'Thank You XUR$ = MID$(Rec$, XLeft%, XLen%): YUR$ = MID$(Rec$, YLeft%, YLen%) LOCATE 16, 1 COLOR Foreground%, Background%: PRINT "In digitiser units, X = "; COLOR Background%, Foreground%: PRINT XUR$; COLOR Foreground%, Background%: PRINT " and Y = "; COLOR Background%, Foreground%: PRINT YUR$ COLOR Foreground%, Background% LOCATE 18, 1: PRINT "If there is a gross error, press ESCape, and go adjust Set-Up."; LOCATE 19, 1: PRINT "Else, press any other key to continue ..."; GetB: a$ = INKEY$: IF LEN(a$) = 0 THEN GOTO GetB IF a$ = CHR$(27) THEN DIHot% = 7 GOTO Digitise END IF XUR! = VAL(XUR$): YUR! = VAL(YUR$) GXScale! = CSNG(Nx% - 1) / (XUR! - XLL!) 'just fitting in x direction GYScale! = CSNG(1 - Ny%) / (YUR! - YLL!) 'just fitting in y direction Ratio! = ABS((YUR! - YLL!) / (XUR! - XLL!)) 'aspect ratio of original IF Ratio! < (7.7 / 9.7) THEN ' wide original; doesn't fill whole height GYScale! = GYScale! * Ratio! / (7.7 / 9.7) 'shrink height C1% = 0 C2% = Nx% - 1 R1% = CINT(.5 * CSNG(Ny% - 1) - GYScale! * .5 * (YUR! - YLL!)) R2% = CINT(.5 * CSNG(Ny% - 1) + GYScale! * .5 * (YUR! - YLL!)) ELSE 'tall original GXScale! = GXScale! * (7.7 / 9.7) / Ratio! 'shrink width R1% = 0 R2% = Ny% - 1 C1% = CINT(.5 * CSNG(Nx% - 1) - GXScale! * .5 * (XUR! - XLL!)) C2% = CINT(.5 * CSNG(Nx% - 1) + GXScale! * .5 * (XUR! - XLL!)) END IF GXAdd! = .5 * CSNG(Nx% - 1) - GXScale! * .5 * (XLL! + XUR!) 'and GYAdd! = .5 * CSNG(Ny% - 1) - GYScale! * .5 * (YLL! + YUR!) 'center it Scaled% = True% DIHot% = 6 GOTO Digitise END IF ELSE SRHot% = 3 - SRHot% GOTO NewSR END IF GOTO Digitise ELSEIF DIHot% = 6 THEN FromTop% = True% LineSegments: '(LS) LSNumber% = 3 DIM LSShort$(3), LSInitial$(3), LSLong$(3), LSOK%(3) LSShort$(1) = " New segment " LSShort$(2) = " Delete last " LSShort$(3) = " Exit " LSInitial$(1) = "N" LSInitial$(2) = "D" LSInitial$(3) = "E" LSLong$(1) = "begin digitizing a New segment; add to end of file" LSLong$(2) = "Delete last segment in file " LSLong$(3) = "Exit to digitizing menu, to change files or quit " LSSLen% = LEN(LSShort$(1)) LSLLen% = LEN(LSLong$(1)) LSOK%(1) = True% LSOK%(3) = True% EWidth% = LEN(EndMark$) SCREEN BestMode%, , 0, 0 IF BestMode% > 2 THEN COLOR Foreground%, Background% CLS LOCATE 1, 34: PRINT "LINE SEGMENTS"; LOCATE 17, 1: FOR i% = 1 TO 80: PRINT CHR$(205); : NEXT i% LOCATE 18, 1: PRINT "Output file "; OutFileN$; " contains "; SegsDone%; " segments."; IF EmptyOut% THEN SegsDone% = 0 LSOK%(2) = FALSE% LSHot% = 1 Points% = 0 ELSE LSOK%(2) = True% END IF IF NOT EmptyOut% THEN LOCATE 19, 1: PRINT "Title lines (if any) of last segment were:"; FOR i% = 1 TO Titles% LOCATE 19 + i%, 1: FOR j% = 1 TO 80: PRINT CHR$(95); : NEXT j% LOCATE 19 + i%, 1: PRINT TitleMark$; FirstFive$(i%); NEXT i% LOCATE 25, 30: PRINT "Points in segment = "; Points%; END IF CALL GSETMENU(16, LSNumber%, LSShort$(), LSInitial$(), LSLong$(), LSSLen%, LSLLen%, LSOK%(), LSHot%) CALL GRUNMENU(16, LSNumber%, LSShort$(), LSInitial$(), LSLong$(), LSSLen%, LSLLen%, LSOK%(), LSHot%) IF LSHot% = 1 THEN CLOSE #3 OPEN OutFileN$ FOR APPEND AS #3 CALL Blanker(18, 25, 1, 79) SegsDone% = SegsDone% + 1 Points% = 0 LOCATE 18, 1: PRINT "Output file "; OutFileN$; " contains "; SegsDone%; " segments."; IF Titles% > 0 THEN Shoshone: LOCATE 19, 1: PRINT "Enter "; Titles%; "title lines for new segment. Use NO COMMAS except in quotes!"; FOR i% = 1 TO Titles% LOCATE 19 + i%, 1: FOR j% = 1 TO 80: PRINT CHR$(95); : NEXT j% LOCATE 19 + i%, 1: PRINT TitleMark$; : INPUT ; "", FirstFive$(i%) PRINT #3, TitleMark$; FirstFive$(i%) NEXT i% END IF IF EmptyOut% THEN LOCATE 25, 14: PRINT " DIGITISE SEGMENT, THEN PRESS ANY KEY TO END IT... "; END IF IF StopMode% = 0 THEN BytesNeeded% = RecordL% ELSE BytesNeeded% = YLeft% + YLen% - 1 B2% = XLeft% + XLen% - 1 IF B2% > BytesNeeded% THEN BytesNeeded% = B2% IF WasteSome% THEN IF CheckHere% > BytesNeeded% THEN BytesNeeded% = CheckHere% END IF END IF Mem1% = 0 Mem2% = 0 GMem1% = 0 MemNum% = 0 LastRec$ = "" Careful% = True% UseRow% = 24 StartCol% = 31 IF NOT LineOpen% THEN CALL OpenCOM(LineOpen%, PNHot%, Baud$, Parity$, DataBits$, StopBits$, StartCol%, UseRow%) END IF IF BestMode% > 2 THEN COLOR Foreground%, 0 SCREEN BestMode%, , HighPage%, HighPage% IF (HighPage% = 0) OR (FromTop%) THEN CLS IF SeeChosen% THEN CLOSE #4 OPEN SeeFileN$ FOR INPUT AS #4 SeeTitleNo% = 0 END IF END IF NeedFrame% = True% NeedSee% = SeeChosen% NeedPast% = (SegsDone% > 1) IF NeedPast% THEN TempName$ = OutPath$ + "\TEMP1742.DIG" CLOSE #3 SHELL "COPY " + OutFileN$ + " " + TempName$ + " > NUL" OPEN OutFileN$ FOR APPEND AS #3 OPEN TempName$ FOR INPUT AS #5 PastTitleNo% = 0 END IF Eject% = FALSE% '<<<<<<<<<<<< RESETTING INDENTATION <<<<<<<<<<<<<<<<<<<<<< ' MASTER: ' ' during (potentially) active (even 'stream'!) digitizing, ' priority is: (1) get records out of the #1 buffer to prevent overflow, and, ' if they are actually new data, store them in memory; ' (2) write from memory to disk file to prevent data loss; ' (3) check for keyboard activity, and finish disk file, return. ' (4) as lowest priority, draw the picture onscreen: ' (a) frame ' (b) digitised data for this segment ' (c) previous segments in this file, if any ' (d) background display file, if any ' NOTE: It is NEVER necessary to wait for display to catch up; data is safe! ' a$ = INKEY$ IF LOC(1) >= BytesNeeded% THEN 'read from #1 buffer GOSUB GetPair IF Recycling% THEN 'should we check for end-of-line? a$ = MID$(Rec$, Trigger%, 1) IF a$ = EjectMark$ THEN Eject% = True% END IF IF WasteSome% THEN B$ = MID$(Rec$, CheckHere%, 1) IF B$ = WasteMark$ THEN GOTO MASTER 'record marked for omission END IF IF Rec$ = LastRec$ THEN GOTO MASTER 'omit duplicates LastRec$ = Rec$ x! = VAL(MID$(Rec$, XLeft%, XLen%)) 'real format in case digitiser y! = VAL(MID$(Rec$, YLeft%, YLen%)) ' transmits any decimal points! IF PLAY(1) = 0 THEN PLAY "MB o5 C64" 'a little blip IF ScaleIt% THEN MX! = M11! * x! + M12! * y! + XAdd! 'change of coordinates MY! = M21! * x! + M22! * y! + YAdd! IF Careful% THEN 'first number may be screwy if stream mode was Careful% = FALSE% 'already on when program began listening! IF (MX! - (1.5 * MXLL! - .5 * MXLR!)) * (MX! - (1.5 * MXLR! - .5 * MXLL!)) > 0! THEN GOTO MASTER IF (MY! - (1.5 * MYLL! - .5 * MYUL!)) * (MY! - (1.5 * MYUL! - .5 * MYLL!)) > 0! THEN GOTO MASTER END IF ELSE IF Careful% THEN 'first number may be screwy if stream mode was Careful% = FALSE% 'already on when program began listening! IF (x! - (1.5 * XLL! - .5 * XUR!)) * (x! - (1.5 * XUR! - .5 * XLL!)) > 0! THEN GOTO MASTER IF (y! - (1.5 * YLL! - .5 * YUR!)) * (y! - (1.5 * YUR! - .5 * YLL!)) > 0! THEN GOTO MASTER END IF MX! = x! MY! = y! END IF MemNum% = MemNum% + 1 Mem2% = (Mem2% MOD N4K%) + 1 Memory!(1, Mem2%) = MX! Memory!(2, Mem2%) = MY! IF MemNum% = N4K% THEN 'about to overflow; take drastic action! IF LineOpen% THEN 'it almost certainly is! CLOSE #1 LineOpen% = FALSE% END IF BEEP RemedyScreen: 'covers case where program cannot keep up with digitiser. SCREEN 0, , 0, 0 CLS LOCATE 5, 25: PRINT "POINTS ARE COMING IN TOO FAST;"; LOCATE 6, 25: PRINT "MEMORY BUFFER ABOUT TO OVERFLOW!"; LOCATE 8, 1: PRINT "Possible corrective actions:"; LOCATE 9, 1: PRINT "(1) Reduce baud rate of digitiser (and in SetUp menu)."; LOCATE 10, 1: PRINT "(2) Release button and/or stop cursor about every 20 seconds,"; LOCATE 11, 4: PRINT "so that program can catch up. (It is caught up when the hard-disk "; LOCATE 12, 4: PRINT "light goes out, even if the screen drawing is incomplete.)"; LOCATE 13, 1: PRINT "(3) Switch from 'stream' mode to single-point mode."; LOCATE 14, 1: PRINT "(4) Let these interrupts keep happening, and then patch the separate"; LOCATE 15, 4: PRINT " line segments in the output file together by editing out the intervening"; LOCATE 16, 4: PRINT "title lines and end-of-segment markers that are artificial."; LOCATE 24, 10: PRINT "When you press any key, your work until this point will be saved, even"; LOCATE 25, 14: PRINT "though the segment will be shorter than you intended."; DoneRd: C$ = INKEY$: IF LEN(C$) = 0 THEN GOTO DoneRd SCREEN BestMode%: CLS GOTO MASTER END IF ELSEIF MemNum% > 0 THEN 'empty memory to disk file Mem1% = (Mem1% MOD N4K%) + 1 PRINT #3, " "; PRINT #3, USING "+#.#####^^^^"; Memory!(1, Mem1%); PRINT #3, ","; PRINT #3, USING "+#.#####^^^^"; Memory!(2, Mem1%) MemNum% = MemNum% - 1 Points% = Points% + 1 ELSEIF Eject% THEN 'finish this segment, and perhaps leap into another Eject% = FALSE% IF Titles% THEN GOTO Kluge 'same effect as a key-press PRINT #3, EndMark$ CLOSE #3 CLOSE #5 IF LEN(DIR$(TempName$)) THEN KILL TempName$ FromTop% = FALSE% NeedPast% = True% SegsDone% = SegsDone% + 1 Points% = 0 Mem1% = 0 Mem2% = 0 GMem1% = 0 MemNum% = 0 TempName$ = OutPath$ + "\TEMP1742.DIG" SHELL "COPY " + OutFileN$ + " " + TempName$ + " > NUL" OPEN OutFileN$ FOR APPEND AS #3 OPEN TempName$ FOR INPUT AS #5 GOTO MASTER 'tigher loop than section below; skips screen 1 ELSEIF LEN(a$) > 0 THEN 'tidy up, and close disk file, return to menu Kluge: IF LineOpen% THEN CLOSE #1 LineOpen% = FALSE% END IF PRINT #3, EndMark$ CLOSE #3 CLOSE #5 IF LEN(DIR$(TempName$)) THEN KILL TempName$ EmptyOut% = FALSE% FromTop% = FALSE% GOTO LineSegments ELSE 'work on drafting graphics (lowest priority) IF NeedFrame% THEN LINE (C1%, R1%)-(C2%, R2%), , B NeedFrame% = FALSE% ELSEIF Mem2% <> GMem1% THEN 'more points in memory than yet drawn GMem1% = (GMem1% MOD N4K%) + 1 IF GMem1% = 1 THEN X1! = GXAdd! + GXScale! * Memory!(1, 1) IF ABS(X1!) > 32000! THEN GOTO MASTER Y1! = GYAdd! + GYScale! * Memory!(2, 1) IF ABS(Y1!) > 32000! THEN GOTO MASTER X1% = CINT(X1!) Y1% = CINT(Y1!) PSET (X1%, Y1%) ELSE X1! = GXAdd! + GXScale! * Memory!(1, GMem1% - 1) IF ABS(X1!) > 32000! THEN GOTO MASTER Y1! = GYAdd! + GYScale! * Memory!(2, GMem1% - 1) IF ABS(Y1!) > 32000! THEN GOTO MASTER X2! = GXAdd! + GXScale! * Memory!(1, GMem1%) IF ABS(X2!) > 32000! THEN GOTO MASTER Y2! = GYAdd! + GYScale! * Memory!(2, GMem1%) IF ABS(Y2!) > 32000! THEN GOTO MASTER X1% = CINT(X1!) X2% = CINT(X2!) Y1% = CINT(Y1!) Y2% = CINT(Y2!) LINE (X1%, Y1%)-(X2%, Y2%) END IF ELSEIF NeedPast% THEN IF EOF(5) THEN NeedPast% = FALSE% ELSE LINE INPUT #5, B$ IF LEFT$(B$, EWidth%) = EndMark$ THEN PastTitleNo% = 0 ELSE PastTitleNo% = PastTitleNo% + 1 Datum% = PastTitleNo% - Titles% IF Datum% <= 0 THEN ELSEIF Datum% = 1 THEN XPast1! = VAL(MID$(B$, 2, 12)) YPast1! = VAL(MID$(B$, 15, 12)) XPast1! = GXAdd! + GXScale! * XPast1! YPast1! = GYAdd! + GYScale! * YPast1! IF ABS(XPast1!) < 32000! THEN BadPast1% = FALSE% XPast1% = CINT(XPast1!) ELSE BadPast1% = True% END IF IF ABS(YPast1!) < 32000! THEN YPast1% = CINT(YPast1!) ELSE BadPast1% = True% END IF IF (NOT BadPast1%) THEN IF ColorIt% THEN PSET (XPast1%, YPast1%), 14 ELSE PSET (XPast1%, YPast1%) END IF END IF ELSE XPast2! = VAL(MID$(B$, 2, 12)) YPast2! = VAL(MID$(B$, 15, 12)) XPast2! = GXAdd! + GXScale! * XPast2! YPast2! = GYAdd! + GYScale! * YPast2! IF ABS(XPast2!) < 32000! THEN BadPast2% = FALSE% XPast2% = CINT(XPast2!) ELSE BadPast2% = True% END IF IF ABS(YPast2!) < 32000! THEN YPast2% = CINT(YPast2!) ELSE BadPast2% = True% END IF IF NOT (BadPast1% AND BadPast2%) THEN IF ColorIt% THEN LINE (XPast1%, YPast1%)-(XPast2%, YPast2%), 14 'yellow ELSE LINE (XPast1%, YPast1%)-(XPast2%, YPast2%) END IF END IF XPast1% = XPast2% YPast1% = YPast2% BadPast1% = BadPast2% END IF END IF END IF ELSEIF NeedSee% THEN IF EOF(4) THEN NeedSee% = FALSE% ELSE LINE INPUT #4, B$ IF LEFT$(B$, SeeEWidth%) = SeeEndMark$ THEN SeeTitleNo% = 0 ELSE SeeTitleNo% = SeeTitleNo% + 1 Datum% = SeeTitleNo% - SeeTitles% IF Datum% <= 0 THEN ELSEIF Datum% = 1 THEN XSee1! = VAL(MID$(B$, 2, 12)) YSee1! = VAL(MID$(B$, 15, 12)) XSee1! = GXAdd! + GXScale! * XSee1! YSee1! = GYAdd! + GYScale! * YSee1! IF ABS(XSee1!) < 32000! THEN BadSee1% = FALSE% XSee1% = CINT(XSee1!) ELSE BadSee1% = True% END IF IF ABS(YSee1!) < 32000! THEN YSee1% = CINT(YSee1!) ELSE BadSee1% = True% END IF ELSE XSee2! = VAL(MID$(B$, 2, 12)) YSee2! = VAL(MID$(B$, 15, 12)) XSee2! = GXAdd! + GXScale! * XSee2! YSee2! = GYAdd! + GYScale! * YSee2! IF ABS(XSee2!) < 32000! THEN BadSee2% = FALSE% XSee2% = CINT(XSee2!) ELSE BadSee2% = True% END IF IF ABS(YSee2!) < 32000! THEN YSee2% = CINT(YSee2!) ELSE BadSee2% = True% END IF IF NOT (BadSee1% AND BadSee2%) THEN IF ColorIt% THEN LINE (XSee1%, YSee1%)-(XSee2%, YSee2%), 2 'green ELSE LINE (XSee1%, YSee1%)-(XSee2%, YSee2%) END IF END IF XSee1% = XSee2% YSee1% = YSee2% BadSee1% = BadSee2% END IF END IF END IF END IF END IF GOTO MASTER 'indefinate loop, until exit by keyboard activity '>>>>>>>>>>>>> end of indentation offset >>>>>>>>>>>>>>>>> ELSEIF LSHot% = 2 THEN 'delete last segment in file SegsDone% = SegsDone% - 1 EmptyOut% = (SegsDone% = 0) FromTop% = True% IF EmptyOut% THEN CLOSE #3 KILL OutFileN$ ELSE TempName$ = OutPath$ + "\TEMP8106.DIG" CLOSE #3 CLOSE #5 NAME OutFileN$ AS TempName$ OPEN TempName$ FOR INPUT AS #5 OPEN OutFileN$ FOR OUTPUT AS #3 Count% = 0 EWidth% = LEN(EndMark$) TitleNo% = 0 DO UNTIL EOF(5) LINE INPUT #5, Rec$ PRINT #3, Rec$ TitleNo% = TitleNo% + 1 IF TitleNo% <= Titles% THEN FirstFive$(TitleNo%) = Rec$ IF LEFT$(Rec$, EWidth%) = EndMark$ THEN Count% = Count% + 1 Points% = TitleNo% - 1 - Titles% TitleNo% = 0 END IF IF Count% = SegsDone% THEN EXIT DO LOOP CLOSE #3 CLOSE #5 KILL TempName$ GOTO LineSegments END IF NeedPast% = True% GOTO LineSegments ELSEIF LSHot% = 3 THEN CLOSE #4 GOTO Digitise END IF ELSEIF DIHot% = 7 THEN GOTO MainMenu END IF ' '------------------------------------------------------------------ ' Termination: SHELL "cls" END ' '----------------------------------------------------------------- ' GetPair: 'most important rountine in program: 'gets a complete record (Rec$) from the digitiser (COMn input buffer) 'Written as a subroutine for speed. DIM Bite AS STRING * 1 BadTries% = 0 GetAnother: Rec$ = "" FOR kPlace% = 1 TO 60 'this loop should never be completed! DO WHILE EOF(1): LOOP 'wait for data to appear Bite = INPUT$(1, #1) Rec$ = Rec$ + Bite 'check whether a complete record has been read IF StopMode% THEN IF kPlace% >= BytesNeeded% THEN IF Bite = StopByte$ THEN RETURN END IF ELSE IF kPlace% = BytesNeeded% THEN RETURN END IF 'if record is still incomplete, make sure it isn't over! IF Bite = StopByte$ THEN BadTries% = BadTries% + 1 IF BadTries% > 2 THEN CLS BEEP LOCATE 6, 10 PRINT "Communications error:" LOCATE 8, 10 PRINT "Three times in a row, the end-of-record byte was read" LOCATE 9, 10 PRINT "before sufficient data bytes were found." LOCATE 11, 10 PRINT "Go to Test and then adjust Manual/Format." LOCATE 20, 50 PRINT "Press any key ..." DO UNTIL INKEY$ <> "": LOOP IF LineOpen% THEN CLOSE #1 LineOpen% = FALSE% END IF PRINT #3, EndMark$ CLOSE #3 CLOSE #5 IF LEN(DIR$(TempName$)) THEN KILL TempName$ SUHot% = 4 GOTO SetUp ELSE GOTO GetAnother END IF END IF NEXT kPlace% CLS BEEP LOCATE 6, 10 PRINT "Communications error:" LOCATE 8, 10 PRINT "Read 60 bytes from the COM input buffer without satisfying the " LOCATE 9, 10 PRINT "criterion for end-of-record." LOCATE 11, 10 PRINT "Go to Test and then adjust Manual/Format." LOCATE 20, 50 PRINT "Press any key ..." DO UNTIL INKEY$ <> "": LOOP IF LineOpen% THEN CLOSE #1 LineOpen% = FALSE% END IF PRINT #3, EndMark$ CLOSE #3 CLOSE #5 IF LEN(DIR$(TempName$)) THEN KILL TempName$ SUHot% = 4 GOTO SetUp ' '----------------------------------------------------------------- ' ClearBuffer: n% = LOC(1) IF n% THEN IF StopMode% THEN ELSE n% = RecordL% * (n% \ RecordL%) 'attempt to preserve alignment! END IF a$ = INPUT$(n%, #1) END IF RETURN ' '----------------------------------------------------------------- ' 'VARIOUS ERROR HANDLERS ' AnyError: 'generic error handler; most versatile one. BEEP COLOR Foreground%, Background% CLS LOCATE 2, 30 PRINT "ERROR INTERRUPT"; LOCATE 4, 1 ErrorCode% = ERDEV AND &HF BadBoy$ = ERDEV$ IF BadBoy$ = "" THEN BadBoy$ = "[null]" PRINT "Device "; BadBoy$; " reports device Error Number of "; ErrorCode%; LOCATE 5, 3 IF ErrorCode% = 1 THEN PRINT "= Unknown Unit"; ELSEIF ErrorCode% = 2 THEN PRINT "= Device not ready"; ELSEIF ErrorCode% = 4 THEN PRINT "= Cyclical Redundancy Check error"; ELSEIF ErrorCode% = 11 THEN PRINT "= Read fault"; ELSEIF ErrorCode% = 12 THEN PRINT "= General Failure"; END IF LOCATE 6, 1 PRINT "or else there was a logical error with code number of "; ERR; LOCATE 7, 3 IF ERR = 24 THEN PRINT "= Device timeout (no signal received)"; LOCATE 12, 1 PRINT "If logical error is 24 (Timeout) then the digitiser is probably not"; LOCATE 13, 1 PRINT "connected to the serial port that you are trying to use."; ELSEIF ERR = 25 THEN PRINT "= Device fault"; ELSEIF ERR = 52 THEN PRINT "= Bad file name or number"; ELSEIF ERR = 53 THEN PRINT "= File not found"; ELSEIF ERR = 54 THEN PRINT "= Bad file mode"; ELSEIF ERR = 55 THEN PRINT "= File already open"; ELSEIF ERR = 57 THEN PRINT "= Device I/O error"; LOCATE 12, 1 PRINT "If logical error is 57 (Device I/O error) then the connection may have broken,"; LOCATE 13, 1 PRINT "or the fault may be in the baud rate, parity, or number of data or stop bits."; ELSEIF ERR = 58 THEN PRINT "= File already exists"; ELSEIF ERR = 59 THEN PRINT "= Bad record length"; ELSEIF ERR = 61 THEN PRINT "= Disk Full"; ELSEIF ERR = 62 THEN PRINT "= Input past end of file"; ELSEIF ERR = 63 THEN PRINT "= Bad record number"; ELSEIF ERR = 64 THEN PRINT "= Bad file name"; ELSEIF ERR = 68 THEN PRINT "= Device unavailable"; ELSEIF ERR = 69 THEN PRINT "= Communication buffer overflow" ELSEIF ERR = 70 THEN PRINT "= Permission denied"; ELSEIF ERR = 71 THEN PRINT "= Disk not ready"; ELSEIF ERR = 72 THEN PRINT "= Disk-media error"; ELSEIF ERR = 75 THEN PRINT "= Path/File access error" ELSEIF ERR = 76 THEN PRINT "= Path not found"; ELSE PRINT "(consult QuickBasic-4 manual, Appendix G)" END IF COLOR Background%, Foreground% LOCATE 23, 8 PRINT "Press any key to return to the program, at statement after error."; LOCATE 24, 4 PRINT "(You may have to do this several times, but you can usually regain control.)"; D99: a$ = INKEY$: IF LEN(a$) = 0 THEN GOTO D99 COLOR Foreground%, Background% RESUME NEXT '-----------------------------------------------------------------