$SOURCE $IPRINT_OFF ' Turn off the BCX "\" to "\\" translations '************************************************************************* ' GLOBAL VARIABLES '************************************************************************* GLOBAL CERR$ GLOBAL Z$ GLOBAL tnum GLOBAL ClineNbr Global BasErrFile$ GLOBAL Version$ GLOBAL Cmd$ GLOBAL DisMsgBox GLOBAL szBasfile$ GLOBAL szCfile$ GLOBAL Src$ GLOBAL FoundSourceOp GLOBAL msgstr$ GLOBAL msgstr1$ GLOBAL msgstr2$ GLOBAL basiclinenumber$ GLOBAL ErrFile$ GLOBAL bclineint GLOBAL LSTRT GLOBAL LEND GLOBAL lcerr GLOBAL A GLOBAL stsrstr$ Global LNR$ GLOBAL INTLNR GLOBAL findlcount GLOBAL foundline Global linestring$ GLOBAL ErrFile$ GLOBAL Inc$ '*************************************************************************** Version$ = "1.96" ' check.exe Version number IF COMMAND$ = "" THEN ? "BCX-DEBUGGER CMD: Command Line Debugger for BCX. Version "; ? Version$ ? " Usage: BCX infile to debug [.bas]" END END IF '************************ [ Announce Program ] *************************** '? "BCX-DEBUGGER CMD: Command Line Debugger for BCX. Version "; Version$ '? "" '************************************************************************* IF INSTR(COMMAND$,".") THEN Cmd$ = COMMAND$(1) ' Allow ANY extension ELSE Cmd$ = UCASE$(EXTRACT$(COMMAND$,".")) & ".BAS" End If szBasfile$ = Cmd$ Cmd$ = UCASE$(EXTRACT$(COMMAND$,".")) & ".C" szCfile$ = Cmd$ Cmd$ = UCASE$(EXTRACT$(COMMAND$,".")) & ".ERR" BasErrFile$ = Cmd$ ErrFile$="lcc.err" if lof("lcc.err")<>-1 then kill "lcc.err" if lof("bcx.err")<>-1 then kill "bcx.err" if lof(BasErrFile$)<>-1 then kill BasErrFile$ '************************************************************************* ' Check $SOURCE is in Basic File OPEN szBasfile$ FOR INPUT AS SourceFile WHILE NOT EOF(SourceFile) LINE INPUT SourceFile,Src$ If instr(UCase$(Trim$(Src$)),"$SOURCE")=1 Then FoundSourceOp = True Exit Do End If loop close SourceFile If FoundSourceOp<>True then msgstr1$="The BCX translator command $SOURCE was not found." msgstr2$="Insert $SOURCE in to your basic source file, and run again." msgstr$=msgstr1$ & chr$(13) & msgstr2$ ? msgstr1$ ? msgstr2$ if DisMsgBox<>true then msgbox msgstr$,"$SOURCE missing from file" end if END end if '************************************************************************* ' Run BCX and tell it to output an error file Cmd$="bc.exe " & szBasfile$ & " -e" shell Cmd$ '************************************************************************* ' Look for Error in BCX Error File if lof(BasErrFile$)=0 Then Goto PassCFile if lof(BasErrFile$)=-1 Then Goto PassCFile OPEN BasErrFile$ FOR INPUT AS SourceFile If EOF(SourceFile) THEN GoTo PassCFile LINE INPUT SourceFile,Src$ close SourceFile basiclinenumber$ = Mid$(Src$, InStrRev(Src$, " ")+1, Len(Src$) - InStrRev(Src$, " ") + 1) if DisMsgBox<>true then msgstr1$="Basic Error: " & Src$ & chr$(13) &"Click OK to goto line: " & basiclinenumber$ & " in JFE" msgbox msgstr1$,"Basic Error!" End If '************************************************************************* ' If error found highlight line in JFE bclineint=val(trim$(basiclinenumber$)) doevents doevents ' Activaet the JFE Window ActivateBcWindow() doevents doevents doevents ' Goto and highlight the line in JFE GOTOLINE(bclineint) doevents doevents doevents doevents ' Clean up and end program kill BasErrFile$ if lof("szCfile$")=0 Then kill szCfile$ End If if lof("szCfile$")=-1 Then kill szCfile$ End If End '************************************************************************* PassCFile: ' Compile Program with LCC and output an error file Cmd$ = "lcc.exe " & szCfile$ & " -O -errout=lcc.err" shell Cmd$ if lof(ErrFile$)=0 Then Goto NoErrors end if if lof(ErrFile$)=-1 Then Goto NoErrors end if 'Open the .ERR file Open ErrFile$ For Input As Fp1 ' Opens a text file for read only ClineNbr=0 DLC: findlcount=0 If EOF(Fp1) Then If lcerr > 0 Then Close Fp1 GoTo EsubErr Else Close Fp1 GoTo NoErrors End If End If dim a '*************************************************************************** 'Start to pass error file one error at a time INTLNR=0 While Not EOF(Fp1) ' While we have not reached the End Of File ClineNbr = ClineNbr + 1 LINE INPUT Fp1, Inc$ ' Read a line from the file Z$=Inc$ LNR$=mid$(Z$,LEN(LEFT$(Cmd$, INSTRREV(Cmd$,".")))+7,5) IF lcase$(left$(Z$,5))="error" then stsrstr$="error:" & szCfile$ FOR A=len(stsrstr$) to LEN(Z$) IF VAL(MID$(Z$,A,1))>0 THEN LSTRT=A EXIT FOR END IF NEXT A FOR A=LSTRT to LEN(Z$) IF MID$(Z$,A,1)=" " THEN LEND=A-LSTRT EXIT FOR END IF NEXT A CERR$=MID$(Z$,LSTRT+LEND,LEN(Z$)) LNR$=MID$(Z$,LSTRT,LEND) INTLNR=Val(Trim$(LNR$)) EXIT Do End If loop '*************************************************************************** 'If no errors found in lcc.err If INTLNR = 0 Then Close Fp1 GoTo NoErrors End If findlcount = 0 foundline = 0 if lof(szCfile$)=0 Then Goto EsubErr 'Look for a Remarked Line with a Basic Line Number in the C File While foundline = 0 Open szCfile$ For Input As Fp4 ' Have looked 17 lines about line with error in c file, and cannot find a basic line number ' So Goto DLC and look for next C Error If findlcount > 17 Then lcerr = lcerr + 1: Close Fp4: GoTo DLC End If '*************************************************************************** 'Go down to line in C File, where Err file reports error - any lines we previously ' did not find a BCX $SOURCE line number For a = 0 To INTLNR - findlcount - 1 If EOF(Fp4) Then lcerr = lcerr + 1: Close Fp4 Exit Do GoTo DLC End If Line Input Fp4, linestring$ Next '*************************************************************************** Close Fp4 linestring$ = Trim$(linestring$) ' If we found the line flag foundline=1, and display the error If LEFT$(linestring$,4) = "// [" Then tnum=InStr(linestring$, "]") basiclinenumber$ = Mid$(linestring$, 5, InStr(linestring$, "]")-5) msgstr1$="C Error: " & CERR$ & " In Basic Line " & basiclinenumber$ & chr$(13) &"Click OK to goto line: " & basiclinenumber$ & " in JFE" msgbox msgstr1$,"C ERROR" foundline = 1 End If findlcount = findlcount + 1 msgstr1$=str$(findlcount) Loop '*************************************************************************** ' Clean up close Fp1 IF LOF(ErrFile$)<>0 then Kill ErrFile$ ' Kill the ERR File IF LOF(ErrFile$)<>0 then Kill szCfile$ ' Kill the C File bclineint=val(trim$(basiclinenumber$)) '*************************************************************************** doevents ' Activate the JFE Editor Window ActivateBcWindow() doevents doevents doevents ' Jump to and highlight the Line in JFE. GOTOLINE(bclineint) doevents doevents doevents End '*************************************************************************** NoErrors: 'close Fp4 'close Fp1 IF LOF(ErrFile$)<>0 then Kill ErrFile$ ' Kill the ERR File IF LOF(ErrFile$)<>0 then Kill szCfile$ ' Kill the C File msgbox "No Errors Found", "No Errors Found" END '*************************************************************************** EsubErr: 'close Fp4 'close Fp1 IF LOF(ErrFile$)<>0 then Kill ErrFile$ ' Kill the ERR File IF LOF(ErrFile$)<>0 then Kill szCfile$ ' Kill the C File msgstr1$="There was an unknown error in your File" & chr$(13) & "Check you are using the latest version of BCX" & chr$(13) & "and that you are degugging a BCX Basic File" msgbox msgstr1$,"Unkown Error" END '*************************************************************************** SUB GOTOLINE (LNBR) DIM KEYSEND DIM A doevents doevents keybd_event(VK_CONTROL, 0, 0, 0) doevents doevents doevents doevents keybd_event(71, 0, 0, 0) doevents doevents doevents doevents doevents keybd_event(71, 0, KEYEVENTF_KEYUP, 0) doevents doevents doevents keybd_event(VK_CONTROL, 0, KEYEVENTF_KEYUP, 0) doevents doevents doevents doevents FOR A=1 to LEN(STR$(LNBR)) KEYSEND=48+VAL(MID$(STR$(LNBR),A,1)) keybd_event(KEYSEND, 0, 0, 0) doevents doevents doevents doevents doevents doevents keybd_event(KEYSEND, 0, KEYEVENTF_KEYUP, 0) doevents doevents doevents doevents doevents doevents NEXT A doevents doevents keybd_event(VK_RETURN, 0, 0, 0) ' ENTER PRESS doevents doevents doevents doevents doevents doevents keybd_event(VK_RETURN, 0, KEYEVENTF_KEYUP, 0) ' ENTER RELEASE doevents doevents doevents doevents doevents doevents keybd_event(VK_SHIFT, 0, 0, 0) doevents doevents doevents doevents keybd_event(VK_END, 0, 0, 0) doevents doevents doevents doevents doevents doevents keybd_event(VK_END, 0, KEYEVENTF_KEYUP, 0) doevents doevents doevents doevents doevents doevents keybd_event(VK_SHIFT, 0, KEYEVENTF_KEYUP, 0) doevents doevents doevents doevents doevents doevents END SUB '*************************************************************************** '*************************************************************************** FUNCTION ActivateBcWindow DIM ALOOP DIM Z$ DIM CurThread, NewThread DIM Buffer$ DIM hWnd AS HANDLE DIM hWnd2 AS HANDLE DIM hWnd3 AS HANDLE CurThread = GetCurrentThreadId() hWnd3 = GetForegroundWindow() hWnd = GetWindow(hWnd3,GW_HWNDFIRST) Z$="File Editor" FOR ALOOP=0 TO 2100 GetWindowText (hWnd,Buffer$, 256) IF hWnd<> hWnd3 THEN IF Buffer$<>"" THEN IF INSTR(LCASE$(Buffer$), LCASE$(Z$)) THEN ' App Window found NewThread=GetWindowThreadProcessId(hWnd,NULL) AttachThreadInput(CurThread,NewThread,TRUE) hWnd2 = SetActiveWindow(hWnd) FUNCTION = TRUE END IF END IF END IF hWnd = GetNextWindow(hWnd,GW_HWNDNEXT) NEXT ALOOP FUNCTION = FALSE ' App Window not found END FUNCTION '***************************************************************************