Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.
;**************************************************************************************************** ; Program Title: Debug Wizard (DW) v1.0 * ; * ; Author Steffen Fraas sfraas@zoo.co.uk * ; * ; Date: April 20 2004 * ; * ; Purpose Script to enable graphical display of order of statement execution. * * ; * ; Details This DebugWizard can be used to simplify debugging of a script. Whilst viewing * ; the script in WinBatch Studio the debugtrace file is used to highlight the * ; executed statement via the bookmark symbol. Using the bookmark symbol requires * * ; this utility to be run in WinBatch Studio debug mode; i.e. right click select * ; DebugWizard. See installation notes. * ; * ; Random and sequential access to debugtrace file provided by the Gigfile UDFs. * ; * ; * ; Step by step Open script X in WinBatch Studio. * ; example Surround troublesome code with DebugTrace(@on,tracefile) and * ; DebugTrace(@off,tracefile) respectively. * ; Right click and select DebugWizard. (Runs in WinBatch Studio Debug mode only - * ; no CTRL F7) * ; Click on 'Create/select debugtrace script'. * ; Click on 'Create a copy for use as a debugtrace script from the current open * ; file'. * ; After a short period a modified script X with read-only attribute will appear in* ; WinBatch Studio. * ; Press CTRL & F7 keys for the new script X to run and create debugtrace file * ; tracefile. * ; At end of run right click and select DebugWizard again. * ; Click on 'Create/select debugtrace script' and highlight 'Copy_of_script X' * * ; Highlight the Copy_of... entry and click 'Select (highlight) a debugtrace script* ; for re/loading into WinBatch Studio'. * * ; Select the debugtrace file created by this special READONLY script. Click OK in * ; panel 3. (See Panels below) * ; Click Resume Trace and each executed line in the script will now be shown via * ; the blue bookmark. * ; Press SHIFT *and* CTRL to display the control panel. * ; * ; REMEMBER!!! Original script X still contains the DebugTrace statements. Delete before saving* ; if required. * ; * ; * ; Panels & * ; Information Each panel is numbered. The number is always in the bottom right-hand corner. * * ; * ; Panel 1 DebugWizard's welcome panel; appears after right clicking inside WinBatch Studio* ; and selecting DebugWizard. * ; * ; Panel 2 'DebugWizard - debugtrace script selector' * ; * ; Button: 'Create a copy for use as a debugtrace script from the current open file' * ; * ; Adding a DebugTrace command to a script will cause a script to log any executed * ; statements (and the results) to the debugtrace file. To enable a logged * ; statement to be associated with the corresponding line in a script requires that* ; each line in a script is numbered. * ; This button will create a copy of the currently open file in WinBatch Studio, * ; add a line number to each line of the script as a special comment, and open this* ; file as a READONLY file in WinBatch Studio. The status bar at the bottom of the * ; screen will display the progess of this operation. After the script has been * ; 'converted' it will be opened as the current file in WinBatch Studio in READONLY* ; mode. DebugWizard adds an entry to the debugwizard.ini file for this converted * ; script and exits. * ; If this converted script is now run it will generate a debugtrace file where * ; every executed statement contains a line number at the end of the statement. * ; This line number is later used to show which line in a script was executed. * ; * ; Botton: 'Create a copy for use as a debugtrace script from a file' * ; * ; This button does the same as the button above but using a user-supplied file * ; instead. * ; * ; Button: 'Select (highlight) a debugtrace script for re/loading into WinBatch Studio' ; * ; From the displayed entries highlight a previously converted script and press * ; this button to load and make it the current file in WinBatch Studio. Remember, * ; this converted script was used to generate a debugtrace file. The following file* ; panel will allow this debugtrace file to be selected. Again, DebugWizard will * ; also save this file name in debugwizard.ini for next time round. * ; * ; Panel 3 'DebugWizard - File Analysis Parameters' * ; * ; This panel is used - after selecting a debugtrace file for a converted script -* ; to define the indexation parameters (IP) for this debugtrace file. Again, this * ; data is saved by DebugWizard for next time round. * ; The IPs are used to virtually split a debugtrace file for fast direct access to* ; a line by using its line number in the debugtrace file. In most cases using * ; the Automatic option will provide suitable IPs. The automatic IPs are based on * ; the following critera: * * ; buffer size for files 1GB or more - file size/1000 * ; buffer size for files 1GB or less - file size/100 - minimum 10,000 * ; secondary size is buffer size / 1000 - minimum 1000 * ; NOTE: maximum secondary size for pre 2004B WinBatch versions is 65535. * ; Check Display graph to monitor the indexation progress. Requires extender * ; wwsop34i.DLL. * ; Check 2GB+file if processing a file greater than 2,147,483,647 bytes; requires * ; extender WWHUG34I.DLL. * ; * ; * ; Panel 4 'DebugWizard - control panel' * ; * ; Button: * ; * ; Resume Trace - resumes display from line number in the debugtrace file as shown* ; in the Resume from trace line # field. * ; * ; Resume Script - resumes display from statement number as shown in the Resume * ; from script line # field. * ; * ; Resume where... various conditional resumption options * ; Example: radio check variable name and enter vad, set =# to 359, and radio * ; check trace line #. Where possible use the case sensitive option.* ; It can improve searches by a factor of up to 10! * ; * ; This combination would resume tracing after searching for variable name * ; 'vad' being set to 359, starting from line as currently shown in the * ; Resume from trace line # field. * ; * ; * ; Display interval - various display interval options * ; * ; Tracelog - Navigation * ; * ; The following keyboard keys can be used to influence the replay action. * ; Left arrow-up: jump back the number of lines shown - 10 to 32767 times * ; multiplier. * ; Right arrow-down: forward number of lines shown - 10 to 32767 times * ; multiplier. * ; Up arrow - move up log * ; Down arrow - freeze display * ; CTRL - present panel 4 * ; * ; Check Exclusive(@On) for faster display * ; * ; Panel 5 'DebugWizard - add line numbers to script' * ; * ; During the script conversion process the addition of the line number can cause * ; WinBatch line number limit of 255 characters to be exceeded. This panel can be * ; used to trim a line by deleted the number of specified blank spaces. * ; * * ; * ; * ; Installation Copy this file into DirHome() - usually ...\winbatch\system\ * ; notes Copy and paste the last two lines of this script into wsp-user.mnu as follows: * * ; Open a file in WinBatch Studio * ; Right-click and click on More.../How do I?.../Customize this * ; Menu... * ; Go to end of wsp-user.mnu and paste. * ; Save, exit and restart WinBatch Studio. * ; * ; History April 20,2004 v1.0 released * ; * ;**************************************************************************************************** ; Script for menu use checked by SyntaxChecker v2004Bc * ;**************************************************************************************************** t@wvers="v1.0" Terminate(!(RtStatus()==10),"DebugWizard",StrCat("DebugWizard only available in WinBatch Studio Debug mode - no CTRL F7",@CrLf,"See Step by step example, and installation notes, in write-up")) Intcontrol(72,2,0,0,0) ; Setup cancel environment. GoSub INIT ; Line 788 While @True t@wcancel=0 t@wformat=`WWWDLGED,6.1` t@wcaption=`DebugWizard %t@wvers%` t@wx=9999 t@wy=9999 t@wwidth=147 t@wheight=080 t@wnumcontrols=003 t@wprocedure=`DEFAULT` t@wfont=`DEFAULT` t@wtextcolor=`DEFAULT` t@wbackground=`DEFAULT,"230|255|255"` t@wconfig=0 t@w001=`017,023,110,012,PUSHBUTTON,DEFAULT,"&Create/select debugtrace script",1,1,32,"MS Sans Serif|5632|70|34","128|128|0","220|226|205"` t@w002=`057,052,030,012,PUSHBUTTON,DEFAULT,"&Exit",0,3,DEFAULT,"MS Sans Serif|5632|70|34","128|128|0","220|226|205"` t@w003=`001,068,146,011,VARYTEXT,t@werror,"",DEFAULT,4,DEFAULT,"Microsoft Sans Serif|5325|40|34","255|0|0",DEFAULT` dw_Panel_Placement("t@w",1) ; Line 795 t@wbtn=Dialog("t@W") t@werror="" If t@wcancel || w@bbtn==4 Then Break GoSub CREATEDEBUG ; Line 201 If !t@wcancel && (c@ttracewbtn==2 || c@ttracewbtn==5) ; All set up for a debug run? Display(4,"DebugWizard","All ready to create debugtrace from READONLY copy") Break EndIf ; !t@wcancel && (c@ttracewbtn==2 || c@ttracewbtn==5). If !t@wcancel && c@ttracewbtn==4 Then GoSub ANALYZEDEBUG ; Play back debugtrace file. ; Line 385 EndWhile ; @True. If IsDefined(w@barray) Then If w@barray[12,0] Then If VarType(w@barray[12,0])==256 Then BinaryFree(w@barray[12,0]) ; Free buffer if allocated. DropWild("t@w*") ; Clean up. DropWild("c@t*") ; Clean up. DropWild("w@b*") ; Clean up. Exit :CANCEL ; From ? Intcontrol(72,2,0,0,0) ; Re-establish cancel environment. t@wcancel=1 Return :CREATEDEBUG ; From 185 c@tenv=FileNameLong(Environment("Tmp")) c@twinbatch=StrCat('"',DirHome(),"WinBatch Studio.exe",'"') c@ttwerror="" While @True c@tfile="" t@wcancel=0 GoSub COPIES ; Line 367 c@ttracewformat=`WWWDLGED,6.1` c@ttracewcaption=`DebugWizard - debugtrace script selector` c@ttracewx=9999 c@ttracewy=9999 c@ttracewwidth=224 c@ttracewheight=130 c@ttracewnumcontrols=009 c@ttracewprocedure=`DEFAULT` c@ttracewfont=`DEFAULT` c@ttracewtextcolor=`DEFAULT` c@ttracewbackground=`DEFAULT,"230|255|255"` c@ttracewconfig=0 c@ttracew001=`158,098,040,011,PUSHBUTTON,DEFAULT,"&OK",1,1,32,"MS Sans Serif|5632|70|34","128|128|0","220|226|205"` c@ttracew002=`092,098,040,011,PUSHBUTTON,DEFAULT,"&Cancel",0,2,DEFAULT,"MS Sans Serif|5632|70|34","128|128|0","220|226|205"` c@ttracew003=`026,098,040,011,PUSHBUTTON,DEFAULT,"&Delete",3,3,DEFAULT,"MS Sans Serif|5632|70|34","128|128|0","220|226|205"` c@ttracew006=`002,082,216,011,PUSHBUTTON,DEFAULT,"&Select (highlight) a debugtrace script for re/loading into WinBatch Studio",4,4,DEFAULT,"MS Sans Serif|5632|70|34","128|128|0","220|226|205"` c@ttracew005=`002,070,216,011,PUSHBUTTON,DEFAULT,"C&reate a copy for use as a debugtrace script from a file",2,5,DEFAULT,"MS Sans Serif|5632|70|34","128|128|0","220|226|205"` c@ttracew004=`002,058,216,011,PUSHBUTTON,DEFAULT,"C&reate a copy for use as a debugtrace script from the current open file",5,6,DEFAULT,"MS Sans Serif|5632|70|34","128|128|0","220|226|205"` c@ttracew007=`007,020,206,040,ITEMBOX,c@tcopies,DEFAULT,DEFAULT,6,DEFAULT,DEFAULT,DEFAULT,"206|255|206"` c@ttracew008=`002,006,222,010,STATICTEXT,DEFAULT,"Existing Copies_of in %c@tenv%",DEFAULT,7,DEFAULT,DEFAULT,DEFAULT,DEFAULT` c@ttracew009=`001,113,219,011,VARYTEXT,c@ttwerror,"",DEFAULT,8,DEFAULT,"Microsoft Sans Serif|5325|40|34","255|0|0",DEFAULT` dw_Panel_Placement("c@ttracew",2) ; Line 795 c@ttracewbtn=Dialog("c@tTracew") If c@ttracewbtn==1 Then Break ; Return to initial panel. If t@wcancel Then Continue ; Request cancelled. c@ttwerror="" If c@ttracewbtn==4 ; Select (highlight) a debugtrace script for re/loading into WinBatch Studio. c@tcopies=ItemExtract(1,c@tcopies,@Tab) If c@tcopies=="" c@ttwerror="No Copy_of file selected" c@ttracewbtn="" ; Show select unsuccesful. Continue Else ; ! c@tcopies=="". c@tnew=StrCat('"',c@tenv,"\",c@tcopies,'"') Run(c@twinbatch,c@tnew) Break EndIf ; C@tcopies=="". EndIf ; C@ttracewbtn==4. If c@ttracewbtn==2 ; Create a copy for use as a debugtrace script from a file. GoSub CREATE ; Create a Copy_of from a file. ; Line 288 If t@wcancel Then Break EndIf ; C@ttracewbtn==2. If c@ttracewbtn==3 ; Delete Copy_of file/s. c@tyesno=AskYesNo("DebugWizard","Delete?") If c@tyesno==0 Then Continue If c@tcopies=="" c@ttwerror="No Copy_of file/s selected" Else ; ! c@tcopies=="". For c@txx=1 To ItemCount(c@tcopies,@Tab) c@tdelfile=StrCat(c@tenv,'\',ItemExtract(c@txx,c@tcopies,@Tab)) ; Set up file name. ErrorMode(@Off) FileAttrSet(c@tdelfile,"r") ; Remove Read only attribute. FileDelete(c@tdelfile) ; Chop it. ErrorMode(@On) GoSub DELFROMINI ; Remove entry from ini. ; Line 374 Next ; C@txx=1 To ItemCount(c@tcopies,@Tab). c@ttwerror=StrCat(ItemCount(c@tcopies,@Tab)," files deleted") EndIf ; C@tcopies=="". EndIf ; C@ttracewbtn==3. If c@ttracewbtn==5 ; Create a copy for use as a debugtrace script from the current open file. c@tlinenum=wGetLineNo() ; Remember cursor's line number. wSelectAll() ; Select contents of file. wCopy() ; Copy to clipboard. TimeDelay(1) ; Give it time to complete the copy operation. wClearSel() ; Remove highlighting. wGotoLine(c@tlinenum) ; Put cursor back on same line - was moved by wSelectAll(). c@tcopied=ClipGet() ; Get current file in string form. c@tfile=StrCat(c@tenv,"\",FileBaseName(wGetFileName())) ; Save file in temp directory. FilePut(c@tfile,c@tcopied) ; Save original file in temp directory. GoSub CREATE ; Create Copy_of file as a debugtrace script. ; Line 288 If t@wcancel Then Break Run(c@twinbatch,StrCat('"',c@tnew,'"')) ; Make copy_of current. TimeDelay(1) ; Ensure file is displayed. wGotoLine(c@tlinenum) ; Put cursor on same line as in original file. FileDelete(c@tfile) Break EndIf ; C@ttracewbtn==5. EndWhile ; @True. Return :CREATE ; From 248 278 c@tfileh=0 c@touth=0 c@tout="" If c@tfile=="" Then c@tfile=AskFileName("","C:\","All Files|*.*|WIL Files|*.wbt;*.mnu|Text Files|*.txt|","*.wbt",1) If c@tfile=="" || t@wcancel Then c@ttwerror="File selection cancelled" Then Return c@tfileh=FileOpen(c@tfile,"read") c@tout=FileCreateTemp("xxx") c@touth=FileOpen(c@tout,"write") c@tcount=0 While @True c@tcount=c@tcount+1 wStatusMsg(StrCat("DebugWizard - line ",c@tcount)) ; Provide feedback. c@tline0=FileRead(c@tfileh) c@tline=StrTrim(c@tline0) If c@tline=="*EOF*" Then Break If StrLen(c@tline)+2+StrLen(c@tcount)>255 Then GoSub TOOBIG ; Report line that needs trimming. ; Line 327 If t@wcancel Then Break c@tline=StrCat(StrFill(" ",StrLen(c@tline0)-StrLen(StrClean(StrTrim(StrCat(c@tline0,Num2Char(1))),Num2Char(1),"",@True,1))),c@tline) FileWrite(c@touth,StrCat(c@tline,";",c@tcount,"'")) EndWhile ; @True. If t@wcancel Then Return If c@tfileh Then FileClose(c@tfileh) If c@touth Then FileClose(c@touth) If c@tout<>"" c@tnew=StrCat(FilePath(c@tout),"Copy_of_",FileBaseName(c@tfile)) ErrorMode(@Off) FileAttrSet(c@tnew,"r") ; Remove Read only attribute. FileDelete(c@tnew) ; Delete a previous copy_of file if present. ErrorMode(@On) c@tx=0 ErrorMode(@Off) c@tx=FileRename(c@tout,c@tnew) ErrorMode(@On) If c@tx Then FileAttrSet(c@tnew,"R") ; Read only. Else Display(4,"Rename failure",StrCat("unable to rename: ",c@tout,@CrLf,"to: ",FilePath(c@tout),"Copy_of_file",FileBaseName(c@tfile))) EndIf ; C@tout<>"". Return :TOOBIG ; From 305 c@taddon=StrCat(";",c@tcount,"'") ; Line numbering addition. c@torig=StrCat(c@tline,c@taddon) c@tline1=StrSub(c@torig,1,255) c@tline2=StrSub(c@torig,256,-1) c@ttoomuch=StrLen(c@tline2) While @True t@wcancel=0 c@tmydialogformat=`WWWDLGED,6.1` c@tmydialogcaption=`DebugWizard - add line numbers to script` c@tmydialogx=9999 c@tmydialogy=9999 c@tmydialogwidth=313 c@tmydialogheight=080 c@tmydialognumcontrols=006 c@tmydialogprocedure=`DEFAULT` c@tmydialogfont=`DEFAULT` c@tmydialogtextcolor=`DEFAULT` c@tmydialogbackground=`DEFAULT,"230|255|255"` c@tmydialogconfig=0 c@tmydialog001=`224,060,040,010,PUSHBUTTON,DEFAULT,"&OK",1,1,32,"MS Sans Serif|5632|70|34","128|128|0","220|226|205"` c@tmydialog002=`136,060,040,010,PUSHBUTTON,DEFAULT,"&Terminate",0,2,DEFAULT,"MS Sans Serif|5632|70|34","128|128|0","220|226|205"` c@tmydialog003=`048,060,040,010,PUSHBUTTON,DEFAULT,"&Restore",2,3,DEFAULT,"MS Sans Serif|5632|70|34","128|128|0","220|226|205"` c@tmydialog004=`015,006,291,010,STATICTEXT,DEFAULT,"Line length > 255 characters - delete %c@ttoomuch% chars from line 1 - do not remove trailing ;linenumber'",DEFAULT,3,DEFAULT,"Microsoft Sans Serif|6963|40|34","0|0|0",DEFAULT` c@tmydialog005=`010,025,291,011,EDITBOX,c@tline1,DEFAULT,DEFAULT,4,DEFAULT,DEFAULT,DEFAULT,"206|255|206"` c@tmydialog006=`010,044,291,011,EDITBOX,c@tline2,DEFAULT,DEFAULT,5,DEFAULT,DEFAULT,DEFAULT,"206|255|206"` dw_Panel_Placement("c@tmydialog",5) ; Line 795 c@tbtn=Dialog("c@tMyDialog") If t@wcancel Then Break If c@tbtn==2 c@tline1=StrSub(c@torig,1,255) c@tline2=StrSub(c@torig,256,-1) Continue EndIf ; C@tbtn==2. If StrLen(c@tline1)+StrLen(c@tline2)>255 Then Continue c@tline=StrCat(c@tline1,c@tline2) c@tline=StrSub(c@tline,1,StrLen(c@tline)-StrLen(c@taddon)) ; Remove addon again. Break EndWhile ; @True. Return :COPIES ; From 208 c@tsavecur=DirGet() ; Save current working directory. DirChange(c@tenv) ; Dive into TEMP directory. c@tx=FileItemize("copy_of*.*") ; Gather Copies_of files. c@tcopies=ItemSort(c@tx,@Tab) ; Sort list. DirChange(c@tsavecur) ; Restore original working directory. Return :DELFROMINI ; From 263 c@tinisections=StrLower(IniItemizePvt("",w@bini)) ; Get all section headers. c@tdelfile=StrLower(c@tdelfile) c@tsectionfound=ItemLocate(c@tdelfile,c@tinisections,@Tab) ; See if in ini file. If c@tsectionfound==0 ; Apparently not there, but... c@tsectionfound=StrIndex(c@tinisections,c@tdelfile,1,@Fwdscan) ; Filenames as section headers have double quotes around them. If c@tsectionfound Then IniDeletePvt(StrCat("""",c@tdelfile,""""),@WholeSection,w@bini) ; Had quotes, so deal with it. Else ; ! c@tsectionfound==0. IniDeletePvt(c@tdelfile,@WholeSection,w@bini) ; Simple section deletion. EndIf ; C@tsectionfound==0. Return :ANALYZEDEBUG ; From 190 Intcontrol(73,1,0,0,0) ; Exit gracefully. w@btracefile=IniReadPvt(c@tnew,"DebugTraceFile","debugtrace.dbt",w@bini) w@btracefile=AskFileName(StrCat("DebugWizard - select debugtrace file created by ",c@tnew),FilePath(w@btracefile),"Debug|*.dbt|All Files|*.*|WIL Files|*.wbt;*.mnu|Text Files|*.txt|",FileBaseName(w@btracefile),1) If t@wcancel Then Return If StrLower(IniReadPvt(c@tnew,"DebugTraceFile","",w@bini))<>StrLower(w@btracefile) IniDeletePvt(c@tnew,@WholeSection,w@bini) ; New trace file, new entry. EndIf ; StrLower(IniReadPvt(c@tnew,"DebugTraceFile","",w@bini))<>StrLower(w@btracefile). GoSub CONTROLPANELIN ; Init fields in panel. ; Line 739 IniWritePvt(c@tnew,"DebugTraceFile",w@btracefile,w@bini) ; Remember debugtrace script's debugtrace file name. w@bfs=FileSize(w@btracefile,1) w@bfs=StrSub(w@bfs,1,StrLen(w@bfs)-2) ; Divide by 100. If StrLen(w@bfs)>7 Then w@bfs=StrSub(w@bfs,1,StrLen(w@bfs)-1) ; Divide by 10, i.e. 1000. If w@bfs<10000 Then w@bfs=10000 ; Minimum buffer size. If w@bparmbuf=="" Then w@bparmbuf=w@bfs If w@bparmsec=="" If w@bfs<100000 Then w@bparmsec=1000 Else w@bparmsec=StrSub(w@bfs,1,StrLen(w@bfs)-2) EndIf ; W@bparmsec=="". If w@bparmgig=="" If FileSize(w@btracefile,1) > "2147483647" Then w@bparmgig=1 Else w@bparmgig=0 EndIf ; W@bparmgig=="". w@bfaerror="" While @True t@wcancel=0 w@bfaformat=`WWWDLGED,6.1` w@bfacaption=`DebugWizard - File Analysis Parameters` w@bfax=9999 w@bfay=9999 w@bfawidth=192 w@bfaheight=80 w@bfanumcontrols=010 w@bfaprocedure=`DEFAULT` w@bfafont=`DEFAULT` w@bfatextcolor=`DEFAULT` w@bfabackground=`DEFAULT,230|255|255` w@bfaconfig=0 w@bfa001=`118,050,040,011,PUSHBUTTON,DEFAULT,"&Ok",2,1,DEFAULT,"MS Sans Serif|5632|70|34","128|128|0","220|226|205"` w@bfa002=`036,050,040,011,PUSHBUTTON,DEFAULT,"&Cancel",0,23,DEFAULT,"MS Sans Serif|5632|70|34","128|128|0","220|226|205"` w@bfa003=`015,013,044,011,CHECKBOX,w@bparmauto,"Automatic - or",1,36,DEFAULT,DEFAULT,DEFAULT,DEFAULT` w@bfa004=`067,014,036,011,EDITBOX,w@bparmbuf,"",DEFAULT,37,DEFAULT,DEFAULT,DEFAULT,"206|255|206"` w@bfa005=`148,014,025,011,EDITBOX,w@bparmsec,"",DEFAULT,38,DEFAULT,DEFAULT,DEFAULT,"206|255|206"` w@bfa006=`045,004,143,009,STATICTEXT,DEFAULT,"Buffer (10,000-999,999,999) && secondary( 1,000-1,000,000)",DEFAULT,39,DEFAULT,DEFAULT,DEFAULT,DEFAULT` w@bfa007=`001,026,192,007,STATICTEXT,DEFAULT,"------------------------------------------------------------------------------------------------------------------------------------",DEFAULT,28,DEFAULT,DEFAULT,DEFAULT,DEFAULT` w@bfa008=`015,033,045,011,CHECKBOX,w@bparmgraph,"Display graph",1,40,DEFAULT,DEFAULT,DEFAULT,DEFAULT` w@bfa009=`067,033,045,011,CHECKBOX,w@bparmgig,"2GB+file",1,41,DEFAULT,DEFAULT,DEFAULT,DEFAULT` w@bfa010=`002,068,192,010,VARYTEXT,w@bfaerror,DEFAULT,DEFAULT,22,DEFAULT,"Microsoft Sans Serif|5325|40|34","255|0|0",DEFAULT` dw_Panel_Placement("w@bfa",3) ; Line 795 w@bfabtn=Dialog("w@bfa") If t@wcancel Then Break wStatusMsg("DebugWizard: Analysing debugtrace file.......") w@barray=gigafile_Init(w@btracefile,w@bparmauto,w@bparmbuf,w@bparmsec,w@bparmgig,w@bparmgraph) ; Line 834 wStatusMsg("") If w@barray[0,0] w@bfaerror=w@barray[1,0] Drop(w@barray) Continue EndIf ; W@barray[0,0]. Break EndWhile ; @True. If t@wcancel Then Return w@bbookmark=0 ; No bookmark showing. w@bcur=1 ; Current debug line. w@bnum=1 ; Default starting script line. w@berror="" w@bend=w@barray[4,0] ; Save total line count of debugtrace file. GoSub W@BQUERYFIRST ; Line 556 wStatusMsg("DebugWizard: when starting... if no change soon then perhaps not a real debugtrace file!!!!!! - press SHIFT & CTRL to end") ; More feedback. w@bkeycodes = StrCat("{LEFT}",@Tab,"{RIGHT}",@Tab,"{UP}",@Tab,"{DOWN}") w@bitem = WaitForKeyEx(w@bkeycodes,0) ; Prime list. While @True If IsKeydown(@Ctrl) ; Interrupting tracing? w@berror=StrCat("Tracing interrupted at line ",w@bcur," of ",w@bend) ; Yes. GoSub W@BQUERY ; See what's up doc. ; Line 552 EndIf ; IsKeydown(@Ctrl). If t@wcancel || w@bbtn==4 Then Break w@bitem = WaitForKeyEx("",0) ; Navigation keys used? If w@bpause<>0 Then TimeDelay(w@bpause) ; Pausing. If w@bitem==0 ; Normal operation. GoSub W@BFORWARDS ; Line 519 Else ; ! w@bitem==0. If w@bitem==4 ; Freeze mode. TimeDelay(.5) Else ; ! w@bitem==4. If w@bitem==1 w@barray=gigafile_Line_Number(w@barray,w@barray[3,0]-(w@bup*w@bupmult)) ; Jump back 30 lines. ; Line 1130 GoSub W@BBACKWARDS ; Move up debugger report by 30. ; Line 499 Else ; ! w@bitem==1. If w@bitem==2 w@barray=gigafile_Line_Number(w@barray,w@barray[3,0]+(w@bdown*w@bdownmult)) ; Jump forward 30 lines. ; Line 1130 GoSub W@BFORWARDS ; Move down debugger report by 30. ; Line 519 Else ; ! w@bitem==2. If w@bitem==3 w@barray=gigafile_Previous_Line(w@barray) ; Previous debug line. ; Line 1459 w@barray=gigafile_Previous_Line(w@barray) ; Previous debug line. ; Line 1459 GoSub W@BBACKWARDS ; Line 499 EndIf ; W@bitem==3. EndIf ; W@bitem==2. EndIf ; W@bitem==1. EndIf ; W@bitem==4. EndIf ; W@bitem==0. EndWhile ; @True. Return :WBERRORHANDLER ; From ? If w@bbookmark ; Turned off. wGotoLine(w@bnum) wStatusMsg("") EndIf ; W@bbookmark. DropWild("t@w*") ; Clean up. DropWild("c@t*") ; Clean up. DropWild("w@b*") ; Clean up. Display(5,"DebugWizard","Error encountered during DebugWizard processing") Exit :W@BBACKWARDS ; Scan backwards. ; From 472 481 If w@barray[2,0]<>"*SOF*" w@bline=w@barray[2,0] ; Extract numbered line. If w@bline=="" || StrTrim(w@bline)=="" ; Skip empty line. w@barray=gigafile_Previous_Line(w@barray) ; Rubbish, try previous line. ; Line 1459 Else ; ! w@bline=="" || StrTrim(w@bline)=="". If StrScan(w@bline,"'",0,@Backscan)<>StrLen(w@bline) ; Debug line of interest? w@barray=gigafile_Previous_Line(w@barray) ; Not a debug trigger line. ; Line 1459 Else ; ! StrScan(w@bline,"'",0,@Backscan)<>StrLen(w@bline). GoSub W@BTRACE ; Provide trace information. ; Line 538 w@barray=gigafile_Previous_Line(w@barray) ; Previous debug line. ; Line 1459 w@barray=gigafile_Previous_Line(w@barray) ; Previous debug line. ; Line 1459 EndIf ; StrScan(w@bline,"'",0,@Backscan)<>StrLen(w@bline). EndIf ; W@bline=="" || StrTrim(w@bline)=="". Else ; ! w@barray[2,0]<>"*SOF*". wStatusMsg("start of trace file reached") w@berror="Start of trace file reached" GoSub W@BQUERY ; Line 552 EndIf ; W@barray[2,0]<>"*SOF*". Return :W@BFORWARDS ; Scan forwards. ; From 465 476 If w@barray[2,0]<>"*EOF*" w@bline=w@barray[2,0] ; Extract numbered line. If w@bline=="" || StrTrim(w@bline)=="" ; Skip empy line. w@barray=gigafile_Next_Line(w@barray) ; Rubbish, try next line. ; Line 1065 Else ; ! w@bline=="" || StrTrim(w@bline)=="". If StrScan(w@bline,"'",0,@Backscan)<>StrLen(w@bline) ; Not a debug trigger line. w@barray=gigafile_Next_Line(w@barray) ; Try next line. ; Line 1065 Else ; ! StrScan(w@bline,"'",0,@Backscan)<>StrLen(w@bline). GoSub W@BTRACE ; Provide trace information. ; Line 538 w@barray=gigafile_Next_Line(w@barray) ; Align trace for next entry. ; Line 1065 EndIf ; StrScan(w@bline,"'",0,@Backscan)<>StrLen(w@bline). EndIf ; W@bline=="" || StrTrim(w@bline)=="". Else ; ! w@barray[2,0]<>"*EOF*". wStatusMsg("end of trace file reached") w@berror="End of trace file reached" GoSub W@BQUERY ; Line 552 EndIf ; W@barray[2,0]<>"*EOF*". Return :W@BTRACE ; From 508 528 w@bcolon=StrScan(w@bline,";",0,@Backscan)+1 ; Start of script line number. w@bnum=StrSub(w@bline,w@bcolon,StrLen(w@bline)-w@bcolon) ; Get and align on script line number. If w@bbookmark Then wSetBookMark() ; Turn off bookmark. w@bbookmark=0 ; Turned off. wStatusMsg("") ; Clear before bookmark - stops confusion. wGotoLine(w@bnum) w@bcur=w@barray[3,0] w@barray=gigafile_Next_Line(w@barray) ; Get numbered line. ; Line 1065 w@bnext=w@barray[2,0] ; Extract numbered line. wStatusMsg(StrCat("DebugWizard: S",w@bnum," T",w@bcur," ",w@bnext," -> ",w@bline)) ; Provide feedback. wSetBookMark() ; Highlight line. w@bbookmark=1 ; Bookmark sign switched on. Return :W@BQUERY ; From 459 516 535 w@btraceline=w@barray[3,0] ; Show current debug trace line. If w@btraceline==0 Then w@btraceline=1 w@bscriptline=w@bnum ; Show current script line. :W@BQUERYFIRST ; From 452 If w@bbookmark Then wSetBookMark() ; Turn off bookmark. w@bbookmark=0 If w@berror=="" Then w@berror="if variable or function = """" then leave =# and =Chars blank." w@bupinit=w@bup ; Minimum up. w@bdowninit=w@bdown ; Minimum down. w@bupmultinit=w@bupmult w@bdownmultinit=w@bdownmult While @True wStatusMsg("") ; Clear status line. w@bupup=StrCat("10|",32767,"|1") w@bdowndown=StrCat("10|",32767,"|1") w@bupmultmult=StrCat("1|",32767,"|1") w@bdownmultmult=StrCat("1|",32767,"|1") t@wcancel=0 w@bformat=`WWWDLGED,6.1` w@bcaption=`DebugWizard - control panel ` w@bx=9999 w@by=9999 w@bwidth=192 w@bheight=145 w@bnumcontrols=043 w@bprocedure=`DEFAULT` w@bfont=`DEFAULT` w@btextcolor=`DEFAULT` w@bbackground=`DEFAULT,230|255|255` w@bconfig=0 w@b001=`038,068,047,011,PUSHBUTTON,DEFAULT,"Res&ume Trace",2,1,DEFAULT,"MS Sans Serif|5632|70|34","128|128|0","220|226|205"` w@b002=`001,004,079,011,STATICTEXT,DEFAULT,"Resume from script line #",DEFAULT,1,DEFAULT,"Microsoft Sans Serif|6963|40|34","0|0|0",DEFAULT` w@b003=`080,002,034,011,EDITBOX,w@bscriptline,DEFAULT,DEFAULT,2,DEFAULT,DEFAULT,DEFAULT,"206|255|206"` w@b004=`002,018,080,011,STATICTEXT,DEFAULT,"Resume from trace line #",DEFAULT,3,DEFAULT,"Microsoft Sans Serif|6963|40|34","0|0|0",DEFAULT` w@b005=`080,017,034,011,EDITBOX,w@btraceline,"",DEFAULT,4,DEFAULT,DEFAULT,DEFAULT,"206|255|206"` w@b006=`116,004,072,011,STATICTEXT,DEFAULT,"Display interval (secs)",DEFAULT,5,DEFAULT,"Microsoft Sans Serif|6963|40|34","0|0|0",DEFAULT` w@b007=`116,017,014,011,RADIOBUTTON,w@binterval,"0",1,6,DEFAULT,DEFAULT,DEFAULT,DEFAULT` w@b008=`135,017,014,011,RADIOBUTTON,w@binterval,".1",2,7,DEFAULT,DEFAULT,DEFAULT,DEFAULT` w@b009=`151,017,014,011,RADIOBUTTON,w@binterval,".5",3,8,DEFAULT,DEFAULT,DEFAULT,DEFAULT` w@b010=`169,017,014,011,RADIOBUTTON,w@binterval,"1",4,9,DEFAULT,DEFAULT,DEFAULT,DEFAULT` w@b011=`004,025,049,011,RADIOBUTTON,w@bvf,"... variable name",1,10,DEFAULT,DEFAULT,DEFAULT,DEFAULT` w@b012=`004,031,049,011,RADIOBUTTON,w@bvf,"... function name",2,11,DEFAULT,DEFAULT,DEFAULT,DEFAULT` w@b013=`004,038,049,010,RADIOBUTTON,w@bvf,"... text to find",3,12,DEFAULT,DEFAULT,DEFAULT,DEFAULT` w@b014=`004,045,080,011,CHECKBOX,w@bvftcase,"var/func/text case sensitive",1,12,DEFAULT,DEFAULT,DEFAULT,DEFAULT` w@b015=`053,033,040,011,EDITBOX,w@bvname,"",DEFAULT,13,DEFAULT,DEFAULT,DEFAULT,"206|255|206"` w@b016=`098,035,008,011,STATICTEXT,DEFAULT,"=#",DEFAULT,14,DEFAULT,"Microsoft Sans Serif|6963|40|34","0|0|0",DEFAULT` w@b017=`108,033,019,011,EDITBOX,w@bdigit,"",DEFAULT,15,DEFAULT,DEFAULT,DEFAULT,"206|255|206"` w@b018=`130,035,026,010,STATICTEXT,DEFAULT,"or =Chars",DEFAULT,16,DEFAULT,DEFAULT,DEFAULT,DEFAULT` w@b019=`157,033,030,011,EDITBOX,w@bchars,"",DEFAULT,17,DEFAULT,DEFAULT,DEFAULT,"206|255|206"` w@b020=`134,043,050,011,CHECKBOX,w@bcase,"case sensitive",1,18,DEFAULT,DEFAULT,DEFAULT,DEFAULT` w@b021=`012,057,030,011,STATICTEXT,DEFAULT,"...starting at",DEFAULT,19,DEFAULT,DEFAULT,DEFAULT,DEFAULT` w@b022=`050,056,035,010,RADIOBUTTON,w@bresume,"beginning",1,20,DEFAULT,DEFAULT,DEFAULT,DEFAULT` w@b023=`094,056,034,010,RADIOBUTTON,w@bresume,"script line #",2,21,DEFAULT,DEFAULT,DEFAULT,DEFAULT` w@b024=`140,056,040,010,RADIOBUTTON,w@bresume,"trace line #",3,22,DEFAULT,DEFAULT,DEFAULT,DEFAULT` w@b025=`001,068,036,011,PUSHBUTTON,DEFAULT,"&End Debug",4,23,DEFAULT,"MS Sans Serif|5632|70|34","128|128|0","220|226|205"` w@b026=`086,068,049,011,PUSHBUTTON,DEFAULT,"&Resume Script",1,24,32,"MS Sans Serif|5632|70|34","128|128|0","220|226|205"` w@b027=`135,068,051,011,PUSHBUTTON,DEFAULT,"Re&sume where...",3,25,DEFAULT,"MS Sans Serif|5632|70|34","128|128|0","220|226|205"` w@b028=`002,081,186,008,STATICTEXT,DEFAULT,"-------------------------------------------Tracelog----Navigation---------------------------------------------------",DEFAULT,26,DEFAULT,DEFAULT,DEFAULT,DEFAULT` w@b029=`002,092,051,008,STATICTEXT,DEFAULT,"Left arrow-up",DEFAULT,27,DEFAULT,DEFAULT,DEFAULT,DEFAULT` w@b030=`034,089,025,011,SPINNER,w@bupup,"%w@bupinit%",DEFAULT,28,DEFAULT,DEFAULT,DEFAULT,"206|255|206"` w@b031=`060,091,003,008,STATICTEXT,DEFAULT,"x",DEFAULT,29,DEFAULT,DEFAULT,DEFAULT,DEFAULT` w@b032=`064,089,025,011,SPINNER,w@bupmultmult,"%w@bupmultinit%",DEFAULT,30,DEFAULT,DEFAULT,DEFAULT,"206|255|206"` w@b033=`092,092,057,008,STATICTEXT,DEFAULT,"Right arrow-down",DEFAULT,31,DEFAULT,DEFAULT,DEFAULT,DEFAULT` w@b034=`134,089,025,011,SPINNER,w@bdowndown,"%w@bdowninit%",DEFAULT,32,DEFAULT,DEFAULT,DEFAULT,"206|255|206"` w@b035=`160,091,003,008,STATICTEXT,DEFAULT,"x",DEFAULT,33,DEFAULT,DEFAULT,DEFAULT,DEFAULT` w@b036=`164,089,025,011,SPINNER,w@bdownmultmult,"%w@bdownmultinit%",DEFAULT,34,DEFAULT,DEFAULT,DEFAULT,"206|255|206"` w@b037=`007,103,063,008,STATICTEXT,DEFAULT,"Up arrow - move up log",DEFAULT,35,DEFAULT,DEFAULT,DEFAULT,DEFAULT` w@b038=`092,103,072,011,STATICTEXT,DEFAULT,"Down arrow - freeze display",DEFAULT,36,DEFAULT,DEFAULT,DEFAULT,DEFAULT` w@b039=`007,111,063,008,STATICTEXT,DEFAULT,"CTRL - present this panel",DEFAULT,37,DEFAULT,DEFAULT,DEFAULT,DEFAULT` w@b040=`092,111,092,011,STATICTEXT,DEFAULT,"",DEFAULT,38,DEFAULT,DEFAULT,DEFAULT,DEFAULT` w@b041=`007,118,050,011,CHECKBOX,w@bexclusive,"(Exclusive(@On)",1,39,DEFAULT,DEFAULT,DEFAULT,DEFAULT` w@b042=`002,125,186,008,STATICTEXT,DEFAULT,"----------------------------------------------------------------------------------------------------------------------",DEFAULT,40,DEFAULT,DEFAULT,DEFAULT,DEFAULT` w@b043=`004,131,250,010,VARYTEXT,w@berror,DEFAULT,DEFAULT,41,DEFAULT,"Microsoft Sans Serif|5325|40|34","255|0|0",DEFAULT` dw_Panel_Placement("w@b",4) ; Line 795 w@bbtn=Dialog("w@b") GoSub CONTROLPANELOUT ; Save all session details. ; Line 762 If t@wcancel || w@bbtn==4 Then Break w@berror="Script/Trace resume line invalid" If StrClean(w@bscriptline,"0123456789","",@True,1)<>"" || StrClean(w@btraceline,"0123456789","",@True,1)<>"" Then Continue If w@bscriptline<1 Then w@bscriptline=1 ; Set minimum script line #. If w@btraceline<1 Then w@btraceline=1 ; Set minimum trace file line #. If w@btraceline>=w@bend Then w@btraceline=w@bend ; Set Maximum trace file line #. w@bpause=ItemExtract(w@binterval,"0,0.1,0.5,1",",") ; Use current timing. If w@bexclusive Then Exclusive(@On) Else Exclusive(@Off) If w@bbtn==1 ; Find trace line # via script line number. w@berror="Script line not found" w@barray=gigafile_Find_Text(w@barray,StrCat(";",w@bscriptline,"'"),0,0,0,0,1) ; Line 1236 If w@barray[0,0]==14 Then Continue ; Script line # not found in trace. w@bcur=w@barray[3,0] ; Trace line numbers. Break EndIf ; W@bbtn==1. If w@bbtn==2 w@berror="Trace line not found" If w@btraceline>=w@barray[4,0] Then Continue ; No outside trace line numbers. w@bcur=w@btraceline ; Set up resume point. Break EndIf ; W@bbtn==2. w@bvfound=0 ; 1 if variable and its value found. If w@bvf==1 Then w@btype="=" ; Variable 'id'. If w@bvf==2 Then w@btype="(" ; Function 'id'. If w@bvf==3 ; Text search. If w@bvname=="" Then w@berror="No text provided in var/funct/text field" ; Basic check. Then Continue EndIf ; W@bvf==3. If w@bresume==1 Then w@bresumeat=1 If w@bresume==2 Then w@bresumeat=w@bscriptline If w@bresume==3 Then w@bresumeat=w@btraceline If w@bvf==3 ; Resume scanning for text starting... If w@bresume==2 ; Find trace line via script line. wStatusMsg(StrCat("DebugWizard: scanning for script line: ",w@bscriptline)) ; Provide feedback. w@barray=gigafile_Find_Text(w@barray,StrCat(";",w@bscriptline,"'"),w@bresumeat,0,0,0,1) ; Line number of script line in trace. ; Line 1236 If w@barray[0,0]<>0 || w@barray[2,0]=="*EOF*" w@berror=StrCat("Script line ",w@bscriptline," not found") Continue Else ; ! w@barray[0,0]<>0 || w@barray[2,0]=="*EOF*". w@bresumeat=w@barray[3,0] ; This script line is in trace line. EndIf ; W@barray[0,0]<>0 || w@barray[2,0]=="*EOF*". EndIf ; W@bresume==2. wStatusMsg(StrCat("DebugWizard: scanning for text: ",w@bvname)) ; Provide feedback. w@barray=gigafile_Find_Text(w@barray,w@bvname,w@bresumeat,0,0,0,w@bvftcase) ; Find our case/not case sensitive text in debugtrace file. ; Line 1236 If w@barray[0,0]<>0 || w@barray[2,0]=="*EOF*" w@berror=StrCat("Text '",w@bchars,"' not found") Continue EndIf ; W@barray[0,0]<>0 || w@barray[2,0]=="*EOF*". w@bcur=w@barray[3,0] Break ; Resume tracing. Else ; ! w@bvf==3. ; now find variable/function name starting at beginning of or a specific line in the trace, or from a trace line containing the script line. If w@bresume==2 ; Find trace line via script line. wStatusMsg(StrCat("DebugWizard: scanning for script line: ",w@bscriptline," from trace line: ",w@bresumeat)) ; Provide feedback. w@barray=gigafile_Find_Text(w@barray,StrCat(";",w@bscriptline,"'"),w@bresumeat,0,0,0,1) ; Line number of script line in trace. ; Line 1236 If w@barray[0,0]<>0 || w@barray[2,0]=="*EOF*" w@berror=StrCat("Script line ",w@bscriptline," not found") Continue Else ; ! w@barray[0,0]<>0 || w@barray[2,0]=="*EOF*". w@bresumeat=w@barray[3,0] ; This script line is in trace line. EndIf ; W@barray[0,0]<>0 || w@barray[2,0]=="*EOF*". EndIf ; W@bresume==2. EndIf ; W@bvf==3. w@berror="" w@bcur=w@bresumeat While @True ; Find variable and its value in w@blist. If IsKeydown(@Ctrl) Then w@berror="Debugtracing interrupted" Then Break ; Interrupting scanning. If w@bdigit<>"" Then wStatusMsg(StrCat("DebugWizard: scanning for variable/function name: ",w@bvname,", and value: ",w@bdigit," from line ",w@bcur)) ; Provide feedback. Else wStatusMsg(StrCat("DebugWizard: scanning for variable/function name: ",w@bvname,", and value: ",w@bchars," from line ",w@bcur)) ; Provide feedback. ; required trace line got to search for variable/function name starting in column 1. w@barray=gigafile_Find_Text(w@barray,w@bvname,w@bcur,0,1,StrLen(w@bvname),w@bvftcase) ; Line 1236 If w@barray[0,0]<>0 || w@barray[2,0]=="*EOF*" GoSub W@BNOTFOUND ; Line 735 Break EndIf ; W@barray[0,0]<>0 || w@barray[2,0]=="*EOF*". If StrScan(StrTrim(StrSub(w@barray[2,0],StrLen(w@bvname)+1,-1)),w@btype,1,@Fwdscan)<>1 Then w@bcur=w@barray[3,0]+1 ; Not a variable or function type line. Then Continue w@barray=gigafile_Next_Line(w@barray) ; Line 1065 If w@barray[0,0]<>0 || w@barray[2,0]=="*EOF*" GoSub W@BNOTFOUND ; Line 735 Break EndIf ; W@barray[0,0]<>0 || w@barray[2,0]=="*EOF*". w@bscan=w@barray[2,0] ; Line for variable's value. If w@bdigit<>"" w@bbullseye=StrIndex(w@bscan,StrCat(") VALUE=> ",w@bdigit),1,@Fwdscan) ; Looking for variable's number. Else ; ! w@bdigit<>"". If w@bchars<>"" ; Any char values? If w@bcase Then w@bbullseye=StrIndex(w@bscan,StrCat(") VALUE=> """,w@bchars),1,@Fwdscan) ; Looking for case sensitive variable's characters. Else w@bbullseye=StrIndexNc(w@bscan,StrCat(") VALUE=> """,w@bchars),1,@Fwdscan) ; Looking for not case sensitive variable's characters. Else ; ! w@bchars<>"". w@bbullseye=StrIndexNc(w@bscan,StrCat(") VALUE=> """"",w@bchars),1,@Fwdscan) ; Looking for variable with blank contents. EndIf ; W@bchars<>"". EndIf ; W@bdigit<>"". If w@bbullseye ; Found variable's value. w@bvfound=1 ; Escape trigger. w@bcur=w@barray[3,0]-1 ; Start again with variable/function name line. Break EndIf ; W@bbullseye. w@bcur=w@barray[3,0]+1 ; Next line to search. EndWhile ; @True. If w@bvfound Then Break ; Resume debugging if variable's value found. EndWhile ; @True. w@barray=gigafile_Line_Number(w@barray,w@bcur) ; Line to start from. ; Line 1130 Return :W@BNOTFOUND ; From 703 710 If w@bdigit<>"" Then w@berror=StrCat("Variable/function and/or its numeric value '",w@bdigit,"' not found") Else w@berror=StrCat("Variable/function and/or its character value '",w@bchars,"' not found") Return :CONTROLPANELIN ; From 393 w@bexclusive=IniReadPvt(c@tnew,"Exclusive",1,w@bini) w@bup=IniReadPvt(c@tnew,"Up",10,w@bini) w@bdown=IniReadPvt(c@tnew,"Down",10,w@bini) w@bupmult=IniReadPvt(c@tnew,"UpMult",1,w@bini) w@bdownmult=IniReadPvt(c@tnew,"DownMult",1,w@bini) w@bvf=IniReadPvt(c@tnew,"VariableFunction",1,w@bini) w@bvftcase=IniReadPvt(c@tnew,"VariableFunctioncase",1,w@bini) w@bvname=IniReadPvt(c@tnew,"Varname","",w@bini) w@bdigit=IniReadPvt(c@tnew,"Number","",w@bini) w@bchars=IniReadPvt(c@tnew,"Character","",w@bini) w@bcase=IniReadPvt(c@tnew,"Case",0,w@bini) w@bresume=IniReadPvt(c@tnew,"Scanfrom",1,w@bini) w@binterval=IniReadPvt(c@tnew,"Interval",2,w@bini) w@bpause=ItemExtract(w@binterval,"0,0.1,0.5,1",",") ; Display current interval. w@bparmauto=IniReadPvt(c@tnew,"Automatic",1,w@bini) ; Automatic. w@bparmbuf=IniReadPvt(c@tnew,"Buffer","",w@bini) ; Buffer. w@bparmsec=IniReadPvt(c@tnew,"Secondary","",w@bini) ; Secondary. w@bparmgig=IniReadPvt(c@tnew,"Gigfile","",w@bini) ; 2G+file. w@bparmgraph=IniReadPvt(c@tnew,"Graph",1,w@bini) ; Graph. w@bscriptline=IniReadPvt(c@tnew,"Scriptline",1,w@bini) w@btraceline=IniReadPvt(c@tnew,"Traceline",1,w@bini) Return :CONTROLPANELOUT ; From 628 w@bup=w@bupup w@bdown=w@bdowndown w@bupmult=w@bupmultmult w@bdownmult=w@bdownmultmult IniWritePvt(c@tnew,"Scriptline",w@bscriptline,w@bini) IniWritePvt(c@tnew,"Traceline",w@btraceline,w@bini) IniWritePvt(c@tnew,"VariableFunction",w@bvf,w@bini) IniWritePvt(c@tnew,"VariableFunctioncase",w@bvftcase,w@bini) IniWritePvt(c@tnew,"Varname",w@bvname,w@bini) IniWritePvt(c@tnew,"Number",w@bdigit,w@bini) IniWritePvt(c@tnew,"Character",w@bchars,w@bini) IniWritePvt(c@tnew,"Case",w@bcase,w@bini) IniWritePvt(c@tnew,"Scanfrom",w@bresume,w@bini) IniWritePvt(c@tnew,"Interval",w@binterval,w@bini) IniWritePvt(c@tnew,"Up",w@bup,w@bini) IniWritePvt(c@tnew,"UpMult",w@bupmult,w@bini) IniWritePvt(c@tnew,"DownMult",w@bdownmult,w@bini) IniWritePvt(c@tnew,"Down",w@bdown,w@bini) IniWritePvt(c@tnew,"Exclusive",w@bexclusive,w@bini) IniWritePvt(c@tnew,"Automatic",w@bparmauto,w@bini) IniWritePvt(c@tnew,"Buffer",w@bparmbuf,w@bini) IniWritePvt(c@tnew,"Secondary",w@bparmsec,w@bini) IniWritePvt(c@tnew,"Gigfile",w@bparmgig,w@bini) IniWritePvt(c@tnew,"Graph",w@bparmgraph,w@bini) Return :INIT ; From 163 t@wcancel=0 c@tnew="" t@werror="" w@bbookmark=0 w@bini=StrCat(DirHome(),"DebugWizard.ini") ; Define INI file name. w@bbtn=0 #DefineSubRoutine dw_Panel_Placement(d@wanel_prefix,d@wanel_number) ; From 181 230 353 433 626 %d@wanel_prefix%numcontrols=%d@wanel_prefix%numcontrols+1 ; Increment control numbers. d@wanel_number_length=StrLen(d@wanel_number) ; String length of panel number. If d@wanel_number_length==1 d@wanel_placement_x=%d@wanel_prefix%width-5 ; X Location of single digit panel #. d@wanel_placement_y=%d@wanel_prefix%height-7 ; Y Location of single digit panel #. Else ; ! d@wanel_number_length==1. d@wanel_placement_x=%d@wanel_prefix%width-7 ; X Location of double digit panel #. d@wanel_placement_y=%d@wanel_prefix%height-7 ; Y location of double digit panel #. EndIf ; D@wanel_number_length==1. d@wanel_newline=StrCat("%d@wanel_prefix%",StrFixLeft(%d@wanel_prefix%numcontrols,"0",3),"=`",d@wanel_placement_x,",") d@wanel_newline=StrCat(d@wanel_newline,d@wanel_placement_y,",012,008,STATICTEXT,DEFAULT,",d@wanel_number) d@wanel_newline=StrCat(d@wanel_newline,",DEFAULT,2,DEFAULT,""Times New Roman|4277|40|18"",""0|0|0"",DEFAULT`") %d@wanel_newline% ; Complete last dialog variable. Return #EndSubRoutine ; Dw_panel_placement. #DefineFunction gigafile_Summary(handle) ;{{{#DefineFunction gigafile_summary}}} ; From ? ; Check for valid array parameter If !ArrInfo(handle,-1) handle[0,0]=5 ; Invalid array parameter passed. handle[1,0]="gigafile_summary: Invalid array parameter passed" Return handle EndIf ; !ArrInfo(handle,-1). line=StrCat("GigaFile summary:",@CrLf) line=StrCat(line,"Error code: ",handle[0,0],@CrLf) line=StrCat(line,"Error msgs: ",handle[1,0],@CrLf) line=StrCat(line,"Current line: ",handle[2,0],@CrLf) line=StrCat(line,"Current line no: ",handle[3,0],@CrLf) line=StrCat(line,"No of lines in file: ",handle[4,0],@CrLf) line=StrCat(line,"No of mini files: ",handle[5,0],@CrLf) line=StrCat(line,"Current mini file: ",handle[6,0],@CrLf) line=StrCat(line,"buffer size: ",handle[7,0],@CrLf) line=StrCat(line,"secondary size: ",handle[15,0],@CrLf) Message("Summary",line) Return handle #EndFunction ; Gigafile_summary. ;*************************************************************************************** ; GigaFile_Init * ;*************************************************************************************** #DefineFunction gigafile_Init(filename,automatic,buffer_size,secondary,huge_file_flag,graph) ;{{{#DefineFunction gigafile_Init}}} ; From 437 Intcontrol(73,1,0,0,0) forth_parm_duff_msg="Fifth parameter (2G+file) invalid specifiy 0 or 1" sec_exceeded=7 sec_exceeded_msg="secondary value exceeded - increase" sec_error=8 sec_msg="secondary dimension value invalid - max for pre 2004B is 65,535" sec_spec=15 sec_spec_msg="Secondary value invalid - 1000 minimum" forth_parm_duff=4 file_not_found=1 file_not_found_msg="File not found" buffer_size_invalid=2 buffer_size_invalid_msg="Buffer size invalid - range 10,000-999,999,999 bytes" buffer_size_max=999999999 buffer_size_min=10000 ; 10000. hugemath_dll_not_found=3 hugemath_dll_not_found_msg="HugeMath Dll not found or required for file size above 2,147,483,647 bytes" file_empty=9 file_empty_msg="File empty" currentsize=0 array=ArrDimension(16,1) ; Temp array. ArrInitialize(array,0) ; Check if file present If FileExist(filename)==0 array[0,0]=file_not_found array[1,0]=file_not_found_msg Return array EndIf ; FileExist(filename)==0. ; Check for empty file If FileSize(filename)==0 array[0,0]=file_empty array[1,0]=file_empty_msg Return array EndIf ; FileSize(filename)==0. ; Check buffer_size is digits only If !automatic If StrClean(buffer_size,"0123456789","",@True,1)<>"" array[0,0]=buffer_size_invalid array[1,0]=buffer_size_invalid_msg Return array EndIf ; StrClean(buffer_size,"0123456789","",@True,1)<>"". ; Check for valid buffer size - max 999,999,999 If StrLen(buffer_size)>9 array[0,0]=buffer_size_invalid array[1,0]=buffer_size_invalid_msg Return array EndIf ; StrLen(buffer_size)>9. ; Check for min/max buffer size - 10,00 to 999,999,999 If buffer_sizebuffer_size_max array[0,0]=buffer_size_invalid array[1,0]=buffer_size_invalid_msg Return array EndIf ; Buffer_size buffer_size_max. ; Check secondary is digits only If StrClean(secondary,"0123456789","",@True,1)<>"" array[0,0]=sec_spec array[1,0]=sec_spec_msg Return array EndIf ; StrClean(secondary,"0123456789","",@True,1)<>"". ; Check for correct secondary dimension - 65535 before 2004b, >65000 afterwards If Version()<"2004B" If secondary>65535 array[0,0]=sec_error array[1,0]=sec_msg Return array EndIf ; Secondary>65535. EndIf ; Version()<"2004B". ; Check for minimum secondary If secondary<1000 array[0,0]=sec_spec array[1,0]=sec_spec_msg Return array EndIf ; Secondary<1000. EndIf ; !automatic. ; Check for valid fifth parm If !(huge_file_flag==0 || huge_file_flag==1) array[0,0]=forth_parm_duff array[1,0]=forth_parm_duff_msg Return array EndIf ; !(huge_file_flag==0 || huge_file_flag==1). ; Check if huge dll present if requested If huge_file_flag If FileExist(StrCat(DirHome(),"wwhug34i.dll"))==0 array[0,0]=hugemath_dll_not_found array[1,0]=hugemath_dll_not_found_msg Return array Else ; ! FileExist(StrCat(DirHome(),"wwhug34i.dll"))==0. AddExtender("WWHUG34I.DLL") EndIf ; FileExist(StrCat(DirHome(),"wwhug34i.dll"))==0. EndIf ; Huge_file_flag. ; Check out graph option If graph<1 || graph>1 Then graph=0 If graph Then If FileExist(StrCat(DirHome(),"wwsop34i.DLL")) Then AddExtender("wwsop34i.DLL") size_of_file=FileSize(filename,1) ; Get filesize. If size_of_file>"2147483647" Then hugefile=1 ; It's a whopper. Else hugefile=0 ; It's a tiddler. If hugefile && huge_file_flag==0 ; Is HUGE needed but not requested? array[0,0]=hugemath_dll_not_found array[1,0]=hugemath_dll_not_found_msg Return array EndIf ; Hugefile && huge_file_flag==0. Drop(array) ; Drop temporary. ; Finished with preliminaries. Down to business. If automatic ; Provide a reasonable buffer & secondary size. buffer_size=size_of_file buffer_size=StrSub(buffer_size,1,StrLen(buffer_size)-2) ; Divide by 100. If StrLen(buffer_size)>7 Then buffer_size=StrSub(buffer_size,1,StrLen(buffer_size)-1) ; Divide by 10, i.e. 1000. If buffer_size<10000 Then buffer_size=10000 ; Minimum buffer size. If buffer_size<100000 Then secondary=1000 ; Minimum secodary. Else secondary=StrSub(buffer_size,1,StrLen(buffer_size)-2) EndIf ; Automatic. array=ArrDimension(16,secondary) ; If error 1636 then up this value. ArrInitialize(array,0) array[1,0]="" array[2,0]="" array[7,0]=buffer_size ; Original buffer_size specification. array[14,0]="" array[13,0]=filename ; Save filename for BinaryReadEx's. array[15,0]=secondary ; Secondary value. buf=0 buf=BinaryAlloc(buffer_size) array[12,0]=buf only_one_buffer_needed=0 If !hugefile If FileSize(filename,1)<=buffer_size ; File fits into a mini file. BinaryReadEx(buf,0,filename,0,buffer_size) ; Read in whole file. array[4,0]=BinaryStrCnt(buf,0,BinaryEodGet(buf)-1,@CrLf)+1 ; Set # of lines in file. If array[4,0]>1 Then If BinaryPeekStr(buf,BinaryEodGet(buf)-2,2)==@CrLf Then array[4,0]=array[4,0]-1 ; Line ends with @CrLf. array[5,0]=1 ; # of mini files. array[8,array[5,0]]=buffer_size ; List of size of each mini file in bytes. array[9,array[5,0]]=buffer_size ; List of total size of mini files up to and including current mini file. array[10,array[5,0]]=array[4,0] ; Set ending line # in mini file. BinaryEodSet(buf,0) only_one_buffer_needed=1 ; We're finished setting up file. EndIf ; FileSize(filename,1)<=buffer_size. EndIf ; !hugefile. If !only_one_buffer_needed If graph Then GoSub GRAPH ; Display graph. ; Line 1030 While @True If huge_file_flag If gigafile_Compare(currentsize,size_of_file)<>-1 Then Break ; Line 1564 Else ; ! huge_file_flag. If !(currentsize < size_of_file) Then Break EndIf ; Huge_file_flag. If huge_file_flag Then size=huge_Subtract(size_of_file,currentsize) Else size=size_of_file-currentsize If huge_file_flag Then size=gigafile_Min(buffer_size,size) ; Line 1559 Else size=Min(buffer_size,size) If graph Then segmentadd=segmentadd+1 Then aStatusBar(1,"Analysing file...",StrCat(currentsize," of ",size_of_file),segment,segmentadd) BinaryReadEx(buf,0,filename,currentsize,size) ; Read in a chunk of the file. If BinaryPeekStr(buf,size-1,2)==@CrLf ; Chunk ends in EOL? GoSub ARRAYADD ; Line 1040 Else ; ! BinaryPeekStr(buf,size-1,2)==@CrLf. x=BinaryIndexEx(buf,size-1,@CrLf,@Backscan,1) ; Find start of line. If x>-1 Then size=x+2 GoSub ARRAYADD ; Line 1040 EndIf ; BinaryPeekStr(buf,size-1,2)==@CrLf. BinaryEodSet(buf,0) EndWhile ; @True. EndIf ; !only_one_buffer_needed. a1=1 ; =x count in FOR. a2=1 ; To count in FOR. slots=1 ; One per thousand lines pointer. slotx=array[15,0]-1 ; Maximu thousand line pointer allocated. done=0 For x=1 To array[5,0] ; Subdivide list into thousand line slots for faster access. If slotx==slots Then Break ; Maximum thousand lines pointer reached. If graph Then aStatusBar(1,"Creating line index",StrCat(x," of ",array[5,0]),array[5,0],x) lc=array[10,x] ; Get highest line number in this mini file. thou=lc/1000 If thou-done For y=slots To thou If slotx==slots Then Break ; Maximum thousand lines pointer reached. array[14,slots]=StrCat(a1,",",a2) slots=slots+1 a1=a2 Next ; Y=slots To thou. a2=a2+1 Else ; ! thou-done. a2=x array[14,slots]=StrCat(a1,",",a2) EndIf ; Thou-done. done=thou Next ; X=1 To array[5,0]. If graph Then aStatusBar(2,"","",0,0) If slotx==slots array[0,0]=sec_exceeded ; Error Id. array[1,0]=sec_exceeded_msg Else ; ! slotx==slots. array[14,slots]=StrCat(a1,",",x-1) ; Write out last slot for remaining lines. EndIf ; Slotx==slots. Return array :GRAPH ; From 974 If huge_file_flag segment=huge_Divide(size_of_file,buffer_size) segment=StrSub(segment,1,StrLen(segment)-5) Else ; ! huge_file_flag. segment=size_of_file/buffer_size EndIf ; Huge_file_flag. segmentadd=0 aStatusBar(0,"","",segment,segmentadd) Return :ARRAYADD ; From 989 993 x=BinaryStrCnt(buf,0,size-1,@CrLf) ; Get line count for this chunk. If x==0 Then x=1 ; Last line in buffer has no EOL. array[4,0]=array[4,0]+x ; Set new line total in file. array[5,0]=array[5,0]+1 ; # of mini files. If array[5,0]==1 array[9,array[5,0]]=size ; List of total size of mini files up to and including current mini file. Else ; ! array[5,0]==1. If huge_file_flag Then array[9,array[5,0]]=huge_Add(array[9,array[5,0]-1],size) Else array[9,array[5,0]]=array[9,array[5,0]-1]+size ; List of total size of mini files up to and including current mini file. EndIf ; Array[5,0]==1. array[10,array[5,0]]=array[4,0] ; Slot for mini file now has highest line number in this mini file. array[8,array[5,0]]=size ; List of each mini file in bytes. If huge_file_flag Then currentsize=huge_Add(currentsize,size) Else currentsize=currentsize+size Return :WBERRORHANDLER ; From ? w@berr=LastError() w@berr=StrCat("Error: ",w@berr,@CrLf,"Error text: ",Intcontrol(34,w@berr,0,0,0)) Message("DebugWizard abended",StrCat(w@berr,@CrLf,"(For error 1636 increase secondary parameter")) Exit #EndFunction ; Gigafile_init. ;*************************************************************************************** ; GigaFile_Next_Line * ;*************************************************************************************** #DefineFunction gigafile_Next_Line(handle) ;{{{#DefineFunction gigafile_Next_Line}}} ; From 523 526 529 546 708 ; Check for valid array parameter If !ArrInfo(handle,-1) handle[0,0]=5 ; Invalid array parameter passed. handle[1,0]="gigafile_next_line: Invalid array parameter passed" Return handle EndIf ; !ArrInfo(handle,-1). ; Check if already on last line If handle[3,0]==handle[4,0] handle[2,0]="*EOF*" Return handle EndIf ; Handle[3,0]==handle[4,0]. ; Get next line handle[0,0]=0 ; Reset. handle[1,0]="" ; Clear any error message. GoSub GETNEXTLINE ; First request for next line? ; Line 1082 Return handle :GETNEXTLINE ; From 1080 buf=handle[12,0] ; Use buf variable to access buffer contents. If !handle[3,0] ; First line ever? BinaryReadEx(buf,0,handle[13,0],0,handle[8,1]) ; Get first chunk of file. handle[6,0]=1 ; Current mini file is number 1. GoSub EXTRACTLINE ; Line 1101 handle[3,0]=1 ; Current line number in relation to whole file. Else ; ! !handle[3,0]. If handle[11,0]==handle[8,handle[6,0]] Then GoSub NEXTMINIFILE ; End of buffer reached in current mini file? ; Line 1095 GoSub EXTRACTLINE ; Line 1101 handle[3,0]=handle[3,0]+1 EndIf ; !handle[3,0]. Return handle :NEXTMINIFILE ; From 1090 BinaryEodSet(buf,0) ; Reset mini file buffer. handle[6,0]=handle[6,0]+1 ; Next mini file id. BinaryReadEx(buf,0,handle[13,0],handle[9,handle[6,0]-1],handle[8,handle[6,0]]) ; Get starting addr of this mini file from previous mini file's total. handle[11,0]=0 ; New starting offset. Return :EXTRACTLINE ; From 1087 1091 x=BinaryIndexEx(buf,handle[11,0],@CrLf,@Fwdscan,1) ; Find EOL indicator. If x==-1 handle[2,0]=BinaryPeekStr(buf,handle[11,0],BinaryEodGet(buf)-handle[11,0]) ; Retrieve EOLless line. handle[11,0]=BinaryEodGet(buf) ; End of file. Else ; ! x==-1. handle[2,0]=BinaryPeekStr(buf,handle[11,0],x-handle[11,0]) ; Copy line data less @CrLf. handle[11,0]=x+2 ; New offset for line two. EndIf ; X==-1. Return #EndFunction ; Gigafile_next_line. ;*************************************************************************************** ; GigaFile_Close * ;*************************************************************************************** #DefineFunction gigafile_Close(handle) ;{{{#DefineFunction gigafile_Close}}} ; From ? handle[0,0]=0 handle[1,0]="" ; Check for valid array parameter If !ArrInfo(handle,-1) handle[0,0]=5 ; Invalid array parameter passed. handle[1,0]="gigafile_close: Invalid array parameter passed" Return handle EndIf ; !ArrInfo(handle,-1). If handle[12,0] Then BinaryFree(handle[12,0]) ; Free if used. Return handle #EndFunction ; Gigafile_close. ;*************************************************************************************** ; GigaFile_Line_Number * ;*************************************************************************************** #DefineFunction gigafile_Line_Number(handle,line_num) ;{{{#DefineFunction gigafile_Line_Number}}} ; From 471 475 733 handle[0,0]=0 handle[1,0]="" ; Check for valid array parameter If !ArrInfo(handle,-1) handle[0,0]=5 ; Invalid array parameter passed. handle[1,0]="gigafile_line_number: Invalid array parameter passed" Return handle EndIf ; !ArrInfo(handle,-1). ; Check if negative line number If line_num < 1 handle[2,0]="*SOF*" ; Start of File. handle[3,0]=0 Return handle EndIf ; Line_num < 1. ; Check for passed EOF If line_num > handle[4,0] handle[2,0]="*EOF*" ; End of File. handle[3,0]=handle[4,0] Return handle EndIf ; Line_num > handle[4,0]. ; Check line number If StrClean(line_num,"0123456789","",@True,1)<>"" handle[0,0]=6 handle[1,0]="Invalid line number passed" Return handle EndIf ; StrClean(line_num,"0123456789","",@True,1)<>"". If handle[12,0] ; Buffer already gotten? buf=handle[12,0] BinaryEodSet(buf,0) ; Reset. Else ; ! handle[12,0]. buf=BinaryAlloc(handle[7,0]) ; Size of original buffer size request. handle[12,0]=buf ; Save buffer address. EndIf ; Handle[12,0]. handle[11,0]=0 handle[6,0]=0 handle[3,0]=0 handle[2,0]="" startto=line_num/1000 If startto*1000<>handle[4,0] Then startto=startto+1 startfrom=ItemExtract(1,handle[14,startto],",") startto=ItemExtract(2,handle[14,startto],",") For x=startfrom To startto ; Find mini file containing this line number. If line_num<=handle[10,x] Then Break ; Line in this mini file. Next ; X=startfrom To startto. handle[6,0]=x ; Mini file # with this line number. If handle[6,0]==1 Then BinaryReadEx(buf,0,handle[13,0],0,handle[8,handle[6,0]]) ; Get chunk of first mini file. Else BinaryReadEx(buf,0,handle[13,0],handle[9,handle[6,0]-1],handle[8,handle[6,0]]) ; Get starting addr of this mini file from previous mini file's total. ; now, trying to find line_num in this chunk of the file. GoSub FINDLINE ; Line 1185 handle[3,0]=line_num ; Set current line line number. handle[2,0]=BinaryPeekStr(buf,fdstart,fdend-fdstart) ; Set current line contents. handle[11,0]=fdend+2 handle[0,0]=0 ; Everying ok. Return handle :FINDLINE ; From 1179 fdstart=0 ; Start of line number scan. fdend=BinaryEodGet(buf)-1 ; End of line number scan. If handle[6,0]==1 Then fdln=line_num Else fdln=line_num-handle[10,handle[6,0]-1] ; Line number relative to this mini file to find. fdend2=fdend fdlncopy=0 fdline=0 While @True fdend2=fdstart+(fdend-fdstart)/2 If fdend2==BinaryEodGet(buf) Then fdline=1 Then Break fdhit=BinaryStrCnt(buf,fdstart,fdend2,@CrLf) ; Find line number from half-way point. If fdhit+fdlncopy==fdln Then Break If fdhit+fdlncopy>fdln fdend=fdend2-1 ; Our line is in the lower half. Else ; ! fdhit+fdlncopy>fdln. fdlncopy=fdlncopy+fdhit fdstart=fdend2+1 EndIf ; Fdhit+fdlncopy>fdln. EndWhile ; @True. If BinaryPeekStr(buf,fdend2,1)==@Lf fdend2=fdend2-2 Else ; ! BinaryPeekStr(buf,fdend2,1)==@Lf. If BinaryPeekStr(buf,fdend2,1)==@Cr fdend2=fdend2-1 Else ; ! BinaryPeekStr(buf,fdend2,1)==@Cr. fdend2=BinaryIndexEx(buf,fdend2,@CrLf,@Backscan,1) If fdend2<1 fdend2=0 fdline=0 Else ; ! fdend2<1. fdend2=fdend2-1 EndIf ; Fdend2<1. EndIf ; BinaryPeekStr(buf,fdend2,1)==@Cr. EndIf ; BinaryPeekStr(buf,fdend2,1)==@Lf. If fdline fdstart=fdend2+2 Else ; ! fdline. If fdend2 < 0 Then fdend2=0 ; Blank line as first line. fdstart=BinaryIndexEx(buf,fdend2,@CrLf,@Backscan,1) If fdstart==-1 Then fdstart=0 Else fdstart=fdstart+2 EndIf ; Fdline. fdend=BinaryIndexEx(buf,fdstart,@CrLf,@Fwdscan,1) If fdend==-1 Then fdend=BinaryEodGet(buf) Return #EndFunction ; Gigafile_line_number. ;*************************************************************************************** ; GigaFile_Find_Text * ;*************************************************************************************** #DefineFunction gigafile_Find_Text(handle,text,start_line,stop_line,col1,col2,case_sens) ;{{{#DefineFunction gigafile_find_text}}} ; From 640 664 673 684 701 ;debugtrace(@on,"c:\xxx.wbt") handle[0,0]=0 handle[1,0]="" ; Check for valid array parameter If !ArrInfo(handle,-1) handle[0,0]=5 ; Invalid array parameter passed. handle[1,0]="gigafile_find_text: Invalid array parameter passed" Return handle EndIf ; !ArrInfo(handle,-1). ; Check line number If StrClean(start_line,"0123456789","",@True,1)<>"" ||StrClean(stop_line,"0123456789","",@True,1)<>"" handle[0,0]=10 handle[1,0]="Invalid start and/or stop line number" Return handle EndIf ; StrClean(start_line,"0123456789","",@True,1)<>"" ||StrClean(stop_line,"0123456789","",@True,1)<>"". ; Check for line number out of range If start_line>handle[4,0] || start_line<0 || stop_line>handle[4,0] || stop_line<0 handle[0,0]=10 handle[1,0]="Invalid start and/or stop line number" Return handle EndIf ; Start_line>handle[4,0] || start_line<0 || stop_line>handle[4,0] || stop_line<0. If start_line==0 && stop_line<>0 Then start_line=1 If stop_line "" || StrClean(col2,"0123456789","",@True,1)<>"" handle[0,0]=11 handle[1,0]="Col1 and/or Col2 number invalid" Return handle EndIf ; StrClean(col1,"0123456789","",@True,1)<>"" || StrClean(col2,"0123456789","",@True,1)<>"". If col1==0 && col2<>0 Then col1=1 If col2 0 || col1>1 Then column_search_needed=1 Else column_search_needed=0 GoSub SETSTARTFILE ; Line 1360 GoSub SETENDFILE ; Line 1373 something_found=0 For x=search_from_file To files_to_search ; Find mini file containing required text. BinaryEodSet(buf,0) ; Reset buffer. search_start=0 If x==1 Then BinaryReadEx(buf,0,handle[13,0],0,handle[8,x]) ; Get chunk of first mini file. Else BinaryReadEx(buf,0,handle[13,0],handle[9,x-1],handle[8,x]) ; Get starting addr of this mini file from previous mini file's total. If starting_offset_needed Then GoSub FINDSTARTINGOFFSET ; For line range find starting offset. ; Line 1386 If ending_offset_needed && x==files_to_search Then GoSub FINDENDINGOFFSET ; Get offset for ending line range in ending mini file. ; Line 1393 search_start=BinaryIndexEx(buf,search_start,text,@Fwdscan,case_sens) ; Find text. If search_start==-1 Then Continue ; Nothing found, perhaps in next mini file. GoSub FOUNDTEXT ; Get line containing search text. ; Line 1400 If column_search_needed GoSub SCANCOLUMNS ; Search rest of mini file for text in columns. ; Line 1346 Else ; ! column_search_needed. something_found=1 EndIf ; Column_search_needed. If something_found Then Break ; We found something in this mini file. Next ; X=search_from_file To files_to_search. If !something_found ; Text not found. handle[0,0]=14 ; Set error message. handle[1,0]="Text not found" ; Set error text. BinaryEodSet(buf,0) ; Clear buffer. handle[3,0]=0 ; Reset current line number - i.e. start anew. handle[6,0]=0 ; Clear current mini file indicator. Return handle EndIf ; !something_found. BinaryEodSet(buf,0) ; Clear. If x==1 Then BinaryReadEx(buf,0,handle[13,0],0,handle[8,x]) ; Reload worked on mini file. Else BinaryReadEx(buf,0,handle[13,0],handle[9,x-1],handle[8,x]) ; Get starting addr of this mini file from previous mini file's total. handle[2,0]=found_text ; Provide line with search text. handle[6,0]=x ; Current mini file. handle[3,0]=BinaryStrCnt(buf,0,search_start,@CrLf)+1 ; Find line number for searched line relative to mini file. If handle[6,0]<>1 Then handle[3,0]=handle[3,0]+handle[10,handle[6,0]-1] ; Real line containing searched text. x=BinaryIndexEx(buf,search_start,@CrLf,@Fwdscan,1) ; Get end of searched line - set up for possible next line request. If x==-1 Then handle[11,0]=BinaryEodGet(buf) ; End of file. Else handle[11,0]=x+2 ; New offset for next line. Return handle :SCANCOLUMNS ; Keep scanning for text in this mini file. ; From 1321 While @True If col2==0 Then endcolumn=StrLen(found_text) ; Last column in line if no end column specified. Else endcolumn=col2 If StrIndexNc(StrSub(found_text,col1,endcolumn-col1+1),text,1,@Fwdscan) something_found=1 ; Flag column search successful. Break EndIf ; StrIndexNc(StrSub(found_text,col1,endcolumn-col1+1),text,1,@Fwdscan). search_start=search_start+1 ; New scanning point. search_start=BinaryIndexEx(buf,search_start,text,@Fwdscan,case_sens) ; Find text. If search_start==-1 Then Break ; Nothing found, perhaps in next mini file. GoSub FOUNDTEXT ; New line to column scan. ; Line 1400 EndWhile ; @True. Return :SETSTARTFILE ; From 1307 If start_line>1 ; Line range search required? startto=start_line/1000 If startto*1000<>handle[4,0] Then startto=startto+1 startfrom=ItemExtract(1,handle[14,startto],",") startto=ItemExtract(2,handle[14,startto],",") For xx=startfrom To startto ; No of mini files to search containing start line no. If start_line<=handle[10,xx] Then Break ; Requested start line in this mini file? Next ; Xx=startfrom To startto. search_from_file=xx ; Starting mini file to search. starting_offset_needed=1 ; Set flag. EndIf ; Start_line>1. Return :SETENDFILE ; From 1308 If stop_line>1 ; Stop searching at a line requested? startto=stop_line/1000 If startto*1000<>handle[4,0] Then startto=startto+1 startfrom=ItemExtract(1,handle[14,startto],",") startto=ItemExtract(2,handle[14,startto],",") For xx=startfrom To startto If stop_line<=handle[10,xx] Then Break ; Requested stop line in this mini file? Next ; Xx=startfrom To startto. files_to_search=xx ; Ending mini file to search. ending_offset_needed=1 EndIf ; Stop_line>1. Return :FINDSTARTINGOFFSET ; Because of line range search. ; From 1315 starting_offset_needed=0 ; Reset. If x==1 Then fdln=start_line Else fdln=start_line-handle[10,x-1] ; Line number relative to this mini file to find. GoSub FINDLINE ; Get offset of this line in current mini file. ; Line 1408 search_start=search_start2 Return :FINDENDINGOFFSET ; Because of ending line to search request. ; From 1316 ending_offset_needed=0 ; Reset. If x==1 Then fdln=stop_line Else fdln=stop_line-handle[10,x-1] ; Line number relative to this mini file to find. GoSub FINDLINE ; Get ending offset of this line in current mini file. ; Line 1408 BinaryEodSet(buf,search_end) ; Truncate buffer to end offset for the to line search. Return :FOUNDTEXT ; From 1319 1357 xx=BinaryIndexEx(buf,search_start,@CrLf,@Backscan,1) ; Get start of line. If xx==-1 Then found_text=BinaryPeekStr(buf,0,search_start) ; Copy up to text. Else found_text=BinaryPeekStr(buf,xx+2,search_start-xx-2) ; Copy up to text. xx=BinaryIndexEx(buf,search_start,@CrLf,@Fwdscan,1) ; Get end of line. If xx==-1 Then found_text=StrCat(found_text,BinaryPeekStr(buf,search_start,BinaryEodGet(buf)-search_start)) ; Append rest of line. Else found_text=StrCat(found_text,BinaryPeekStr(buf,search_start,xx-search_start)) ; Append rest of line. Return :FINDLINE ; From 1390 1397 fdstart=0 ; Start of line number scan. fdend=BinaryEodGet(buf)-1 ; End of line number scan. fdend2=fdend fdlncopy=0 fdline=0 While @True fdend2=fdstart+(fdend-fdstart)/2 If fdend2==BinaryEodGet(buf) Then fdline=1 Then Break fdhit=BinaryStrCnt(buf,fdstart,fdend2,@CrLf) ; Find line number from half-way point. If fdhit+fdlncopy==fdln Then Break If fdhit+fdlncopy>fdln fdend=fdend2-1 ; Our line is in the lower half. Else ; ! fdhit+fdlncopy>fdln. fdlncopy=fdlncopy+fdhit fdstart=fdend2+1 EndIf ; Fdhit+fdlncopy>fdln. EndWhile ; @True. If BinaryPeekStr(buf,fdend2,1)==@Lf fdend2=fdend2-2 Else ; ! BinaryPeekStr(buf,fdend2,1)==@Lf. If BinaryPeekStr(buf,fdend2,1)==@Cr fdend2=fdend2-1 Else ; ! BinaryPeekStr(buf,fdend2,1)==@Cr. fdend2=BinaryIndexEx(buf,fdend2,@CrLf,@Backscan,1) If fdend2<1 fdend2=0 fdline=0 Else ; ! fdend2<1. fdend2=fdend2-1 EndIf ; Fdend2<1. EndIf ; BinaryPeekStr(buf,fdend2,1)==@Cr. EndIf ; BinaryPeekStr(buf,fdend2,1)==@Lf. If fdline fdstart=fdend2+2 Else ; ! fdline. If fdend2 < 0 Then fdend2=0 ; Blank line as first line. fdstart=BinaryIndexEx(buf,fdend2,@CrLf,@Backscan,1) If fdstart==-1 Then fdstart=0 Else fdstart=fdstart+2 EndIf ; Fdline. fdend=BinaryIndexEx(buf,fdstart,@CrLf,@Fwdscan,1) If fdend==-1 Then fdend=BinaryEodGet(buf) search_start2=fdstart search_end=fdend Return #EndFunction ; Gigafile_find_text. ;*************************************************************************************** ; GigaFile_Previous_line * ;*************************************************************************************** #DefineFunction gigafile_Previous_Line(handle) ;{{{#DefineFunction gigafile_Previous_Line}}} ; From 479 480 503 506 509 510 ; Check for valid array parameter If !ArrInfo(handle,-1) handle[0,0]=5 ; Invalid array parameter passed. handle[1,0]="gigafile_previous_line: Invalid array parameter passed" Return handle EndIf ; !ArrInfo(handle,-1). ; Check if already at the beginning If handle[3,0]<2 || handle[12,0]==0 handle[2,0]="*SOF*" ; Start of File. handle[3,0]=0 Return handle EndIf ; Handle[3,0]<2 || handle[12,0]==0. ; Get next line handle[0,0]=0 ; Reset. handle[1,0]="" ; Clear any error message. buf=handle[12,0] ; Use buf variable to access buffer contents. current_offset=handle[11,0] ; handle[11,0] is offset to start of next line. We have to go back two lots of @crlf to get to the previous record. current_offset=BinaryIndexEx(buf,current_offset,@CrLf,@Backscan,1) ; Get to end of current line. If current_offset==-1 GoSub PREVIOUSMINIFILE ; Start of current mini file? ; Line 1496 current_offset=BinaryIndexEx(buf,current_offset,@CrLf,@Backscan,1) EndIf ; Current_offset==-1. ; At end of data of current line. current_offset=BinaryIndexEx(buf,current_offset,@CrLf,@Backscan,1) ; Get to end of previous line. If current_offset==-1 GoSub PREVIOUSMINIFILE ; Start of current mini file? ; Line 1496 current_offset=BinaryIndexEx(buf,current_offset,@CrLf,@Backscan,1) EndIf ; Current_offset==-1. ; At end of previous line we want. pre=BinaryIndexEx(buf,current_offset,@CrLf,@Backscan,1) ; Find start of our previous line. If pre==-1 Then pre=0 ; Our previous record is the first in the mini buffer. Else pre=pre+2 ; Start of our previous record. GoSub EXTRACTLINE ; Line 1504 handle[3,0]=handle[3,0]-1 ; Set previous line number. Return handle :PREVIOUSMINIFILE ; From 1480 1486 BinaryEodSet(buf,0) ; Reset mini file buffer. handle[6,0]=handle[6,0]-1 ; Previous mini file id. If handle[6,0]==1 Then BinaryReadEx(buf,0,handle[13,0],0,handle[8,1]) ; Load first mini file. Else BinaryReadEx(buf,0,handle[13,0],handle[9,handle[6,0]-1],handle[8,handle[6,0]]) ; Get starting addr of this mini file from previous mini file's total. handle[11,0]=BinaryEodGet(buf) current_offset=handle[11,0] Return :EXTRACTLINE ; From 1493 x=BinaryIndexEx(buf,pre,@CrLf,@Fwdscan,1) ; Find EOL indicator. If x==-1 handle[2,0]=BinaryPeekStr(buf,pre,BinaryEodGet(buf)-pre) ; Retrieve EOLless line. handle[11,0]=BinaryEodGet(buf) ; End of file. Else ; ! x==-1. handle[2,0]=BinaryPeekStr(buf,pre,x-pre) ; Copy line data less @CrLf. handle[11,0]=x+2 ; New offset for next line. EndIf ; X==-1. Return #EndFunction ; Gigafile_previous_line. ;*************************************************************************************** ; GigaFile_Last_Line * ;*************************************************************************************** #DefineFunction gigafile_Last_Line(handle) ;{{{#DefineFunction gigafile_Last_Line}}} ; From ? ; Check for valid array parameter If !ArrInfo(handle,-1) handle[0,0]=5 ; Invalid array parameter passed. handle[1,0]="gigafile_last_line: Invalid array parameter passed" Return handle EndIf ; !ArrInfo(handle,-1). ; Get last line handle[0,0]=0 ; Reset. handle[1,0]="" ; Clear any error message. buf=handle[12,0] ; Use buf variable to access buffer contents. BinaryEodSet(buf,0) ; Clear buffer. handle[6,0]=handle[5,0] ; Last mini file id. If handle[6,0]==1 Then BinaryReadEx(buf,0,handle[13,0],0,handle[8,1]) ; Load first mini file. Else BinaryReadEx(buf,0,handle[13,0],handle[9,handle[6,0]-1],handle[8,handle[6,0]]) ; Get starting addr of this mini file from previous mini file's total. handle[11,0]=BinaryEodGet(buf) ; handle[11,0] is offset to end of last line. We have to go back one lots of @crlf if @Crlf is last data, or up to first @Crlf for start of last line. If BinaryEodGet(buf)<2 pre=0 ; Last line has no @crlf. Else ; ! BinaryEodGet(buf)<2. If BinaryPeekStr(buf,BinaryEodGet(buf)-2,2)==@CrLf ; Last line has @Crlf. pre=BinaryIndexEx(buf,BinaryEodGet(buf)-2,@CrLf,@Backscan,1) ; Find start of last line with a close @Crlf. Else ; ! BinaryPeekStr(buf,BinaryEodGet(buf)-2,2)==@CrLf. pre=BinaryIndexEx(buf,BinaryEodGet(buf)-1,@CrLf,@Backscan,1) ; Find start of last line with no closing @Crlf. EndIf ; BinaryPeekStr(buf,BinaryEodGet(buf)-2,2)==@CrLf. EndIf ; BinaryEodGet(buf)<2. ; At start of last line If pre==-1 Then pre=0 ; Last line is the first in the mini buffer. Else pre=pre+2 ; Point at start of last line. GoSub EXTRACTLINE ; Line 1550 handle[3,0]=handle[4,0] ; Total line count is now last line. Return handle :EXTRACTLINE ; From 1547 x=BinaryIndexEx(buf,pre,@CrLf,@Fwdscan,1) ; Find EOL indicator. If x==-1 handle[2,0]=BinaryPeekStr(buf,pre,BinaryEodGet(buf)-pre) ; Retrieve EOLless line. Else ; ! x==-1. handle[2,0]=BinaryPeekStr(buf,pre,x-pre) ; Copy line data less @CrLf. EndIf ; X==-1. Return #EndFunction ; Gigafile_last_line. #DefineFunction gigafile_Min(a,b) ; From 983 If gigafile_Compare(a,b) == 1 Then x=b ; Line 1564 Else x=a Return x #EndFunction ; Gigafile_min. #DefineFunction gigafile_Compare(a,b) ; From 977 1560 AddExtender("WWHUG34I.DLL") c=huge_Subtract(a,b) If StrSub(c,1,1)=="-" x=-1 Else ; ! StrSub(c,1,1)=="-". If c=="0" Then x=0 Else x=1 EndIf ; StrSub(c,1,1)=="-". Return x #EndFunction ; Gigafile_compare. Return ;********************************************************************** ; _DebugWizard Call(StrCat(DirHome(),"DebugWizard.wbt"),"")
Article ID: W16747
File Created: 2005:02:18:12:22:12
Last Updated: 2005:02:18:12:22:12