// WILDFILEW.WDM (WildFile for Windows) - Process entire groups of files. // // By: Pauli Lindgren 2006-08-10 // Based on wildfwiz.vdm (Wildfile wizard} by Ted Green, Greenview Data, Inc. // Last change: 2007-12-05 v1.8 // // Requires: VEDIT 6.10 or later. // // Description: Perform a Search/Replace, any command sequence, or run any // macro on an entire group of files, e.g. "*.txt", "*.c". // Subdirectories may also be searched. // ///////////////////////////////////////////////////////////////////////////// // // // @40 + Name of the file for saving settings (wildfilw.ini) // #41 + 1 = Enable saving ini file // #42 + tmp // #43 + Current dialog box type (simple/full) // #44 + Option: Startup dialog: 1 = search, 2 = last used // #45 + Option: Dialog box type: 1 = simple dialog, 2 = full dialog, 0 = no dialogs (batch mode) // #46 + Option: default directory: 1 = cur_dir, 2 = current file's dir, 3 = last used // #47 + Option: default search/replace strings: 1 = none, 2 = current, 3 = last used // #48 + Option: default search options: 1 = config, 2 = last used // #50 + Saved search options // #51 + Skip Comments option // #52 + Saved "Open as Read Only" flag // #53 + Saved "Pause after screenful" tickbox for 'C' and 'M' // #54 + T-Reg for saved Search string // #55 + T-Reg for saved Replace string // #56 + T-Reg for saved command sequence for 'C' operation // #57 + T-Reg for saved macro pathname for 'M' operation // #58 For search/replace 'D' or 'E': last line # displayed // #59 For search/replace 'D' or 'E': line to be displayed // For macro/nommand: save cursor position before call // #60 Number of files to process (for info only) // #61 Edit buffer for search result listing // #62 Number of files where text was found. // #63 Dialog: "Display matched lines as" radio buttons // Execute: Number of occurrences found // #64 Dialog: "Matched lines" radio buttons in Replace dialog // Execute: Number of lines with occurrences // #65 Temp buffer, currently XBUF1 // #66 Temp buffer, currently XBUF2 // #67 T-Reg # for saving current directory // #68 Dispose-last-file radio button // #69 Flag to allow quick return to VEDIT // #70 Selected operation: 'S', 'R', 'C', 'M' // #71 Subdirectories flag. Execution: flag for counting filenames in main processing loop // #72 Column # for status line messages // #73 T-Reg for custom processing // #74 [V]isual, [D]isplay or [E]xtract flag. // #75 * Tmp for dialog box etc. // #76 Save original Zoom value // #77 Name of any bottom-reserved window // #78 Number of lines in any bottom-reserved window // #79 Border type in any bottom-reserved window // #80 T-Reg # containing this macro // #81 Value of parent's locked-in macro // #82 Original buffer # // #83 Original window # // #84 Save state of "Enable file open/close macro", later T-Reg for line comment string // #85 Save state of "Enable -MORE- operation", later T-Reg for block comment strings // #86 Save state of Visual_Macro // #87 Edit-buffer # for file being edited/searched, // During filename processing: Save/restore file position // #88 State of SR_CASE_OPT and SR_MODE_OPT (Search Case,Mode) // #89 T-Reg # for holding locked-in macro // #90 Edit-buffer # for editing each file not already open // #91 * T-Reg # for user-supplied wildnames; execution: pathname of file being processed // #92 * T-Reg # for default path - Later T-Reg holding processing macro // #93 T-Reg # for holding search string in dialog box // During filename processing: full drive:pathname // #94 T-Reg # for holding replace string in dialog box // * During filename processing: "\" for DOS, "/" for UNIX // #95 * T-Reg # for holding macro executed for each file // #96 * T-Reg # to hold current driver macro/filename // #97 * Flag - break-out operation // #98 * Flags for user macro: 0=1st call, 1=running, 2=last file or cancel, 4=no end dialog, 8=keep file open, 0x10=search.tmp used // #99 Flag - 0x57495C44 ("WILD") when macro is running // #100 Filename position marker // @104 Dialog: focus on file field // @105 Dialog: focus on search field; Filename processing: List of existent wildnames // @106 Dialog: focus on replace field; Filename processing: List of nonexistent wildnames // ////////////////////////////////////////////////////////////////////////////// // // Init - 1) Save state // 2) Use configured search mode (Simple, Pattern, Reg-Exp) // 3) Determine free buffers/T-Regs // Reg_Set(40,"|(USER_MACRO)\wildfilw.ini") // file for saved settings :set_ini: //Entry point when filename for settings given in T-Reg 40 #41 = 1 // enable saving settings goto BEGIN :read_ini: #41 = 0 // disable saving settings :BEGIN: if (!Is_Win32) { Alert() Get_Key("WILDFWIZ.VDM only works with the 32-bit Windows version of VEDIT.",STATLINE) return } if (#99==0x57495C44) { Goto VMAIN } //Skip init if macro already running if (OS_Type != 1 || Version_Num < 610) { //Ensure Windows VEDIT version 6.10 or later is running Alert() DI1(0,"`Sorry!`, `WILDFWIZ.VDM requires Windows VEDIT version 6.10 or later`") Break_Out(EXTRA) } Num_Push(41,100) //Save numeric regs [ #44 = 1 //Option: Start at Search dialog #45 = 1 //Option: Simple dialog box #46 = 3 //Option: default directory = last used by wildfilew.vdm #47 = 3 //Option: default search string = last used by wildfilew.vdm #48 = 2 //Option: default search options = last used by wildfiew.vdm #51 = 0 //Skip comments option #68 = 0 //Last-file-disposition radio button #63 = 2 //"Matched lines" radio button = List matches #64 = 1 //"Matched lines" in replace dialog = Confirm #71 = 0 //subdirectories flag in dialog box #80 = Macro_Num //#80 = T-Reg containing this macro #81 = Reg_Lock_Macro //#81 = parent's locked-in macro (0=none) #82 = Buf_Num //#82 = original buffer #83 = Win_Num //#83 = original window # (maybe status line!) #84 = Config(F_E_F_MACRO,0) //#84 = original Config value; disable #85 = Config(S_E_MORE,0) //#85 = original Config value; disable #86 = Visual_Macro //#86 = save state of Visual_Macro Num_Push(84,86) //Save numeric regs for saved values [ // // Get default search options from config settings // #88 = 0 //Assume pattern matching, not case sensitive if (Config(SR_MODE_OPT)==0) { #88 += SIMPLE } if (Config(SR_MODE_OPT)>=2) { #88 += REGEXP } if (Config(SR_MODE_OPT)==3) { #88 += MAX } if (Config(SR_CASE_OPT)) { #88 += CASE } if (Config(D_DSP_MODE)&128) { #88 += EBCDIC } #50 = #88 //Saved search options // // #76 = Zoom_Status //#76 = window zoom status #77 = 0 //Assume no reserved windows if (#102!=0x44454D4F) { //Only if tutor macro not running... if (#77=Win_Reserved_Bottom_ID) { //If reserved bottom window... Win_Switch(#77) //Switch to it #78 = Win_Lines //#78 = lines in it #79 = Win_Border //#79 = # border lines in it Win_Delete() //Delete it Win_Switch(#83) //Switch back to original window } } #61 = -1 //Buffer for search results, -1 = not open #65 = XBUF1 //Extra buffer for "temp" #66 = XBUF2 //Extra buffer for "temp" #69 = !Is_Auto_Execution //Allow quick exit unless run from command line Reg_Set(#89=Reg_Free," ") //#89 = Reserve T-reg for locked-in macro #91=Reg_Free //#91 = Reserve T-Reg for filename //Ensure T-Reg #91,#92, #93 and #94 are adjacent (for dialog box) while (Reg_Size(#91) || Reg_Size(#91+1) || Reg_Size(#91+2) || Reg_Size(#91+3)) { #91++ } #92=#91+1; #93=#91+2; #94=#91+3 Reg_Set(#91," ") //#91 = Reserve T-Reg for filename Reg_Set(#92," ") //#92 = Reserve T-Reg for default path Reg_Set(#93," ") //#93 = Reserve T-Reg for search string Reg_Set(#94," ") //#94 = Reserve T-Reg for replace string Reg_Set(#95=Reg_Free," ") //#95 = Reserve T-reg for operation macro Reg_Set(#96=Reg_Free," ") //#96 = Reserve T-Reg for processing macro Reg_Set(#73=Reg_Free," ") //#73 = Reserve T-Reg for custom processing Reg_Set(#67=Reg_Free," ") //#67 = Reserve T-Reg for current directory Reg_Set(#54=Reg_Free," ") //#54 = Reserve T-Reg for saved search string Reg_Set(#55=Reg_Free," ") //#55 = Reserve T-Reg for saved replace string Reg_Set(#56=Reg_Free," ") //#56 = Reserve T-Reg for saved command sequence for 'C' Reg_Set(#57=Reg_Free," ") //#57 = Reserve T-Reg for saved macro name for 'M' Reg_Set(#84=Reg_Free,"//") //#84 = Reserve T-Reg for line comment search string Reg_Set(#85=Reg_Free,"|{/*,*/}") //#85 = Reserve T-Reg for block comment search string Reg_Set(#91,"*.*") //default file filter Reg_Set(#92,PATH_ONLY) //default path = current file's path Reg_Empty(#54) Reg_Empty(#55) Reg_Empty(#56) Reg_Empty(#57) Call("READ_SETTINGS") //Read saved settings from .ini file Call("SET_DEFAULT_DIR") //Start-up option if (#44==1) { #70 = 'S' } //start at Search dialog #43 = #45 //get stored dialog box type (simple/full) if (#47==1) { //option: search string = empty Reg_Empty(#54) Reg_Empty(#55) } if (#47==2) { //option: search string = current Buf_Switch(#65) Buf_Empty(OK) Out_Ins() #75 = SR_Display() Out_Ins(CLEAR) BOF Char(4) RCB(#54,Cur_Pos,EOL_pos-1) //search string if (#75==2) { Line(1) Char(4) RCB(#55,Cur_Pos,EOL_pos-1) //replace string } Buf_Quit(OK) } Reg_Empty(#95) // Reg_Empty(105) // Reg_Empty(106) // // Use any small highlighted block as default search string. // if ((BE-BB > 0) && (BE-BB<50)) { Reg_Copy_Block(#54,BB,BE) if (Config(D_DSP_MODE)&128) { //If in EBCDIC mode... Buf_Switch(XBUF3) //Switch to temp buffer Reg_Ins(#54) Translate_Block(0,File_Size,REVERSE) //Translate EBCDIC to ASCII Reg_Copy_Block(#54,0,File_Size) Buf_Quit(OK) Buf_Switch(#82) } } Buf_Switch(#90=Buf_Free) //#90 = buffer for editing files IT(" ") //insert something to tmp buffer to allow opening new buffer Buf_Switch(#82) //Back to original buffer ////////////////////////////////////////////////////////////////////////// // // // Set "Locked-in" macro #89 to catch break-outs and exit macro. // // // ////////////////////////////////////////////////////////////////////////// Reg_Set(#89,^ Reg_Lock_Macro(CLEAR) // PL allow exit from locked macro in case of error Buf_Switch(#66,LOCAL) Buf_Quit(OK) //Quit any temp file Buf_Switch(#65,LOCAL) Buf_Quit(OK) //Quit any temp file Win_Delete('h') //Delete any 'h' window #68 = 0 //Last-file-disposition radio button //if (#102==0x44454D4F) { Goto EXIT } //Exit if tutor macro is running if (#69) { Goto EXIT } //Exit if [CANCEL] 1st dialog box Reg_Empty(103) // // Dispose of any unaltered, non-user-loaded file. // Gets rid of blank tab from the tab bar. // Reg_Push(1,3) // Save and empty T-Regs Num_Push(0,0) // [ Reg_Set(103,"`.cDone\n`,") if ((#74=='V') || (#74=='D') || (#74=='E') || (#74=='C') || (#74==0) || (#74=='F')) { // // Show number of occurrences found (PL) // if (#70 == 'R') { Reg_Set(3,"Replaced: ") } else { Reg_Set(3,"Found: ") } Num_Str(#63,2,LEFT) // number of occurrences found Reg_Set(3,@2,APPEND) Reg_Set(3, " occurrences in ",APPEND) if (#74 > 0) { // if "All" selected, line count not known Num_Str(#64,2,LEFT) // number of lines with occurrences Reg_Set(3,@2,APPEND) Reg_Set(3, " lines in ",APPEND) } Num_Str(#62,2,LEFT) // number of files with occurrences Reg_Set(3,@2,APPEND) Reg_Set(3," files",APPEND) Reg_Empty(2) } if (((#74=='D') || (#74=='E') || (#74=='F')) && #97==0) { // Search with Display/Extract option Buf_Switch(#61) // Write number of occurences into search.tmp BOF Line(1) Reg_Ins(3) // Update() } if (#82 != #90) { // if tmp buffer doesn't contain file that user macro asked to keep open Buf_Switch(#90) if (!Is_Altered) { Buf_Quit(OK+DELETE) Buf_Switch(#82) } else { Reg_Set(1,"`.\Regarding ") Reg_Set(1,PATHNAME,APPEND) Reg_Set(1,":`,",APPEND) Reg_Set(2,"`()&Keep open`,`.h.i()&Save`,`.h()&Abandon`,") #68 = 2 // Set 2nd radio button (Save) } } if (#97==1) { Alert() Reg_Set(103,"`.cBREAK-OUT!`,") } // if visual option, user macro or break-out, show dialog #0 = #68 if ((#74=='V') || (#74=='C') || (#74=='M') || (#74==0) || (#97==1)) { Reg_Set(3,"`\t",INSERT) Reg_Set(3,"\t\t\n`,",APPEND) #75 = DI1(0,"`Wildfilew - Multifile Processing`, |@(103)|@(3)|@(1)|@(2) `[&OK]`", SCREEN+CENTER,-20,-20) } #68 = #0 Num_Pop(0,0) // ] Reg_Pop(1,3) //if (#75==2) { Chain(#80) } //if (#75==3) { Exit() Chain(#80) } if ((#43==0) && (#98 & 0x18 == 0)) { // batch operation, exit Vedit Buf_Switch(#61) File_Save(NOMSG+BEGIN) //Save search result // Exit() Chain(#80) } // // Exit - Restore state before returning. // :EXIT: if ((#98 & 8) == 0) { //if user macro did not ask to keep file open Call(#80,"SAVELAST") //Save or abandon last file, if any //Switches to buffer #90 if (#68==0) { if (Config(WIN_AUTO_CRE)) { //Probably need to delete attached window Buf_Quit(DELETE) //Close buffer and window } else { Buf_Quit() } //Else just close buffer } } // //Win_Delete('h') //Delete help window if (#77) { //Restore original reserved bottom window... if (#79==0) { Win_Reserved(#77,#78,BOTTOM+NOBORDER) } else { if (#79==1) { Win_Reserved(#77,#78,BOTTOM+MINBORDER) } else { Win_Reserved(#77,#78,BOTTOM) } } } Win_Zoom(#76) //Restore window zoom state Buf_Switch(#66,LOCAL) Buf_Quit(OK) Buf_Switch(#65,LOCAL) Buf_Quit(OK) if ((#74=='D') || (#74=='E') || (#74=='F') || ((#98 & 0x10))) { // Search with Display/Extract option or user macro uses search.tmp Buf_Switch(#61) File_Save(NOMSG+BEGIN) //Save search result Update() } else { // if ((#98 & 8) == 0) { //if user macro did not ask to keep file open Buf_Switch(#82,LOCAL) //Return to original buffer Win_Switch(#83) //Return to original window // } if (#74 != 0) { //Not cancel if (#61 > 0) { Buf_Switch(#61) //User macro didn't use search.tmp Buf_Quit(OK) } } } Chdir(@(#67)) //Restore original "current" directory Reg_Empty(#54) Reg_Empty(#55) Reg_Empty(#56) Reg_Empty(#57) Reg_Empty(#67) Reg_Empty(#73) //Empty custom post-processing macro Reg_Empty(#80,EXTRA) //Empty register with main macro Reg_Empty(#84) Reg_Empty(#85) Reg_Empty(#91) Reg_Empty(#92) Reg_Empty(#93) Reg_Empty(#94) Reg_Empty(#95) Reg_Empty(#96) Reg_Empty(103) Reg_Empty(104) Reg_Empty(105) Reg_Empty(106) #98 = 0 Num_Pop(84,86) //Restore numeric regs for saved values ] Config(F_E_F_MACRO,#84) //Restore original Config values Config(S_E_MORE,#85) if (#86) { Visual_Macro(SET+NOMSG) //Return to Visual Mode; no Pause } else { Visual_Macro(CLEAR) } Reg_Lock_Macro(#81) //Restore any previous locked-in macro Num_Pop(41,100) //Restore numeric regs ] return(1,DELETE) //Empty this T-Reg; return ^) ////////////////////////////////////////////////////////////////////////// // // // Start Main Processing // // // ////////////////////////////////////////////////////////////////////////// :VMAIN: Call("SAVELAST") //Save or abandon last file, if any //In case of restart following Break-out #97=1 //Enable "BREAKOUT" message #99=0x57495C44 //Macro is now running ("WILD") Visual_Macro(CLEAR) //Don't return to Visual Mode on break-out ////////////////////////////////////////////////////////////////////////// // // // Setup null custom postprocessing macro for each file processed. // // // ////////////////////////////////////////////////////////////////////////// Reg_Set(#73,` Return //Remove this line to activate following macro // // For example - The following submacro changes the filename extension to // ".MOD" if and only if the file was modified. // if (Is_Altered==0) { Return } Reg_Set(103,PATHNAME) Buf_Switch(XBUF3) Buf_Empty(OK) Reg_Ins(103,BEGIN) Replace("{.+}\..+","\1.MOD",REGEXP+NOERR) Reg_Copy_Block(103,0,EOB_Pos) Buf_Quit(OK) Buf_Switch(#90) File_Save_As(@103,OK) Return `) ////////////////////////////////////////////////////////////////////////// // // // Start building main macro WildFile.tmp in extra buffer #66. // // // ////////////////////////////////////////////////////////////////////////// Buf_Switch(#65) Buf_Quit(OK) //#65 is used as temp buffer Buf_Switch(#66) Buf_Quit(OK) //#66 is used to build Wildfile.tmp //Close it to ensure it is re-opened with // EXTRA memory Buf_Switch(#66,EXTRA) //Open extra Buffer(#66) with EXTRA memory // if (File_Exist(VEDIT_TEMP)==0) { //Create vedit/temp dir if needed File_Mkdir(VEDIT_TEMP) } if (OS_Type==1) { File_Delete("|(VEDIT_TEMP)/ved|(PID).wild.tmp",OK+NOERR) File_Open(*"|(VEDIT_TEMP)/ved|(PID).wild.tmp"*,FORCE+NOMSG) //Open temp file; force in temp buffer } else { File_Delete("|(VEDIT_TEMP)/wildfile.tmp",OK+NOERR) File_Open(*"|(VEDIT_TEMP)/wildfile.tmp"*,FORCE+NOMSG) } Config(F_F_TYPE,1,LOCAL) //Ensure not record-mode // Reg_Lock_Macro(#89,EXTRA) //Enable Break-out macro // // Set default options from Config() values. // Num_Push(#91,#91+5) #100=#91 #@100 = #71; #100++ // subdirectorires flag if (#48==2) { #88 = #50 // use saved search options } else { #51 = 0 // skip comments = no } #@100 = ((#88 & CASE) > 0); #100++ #@100 = ((#88 & WORD) > 0); #100++ #@100 = #51; #100++ // skip comments #@100 = 2 // search mode radio button = Pattern if (#88 & SIMPLE) {#@100 = 1} if (#88 & REGEXP) {#@100 = 3} if (#88 & MAX) {#@100 = 4} Reg_Set(#67,CUR_DIR) // Save current directory Buf_Switch(#90) // Tabbar complication: don't want new Buf_Quit(OK) // empty tab displayed // Go to selected startup dialog, or continue after "no files found". if ((#70 == 'C') || (#70 == 'M')) { goto MACRO_DIALOG } ////////////////////////////////////////////////////////////////////////// // // // SEARCH / REPLACE DIALOG // // // ////////////////////////////////////////////////////////////////////////// :SEARCH_DIALOG: Reg_Set(#93, @(#54)) // restore saved search string Reg_Set(#94, @(#55)) // restore saved replace string if (#70=='S') { #74 = #63 // Radio button for Visual/List/Extract option } else { #74 = #64 // Radio button for Visual/List option } #100=#91+5 #@100 = #74 if (#43==0) { #75 = 2 // say OK clicked goto SKIP_SDIALOG } // Select which input field has focus: Reg_Empty(104) Reg_Empty(105) Reg_Empty(106) if (Reg_Size(#91)==0) { // filename string empty? Reg_Set(104, ".i") // yes, set focus to filename field } else { Reg_Set(105, ".i") // set focus to search field } if (#70=='S') { // Search dialog if (#43==2) { // full dialog box Reg_Set(103," `.v.l.b[Ok]`,`.h.l[Cancel]`,`.l[&Replace... ]`,`.l[Less <<]`, `.v.l[&View]`,`.h.l[&Options]`,`.l[&Help ]`, `Select operation:`, `.v.l[SEARCH]`,`.h.l[Replace]`,`.l[ Command ]`,`.l[Macro]`, ") } else { // simple dialog box Reg_Set(103," `.v.l.b[Ok]`,`.h.l[Cancel]`,`.l[ &Replace... ]`,`.l[ &More >> ]`, ") } #75 = DI1(#91,^`Wildfile for Windows - Search`, `Enter list of filenames to process, separated by commas. The wildcards "?" and "*" may be used.`, `|@(104)??&Files: `, `??&Directory:`, `[]Search s&ubdirectories`,`.h.r[Browse]`, `|@(105)??&Search: `, `[]&Case sensitive `, `.h[]&Word `, `.h[]S&kip comments`, `Search mode: \t\t Display matched lines as: `, `.l.g()S&imple`, `()Pa&ttern`, `()Regular &Expressions `, `()Reg-Exp (M&ax)`, `.g.h.l()&Visual / edit `, `()&List with filenames`, `()E&xtract w/o filenames`, `()List file&names only`, |@(103)^, APP+CENTER+TOP+SET,0,140) } else { // 'R' - Replace dialog if (Reg_Size(#91) && Reg_Size(#93)) { // 'Files' and 'Search' fields already filled? Reg_Empty(105) // yes, set focus to replace field Reg_Set(106, ".i") } if (#43==2) { // full dialog box Reg_Set(103," `.v.l.b[Ok]`,`.h.l[Cancel]`,`.l[Search...]`,`.l[Less <<]`, `.v.l[&View]`,`.h.l[&Options]`,`.l[&Help ]`, `Select operation:`, `.v.l[Search]`,`.h.l[REPLACE]`,`.l[ Command ]`,`.l[Macro]`, ") } else { // simple dialog box Reg_Set(103," `.v.l.b[Ok]`,`.h.l[Cancel]`,`.l[ Search... ]`,`.l[ &More >> ]`, ") } #75 = DI1(#91,^`Wildfile for Windows - Search & Replace`, `Enter list of filenames to process, separated by commas. The wildcards "?" and "*" may be used.`, `|@(104)??&Files: `, `??&Directory:`, `[]Search s&ubdirectories`,`.h.r[Browse]`, `|@(105)??&Search: `, `|@(106)??&Replace: `, `[]&Case sensitive `, `.h[]&Word `, `.h[]S&kip comments`, `Search mode: \t\t Display matched lines as:`, `.l.g()S&imple`, `()Pa&ttern`, `()Regular &Expressions `, `()Reg-Exp (M&ax)`, `.g.h.l()Co&nfirm each replace`, `()&List matched lines/filenames`, |@(103)^, APP+CENTER+TOP+SET,0,107) } // [Cancel] or . if ( #75 == 0 || #75 == 3 ) { Num_Pop(#91,#91+5) #74 = 0 // do not close search results window Chain(#89) // Chain to Break-out/exit macro } :SKIP_SDIALOG: // Save radio button value in case mode changes #100=#91+5 // Radio button for Visual/List/Extract option if (#70=='S') { #63 = #@100 } else { #64 = #@100 } Reg_Set(#54, @(#93)) // save search string Reg_Set(#55, @(#94)) // save replace string if ( #75 == 1 ) { // [Browse] Reg_Set(103,@(#92)) Reg_Set(103,"\Select directory",APPEND) if (Get_Filename(103,"*.*","Change directory",SET)) { // remove filename from path Buf_Switch(#65) Buf_Empty(OK) Reg_Ins(103) EOF if (Search("\",REVERSE+NOERR)) { Del_Block(CP,EOB_pos) } BOF Reg_Copy_Block(#92,Cur_Pos,EOL_pos) Buf_Quit(OK) } goto SEARCH_DIALOG } if ( #75 == 4 ) { // [Replace...] / [Search...] if (#70=='S') { #70 = 'R' } else { #70 = 'S' } goto SEARCH_DIALOG } if ( #75 == 5 ) { // [More >>] / [Less <<] if (#43==1) { #43 = 2 } else { #43 = 1 } goto SEARCH_DIALOG } #71 = #@91 // subdirectory flag // // Set #88 from user's selected options. // #88 = #88 & ~(SIMPLE + REGEXP + MAX + CASE + WORD + HEX) #100 = #91+1 // @#100 = state of 2nd check box if (#@100) { #88 = #88 | CASE } #100++ if (#@100) { #88 = #88 | WORD } #100++ if (#@100) { #51 = 1 } else { #51 = 0 } #100++ if (#@100 == 1) { #88 = #88 | SIMPLE } if (#@100 == 3) { #88 = #88 | REGEXP } if (#@100 == 4) { #88 = #88 | REGEXP | MAX } #100++ #74 = (#@100 ) // [V]isual, [D]isplay or [E]xtract flag. #50 = #88 // save options // // Convert display option number to mnemonic letter used herein. // if (#74==1) { if (#70=='S') { #74='V' } // Visual mode for Search else { #74='C' } // Confirm for Replace } if (#74==2) { #74='D' } // List filenames (Display) if (#74==3) { #74='E' } // Extract if (#74==4) { #74='F' } // Filenames only if (#75==6) { // [View] Reg_Set(#96,FILENAME) if (Reg_Compare(#96,"search.tmp") == 0) { Buf_Quit(OK+DELETE) //Close old search results listing } else { Call("OPEN_OUTPUT_FILE") Update() } #82 = Buf_Num // original buffer = search.tmp #83 = Win_Num // original window Reg_Empty(#96) Goto SEARCH_DIALOG } if (#75==7) { // [Options] Call("OPTIONS_DIALOG") goto SEARCH_DIALOG } if (#75==8) { // [Help] // Help("WILDFILE.VDM macro") System("hh.exe |(USER_MACRO)\wildfilew.chm",NOWAIT) goto SEARCH_DIALOG } if (#75==9) { #70='S' Goto SEARCH_DIALOG } if (#75==10) { #70='R' Goto SEARCH_DIALOG } if (#75==11) { #70='C' Goto MACRO_DIALOG } if (#75==12) { #70='M' Goto MACRO_DIALOG } // [OK] clicked ... Num_Pop(#91,#91+5) // End of Search dialog box handling Call("SAVE_SETTINGS") // Save settings to .ini file if (#70=='R') { if (#74=='C') { #52 = 0 // open all files } else { #52 = 2 // skip read-only files } } else { //'S' #52 = 1 // open all files as read-only } ////////////////////////////////////////////////////////////////////////// // // // Set T-Reg[#95] = macro string to execute for each file // // for Search or Search & Replace operation. // // // ////////////////////////////////////////////////////////////////////////// if (#74=='D' || #74=='E') { // // Insert searched keyword into syntax file (PL) // if ( File_Exist("|(HOME)/search.syn") ) { Buf_Switch(#90) Buf_Empty(OK) File_Open(*"|(HOME)/search.syn"*,FORCE+NOMSG) if (Search("|> ]`, ") } #75 = DI1(#91,^`Wildfile for Windows - Command sequence`, `Enter list of filenames to process, separated by commas. The wildcards "?" and "*" may be used.`, `??&Files: `, `??&Directory:`, `[]Search s&ubdirectories`,`.h.r[Browse]`, `[]Open as &read-only`, `Enter single-line VEDIT command sequence\t\t to be executed for each file:`, `.i??`, `[]&Pause after each screenful`, |@(103)^, APP+CENTER+TOP+SET,0,187) // [Cancel] or . if ( #75 == 0 || #75 == 3 ) { Num_Pop(#91,#91+5) Chain(#89) //Chain to Break-out/exit macro } #75++ // Skip non-existent "Browse for Macro" button #100=#91+1 #52 = #@100 #100++ // Open as read-only tickbox #53 = #@100 // Pause &after each screenful tickbox Reg_Set(#56,@(#91+2)) // Save command sequence } else { // [Macro...] Reg_Set(#91+2,@(#57)) // Saved macro filename if (#43==2) { Reg_Set(103," `.v.l.b[Ok]`,`.h.l[Cancel]`,`.l[Less <<]`, `.v.l[&View]`,`.h.l[&Options]`,`.l[&Help ]`, `Select operation:`, `.v.l[Search]`,`.h.l[Replace]`,`.l[ Command ]`,`.l[MACRO]`, ") } else { Reg_Set(103," `.v.l.b[Ok]`,`.h.l[Cancel]`,`.l[ &More >> ]`, ") } #75 = DI1(#91,^`Wildfile for Windows - Execute macro`, `Enter list of filenames to process, separated by commas. The wildcards "?" and "*" may be used.`, `??&Files: `, `??&Directory:`, `[]Search s&ubdirectories`,`.h.r[Browse]`, `[]Open as &read-only`, `Enter pathname to a macro to be executed once for each file: `, `.i??M&acro file: `, `\t\t\t Browse for macro file:`,`.h.r[Browse]`, `[]&Pause after each screenful`, |@(103)^, @(#93),APP+CENTER+TOP+SET,0,164) // [Cancel] or . if ( #75 == 0 || #75 == 4 ) { Num_Pop(#91,#91+5) #74 = 0 // do not close search results window Chain(#89) // Chain to Break-out/exit macro } #100=#91+1 #52 = #@100 #100++ // Open as read-only tickbox #53 = #@100 // Pause &after each screenful tickbox Reg_Set(#57,@(#91+2)) // Save macro filename // [Browse] for macro if ( #75 == 2 ) { Reg_Set(#91+2,USER_MACRO) Reg_Set(#91+2,"\*.vdm",APPEND) #100 = Get_Filename(#57,@(#91+2)) goto MACRO_DIALOG } } // [Browse]] for files if ( Return_Value == 1 ) { // (check original return value, not #75) Reg_Set(103,@(#92)) Reg_Set(103,"\Select directory",APPEND) if (Get_Filename(103,"*.*","Change directory",SET)) { // remove filename from path Buf_Switch(#65) Buf_Empty(OK) Reg_Ins(103) EOF if (Search("\",REVERSE+NOERR)) { Del_Block(CP,EOB_pos) } BOF Reg_Copy_Block(#92,Cur_Pos,EOL_pos) Buf_Quit(OK) } goto MACRO_DIALOG } if ( #75 == 5 ) { // [More >>] / [Less <<] if (#43 == 1) { #43 = 2 } else { #43 = 1 } goto MACRO_DIALOG } if (#75==6) { // [View] Reg_Set(#96,FILENAME) if (Reg_Compare(#96,"search.tmp") == 0) { Buf_Quit(OK+DELETE) //Close old search results listing } else { Call("OPEN_OUTPUT_FILE") Update() } #82 = Buf_Num // original buffer = search.tmp #83 = Win_Num // original window Reg_Empty(#96) Goto MACRO_DIALOG } if (#75==7) { // [Options] Call("OPTIONS_DIALOG") goto MACRO_DIALOG } if (#75==8) { // [Help] if (#70=='C') { // Command dialog System("hh.exe |(USER_MACRO)\wildfilew.chm::/command_dialog.htm",NOWAIT) } else { // Macro dialog System("hh.exe |(USER_MACRO)\wildfilew.chm::/macro_dialog.htm",NOWAIT) } goto MACRO_DIALOG } if (#75==9) { #70='S' Goto SEARCH_DIALOG } if (#75==10) { #70='R' Goto SEARCH_DIALOG } if (#75==11) { #70='C' Goto MACRO_DIALOG } if (#75==12) { #70='M' Goto MACRO_DIALOG } #71 = #@91 // subdirectory flag :SKIP_MDIALOG: // [OK] clicked ... Num_Pop(#91,#91+5) Call("SAVE_SETTINGS") // Save settings to .ini file // Enable/disable -MORE- operation Config( S_E_MORE, #53>0 ) // Get user command or macro into t-reg #95 if (#70=='C') { Reg_Set(#95,@(#56)) // User command sequence } else { if (Reg_Size(#57)==0) { DI1(0,"`Wildfile for Windows - Macro`, `\t No macro filename given! \t`") Goto MACRO_DIALOG } if (File_Exist(@(#57),NOERR) != 1) { DI1(0,"`Wildfile for Windows - Macro`, ` Macro file ( |@(#57) ) not found! `") Goto MACRO_DIALOG } Reg_Load(#95,@(#57),EXTRA) // Load the macro } ////////////////////////////////////////////////////////////////////////// // // // Get & Process Filename List into WildFile.tmp. // // // ////////////////////////////////////////////////////////////////////////// :PROCESS_FILENAMES: Message("Searching for files",STATLINE) ChDir(@(#92)) Buf_Switch(#82) // original buffer if (reg_size(#91)==0) { // if no filenames given... Reg_Set(#91,PATHNAME) // search in current file } // // Expand wildcards; add complete pathname; check for file existence. // Buf_Switch(#65) // Switch to work buffer (no tabs for "extra" buffers) Buf_Empty(OK) Reg_Ins(#91) Begin_Of_File() Reg_Push(#93,#94) // Save any search/replace strings Reg_Set(#94,"\") Reg_Empty(105) Reg_Empty(106) While (!At_EOF) { // // Copy next wildname from buffer[ #65 ] into T-Reg[#91]. // Delete processed text from the buffer. // #106 = Cur_Char #105 = Cur_Pos if (#106==''' || #106=='"') { Char(1) } else { #106 = ',' } Ins_Char(#106) // Insert one of ["',] Reg_Copy_Block(104,Cur_Pos-1,Cur_Pos,DELETE) // T-Reg[104] = delimiter ["',] if (Search(@104,NOERR)) { if (#106!=',') { // Advance past any ["'] Char(1) } Reg_Copy_Block(#91,#105,Cur_Pos,DELETE) // T-Reg[#91] = wildname Match("|[|w],|[|w]",ADVANCE) // Advance past any comma and wsp Del_Char(-CMAT) // Delete upto start of next wildname } else { // Else Reg_Copy_Block(#91,#105,EOB_Pos,DELETE) // T-Reg[#91] = final wildname } // // Check file existence when not "-s". // if (#71==0) { if (File_Exist("|@(#91)")==0) { // // Append nonexistent wildname to T-Reg[106]. // if (Reg_Size(106)) { Reg_Set(106,',',APPEND) } Reg_Set(106,@(#91),APPEND) Continue } } // // Use Dir() command to expand wildnames, recursing into subdirs if "-s". // Buf_Switch(#66) End_Of_File() //Goto end of buffer #87=#100=Cur_Pos() // and save position Out_Ins() //Re-route normal display into buffer #66 if (#71) { Directory(`"|@(#91)" -s`,COUNT+NOERR,1) //Insert directory, one column } else { Directory(`"|@(#91)"`,COUNT+NOERR,1) //Insert directory, one column } Out_Ins(CLEAR) //Turn off re-routing // // // repeat (ALL) { Goto_Pos(#87) //Restore position Search("|<|[|W]|LDirectory ",ADVANCE+ERRBREAK) //Search for "Directory" header Del_Char(-Chars_Matched) //Delete partial header and previous blank line #87=Cur_Pos() //Save current position Reg_Copy_Block(#92,Cur_Pos,EOL_Pos) //Copy drive:pathname to T-Reg #92 Begin_Of_Line() Del_Line() //Delete "Directory..." header if (Search("|<|[|W]|LDirectory ",NOERR)) { //Search for next "Directory" header Set_Marker(9,Cur_Pos) //Set marker at beginning of next subdirectory } else { Set_Marker(9,File_Size) //Else, set marker at E-O-F } // // Cleanup filenames. // Goto_Pos(#87) repeat (ALL) { //Remove blank lines Search_Block("|L|L",#87,Marker(9),ERRBREAK) Del_Line() } Goto_Pos(#87) //Remove leading white space Replace_Block("|<|W","",#87,Marker(9),NOERR+ALL) Goto_Pos(#87) //Remove the ".." entry Replace_Block("|<..|L","",#87,Marker(9),NOERR+ALL) Goto_Pos(#87) //Don't include Windows system file Replace_Block("|",#87,Marker(9),ERRBREAK) Begin_Of_Line() Del_Line() } Goto_Pos(#87) repeat (ALL) { //Don't include VEDIT's temp files Search_Block("|{#,$,%,&}|D|D|>",#87,Marker(9),ERRBREAK) Begin_Of_Line() Del_Line() } Goto_Pos(#87) //Restore position if (#87==Marker(9)) { // Handle empty directories continue //(Maybe empty after deleting garbage above) } repeat (ALL) { //Precede each filename with ... Search_Block("|<|?",#87,Marker(9),ERRBREAK+NORESTORE) Reg_Ins(#92,ADVANCE) //... full drive:pathname Reg_Ins(#94,ADVANCE) //... "\" (DOS) or "/" (UNIX/QNX) } Goto_Pos(#87) repeat (ALL) { //Don't include wildfile temp files Replace_Block("|(VEDIT_TEMP)|{/,\}wildfile|*|L","",#87,Marker(9),ERRBREAK) } Goto_Pos(#87) repeat (ALL) { //Don't include wildfile temp search files Replace_Block("|(VEDIT_TEMP)|{/,\}search.tmp|*|L","",#87,Marker(9),ERRBREAK) } Goto_Pos(#87) repeat (ALL) { //Don't include current session's temp files Replace_Block("|(VEDIT_TEMP)|{/,\}ved|(PID)|*|L","",#87,Marker(9),ERRBREAK) } Goto_Pos(#87) repeat (ALL) { //Don't include Win2000 "Registry" files Search_Block("system32\config\",#87,Marker(9),ERRBREAK) Begin_Of_Line() Del_Line() } Goto_Pos(Marker(9)) //Goto end of subdirectory block #87 = Cur_Pos //Restart from here } Del_Char(ALL) // Delete any extra chars (shouldn't be any) // // Append wildname from T-Reg[#91] to T-Reg[105], if good, or [106], if bad. // if (Cur_Pos == #100) { // Check for empty result set if (Reg_Size(106)) { Reg_Set(106,',',APPEND) } Reg_Set(106,@(#91),APPEND) } else { if (Reg_Size(105)) { Reg_Set(105,',',APPEND) } Reg_Set(105,@(#91),APPEND) } Buf_Switch(#65) } // // If files not found: // Copy any filenames from [106] back into [#91]; // empty work reg [106]; // loop to try again. // if (Reg_Size(105) == 0) { Reg_Set(#91,@106) // Copy all filenames back into T-Reg[#91] Buf_Switch(#66) // Switch to WildFile.tmp Alert() // Sound warning #75 = DI1(0,"`Wildfile for Windows - File(s) not found`, `\tNo files found:\t\t\t`, `.\.c|@(106)`, `[&Back]`,`[Cance&l]`") Reg_Empty(106) // Empty the work reg if (#75==0 || #75 == 2) { // or [Cancel] #74=0 break_out() } BOF() DC(ALL) Call("READ_SETTINGS") if (#43==0) { #43=1 } // Show dialog ** Goto VMAIN // Restart } Reg_Empty(#91) // No longer needed Reg_Pop(#93,#94) // Restore any search/replace strings Message("Processing",STATLINE) ////////////////////////////////////////////////////////////////////////// // // // Place the following executive macro into T-Reg #92. // // // ////////////////////////////////////////////////////////////////////////// Reg_Set(#92,` if (Reg_Size(#91)==0) { return } if (#52 & 2) { // skip read-only files flag if (File_Attrib(@#91) & 1) { return } } `) if (#52 & 1) { // open as read only flag // Use browse mode for faster operation Reg_Set(#92,` if ((#87=File_Check(@#91))<=0) { #87 = #90 // #87 = file being edited (PL) Buf_Switch(#90) File_Open(*"|@(#91)"*,BROWSE+NOEVENT) Call(#95) Buf_Switch(#90) Call(#73) if ((#98 & 8) == 0) { File_Close(NOMSG) } } else { Buf_Switch(#87) Save_Pos() Begin_Of_File() Call(#95) Restore_Pos() } `,APPEND) } else { // write access needed // Open file in read/write mode Reg_Set(#92,` if ((#87=File_Check(@#91))<=0) { #87 = #90 Buf_Switch(#90) File_Open(*"|@(#91)"*) Call(#95) Buf_Switch(#90) Call(#73) if ((#98 & 8) == 0) { File_Close(NOMSG) } } else { Buf_Switch(#87) Save_Pos() Begin_Of_File() Call(#95) Restore_Pos() } `,APPEND) } ////////////////////////////////////////////////////////////////////////// // // // Convert each line in WildFile.tmp (simple pathname) into: // // Reg_Set(#91,'pathname') Call(#92) // // // ////////////////////////////////////////////////////////////////////////// Buf_Switch(#66) Begin_Of_File() while ( !At_EOF ) { Ins_Text("RS(#91,`") End_Of_Line() Ins_Text("`) Call(#92)") Line(1, ERRBREAK) } // // Set "last file" flag for user macro (for 'M' operation) // Line(-1) Ins_Text("#98 |= 2 ") // #60 = Cur_Line // number of files to process (for info only) // // // Begin_Of_File() if (#102==0x44454D4F) { //If tutor macro, remove instruction window if (#77=Win_Reserved_Bottom_ID) { //If reserved bottom window... Win_Switch(#77) //Switch to it #78 = Win_Lines //#78 = lines in it #79 = Win_Border //#79 = # border lines in it Win_Delete() //Delete it } } if (#74=='V') { call("ShowHelpWindow") } // // Open a buffer for search result (PL) // if ((#74=='D') || (#74=='E') || (#74=='F')) { Call("OPEN_OUTPUT_FILE") Del_Block(CP,File_Size) // erase any old data if ((#74=='D') || (#74=='F')) { if (#70=='R') { Ins_Text("Replacing: ") // insert header Reg_Ins(#54) Ins_Text(" with: ") Reg_Ins(#55) } else { Ins_Text("Searching for: ") // insert header Reg_Ins(#54) } IN(3) } else { Ins_Text("Extracted lines matching: ") // insert header Reg_Ins(#54) IN(3) } Update() } else { if ((#70 == 'C') || (#70 == 'M')) { // Command or Macro operation Call("MAKE_DOUBLE_CLICK") Call("OPEN_OUTPUT_FILE") } } ////////////////////////////////////////////////////////////////////////// // // // Execution Loop // // // // Copy each line - Reg_Set(#91,'pathname') Call(#92) - // // from WildFile.tmp buffer into T-Reg #96 and execute it. // // // ////////////////////////////////////////////////////////////////////////// #69 = 0 //Disable quick-exit once macro really starts #62 = 0 //#62 = number of files with occurrences #63 = 0 //#63 = number of occurrences found #64 = 0 //#64 = number of lines with occurrences #98 = 0 //#98 = 1st-time-in flag for user macro Buf_Switch(#66) while (! At_EOF) { Reg_Copy(#96,1,DELETE) //Move next line into T-Reg #96 #58 = 0 //Reset "last" line # #71 = 0 //Reset "file counted" flag if (#74=='M') { //If executing command or macro... Reg_Push(40,40) // Save ini filename Num_Push(52,97) // Save local Num_Regs Call(#96) // Process next file Num_Pop(52,97) // Restore local Num_Regs Reg_Pop(40,40) // Restore ini filename if (#98 & 8) { // if user macro requested to keep file open #82 = Buf_Num // original buffer = current buffer } #99=0x57495C44 // Restore Wildfile ID ("WILD") } else { Call(#96) // Process next file } if (Win_Status('h')==0 || #74=='V') { //Check that help line still there if (Win_Status('h')<0) { call("ShowHelpWindow") } else { Win_Switch('h') } if (Win_Hor != #72) { Win_Color(112) Win_Clear() Message("[VISUAL EXIT] (<\>) to search again [VISUAL ESCAPE] (<\>) to quit",EXTRA) } } Buf_Switch(#66) if (#98 & 2) { //Operation canceled in user macro if (#98 & 4) { //User macro requests no end dialog #74 = 'x' } Break } } :DONE: #97=0 //Disable "BREAK-OUT" message // break_out() Chain(#89) //Chain to Break-out/exit macro return // --------------------- SUBROUTINES -------------------------------- ////////////////////////////////////////////////////////////////////////// // // // Options Dialog // // // ////////////////////////////////////////////////////////////////////////// :OPTIONS_DIALOG: DI1(44,^`Wildfile for Windows - Options`, `Start Wildfilew at:`, `.g.t()Search dialog`, `.t()Last dialog used`, `Default dialog type:`, `.g.t()Simple dialog`, `.t()Full dialog`, `Default directory:`, `.g.t()Current directory`, `.t()Current file's directory`, `.t()Last dir used by Wildfilew`, `Default search/replace strings (when no block highlighted):\t `, `.g.t()Empty`, `.t()Current search/replace strings`, `.t()Last used by Wildfilew`, `Default search options:`, `.g.t()Config settings`, `.t()Last used by Wildfilew`, `[Ok]`,`[Cancel]`,`[Help]`^, SET+APP+TOP+CENTER,0,100) if (Return_Value==3) { // [Help] System("hh.exe |(USER_MACRO)\wildfilew.chm::/options_dialog.htm",NOWAIT) Goto OPTIONS_DIALOG } if (Return_Value==1) { // [OK] Call("SAVE_SETTINGS") // Save settings to .ini file Call("SET_DEFAULT_DIR") } return ////////////////////////////////////////////////////////////////////////// // // // Set default directory as selected in options // // // ////////////////////////////////////////////////////////////////////////// :SET_DEFAULT_DIR: Buf_Switch(#82) //Back to original buffer if (#46==2) { //option: default path = current files path Reg_Set(#95,FILENAME) if (Reg_Compare(#95,"search.tmp") != 0) { // do not use the path of search.tmp Reg_Set(#92,PATH_ONLY) //default path = current file's path } } if (#46==1 || Reg_Size(#92)==0) { Reg_Set(#92,CUR_DIR) //default path = current directory } return ////////////////////////////////////////////////////////////////////////// // // // CONFIRM - Setup code to put up "Confirm" dialog for Replace. // // Enter: #74 = 'C' for Confirm else 0. // // Retrn: #74 = [All] ? 0 : 'C' // // // ////////////////////////////////////////////////////////////////////////// :CONFIRM: Ins_Text(^ // // Faster processing after [All] has been selected. // if (#74==0) { ^) if (#51) { // skip comments option Ins_Text("Search(@#54,SET+ERRBREAK+NORESTORE+#88)") Call("CHECK_COMMENT") } Ins_Text(^ #63 += Replace(@#54,@#55,SET+ERRBREAK+NORESTORE+#88) if (#71==0) { #71=1 #62++ } #42=Cur_Line if(#42!=#58) { #64++ #58=#42 } // // Otherwise, show highlighted, matched text and put up options dialog. // } else { Search(@#54,SET+ERRBREAK+CONFIRM+NORESTORE+#88) ^) if (#51) { // skip comments option Call("CHECK_COMMENT") } Ins_Text(^ Update() if (File_Attrib(@#91) & 1) { // check for read-only attribute #75=DI1(0,"`Wildfilew - Replace`, `.cFile is Read-only!`, `.v.l[ &Skip ]`,`.h.l.cSkip this file and continue `, `.v.l[Skip &All]`,`.h.l.cSkip all read only files`, `.v.l[Cancel]`,`.h.l.cCancel the operation`", APP+TOP+CENTER,0,21) if (#75==0||#75==3) { // [Cancel] Break_Out } if (#75==2) { // [Skip all] #52 |= 2 } Break } // // Put up option dialog. // #75=DI1(0,"`Replace?`, `[&Yes]`,`[&No]`,`[&All]`,`[&One]`,`[&Visual]`,`[Cance&l]`",APP+TOP+CENTER,0,21) // // Break out to locked-in macro if or [Cancel]. // if (#75==0||#75==6) { #97=0 //Disable "BREAK-OUT" message Break_Out } // // [Yes], [One] and [All]. // if (#75==1||#75==4||#75==3) { // // In all three cases, replace the matched text. // Replace(@#54,@#55,#88) #63++ if (#71==0) { #71=1 #62++ } #42=Cur_Line if(#42!=#58) { #64++ #58=#42 } // // For [One], break out to the locked-in macro. // if (#75==4) { #97=0 //Disable "BREAK-OUT" message Break_Out } // // For [All], switch to the fast track for future processing. // if (#75==3) { #74 = 0 #52 |= 2 // skip read-only files ^) if (#51==0) { // no "skip comments" option Ins_Text("#88 |= ALL ") } Ins_Text(^ } } // // For [No], just advance edit position by one character. // if (#75==2) { Char() } // // [Visual] // if (#75==5) { Call(#80,"ShowHelpWindow") //Put up "Visual Escape/Exit" help window Visual_Macro(CLEAR) V() Win_Delete('h') //Delete the help window } } ^) return ////////////////////////////////////////////////////////////////////////// // // // Insert code to check if inside comment // // // ////////////////////////////////////////////////////////////////////////// :CHECK_COMMENT: if (Reg_Size(#84)) { // Check for line comments? Ins_Text(^ #75=Cur_Pos BOL if (Search_Block(@(#84),CP,#75,NOERR)) { //check for line comment Line(1) Continue } GP(#75) ^) } if (Reg_Size(#85) > 3) { // Check for block comments? if (Reg_Size(#84)) { // Check if block comment begin was inside line comment Ins_Text(^ #75=Cur_Pos if (Search(@(#85),NOERR+REVERSE+ADVANCE)) { // find comment begin or end if (Match_Item==1) { // begin of comment #42 = Cur_Pos BOL if (Search_Block("//",CP,#42,NOERR)==0) { GP(#42) Search("*/",ERRBREAK+ADVANCE) Continue } } } GP(#75) ^) } else { // do not check line comment Ins_Text(^ #75=Cur_Pos if (Search(@(#85),NOERR+REVERSE+ADVANCE)) { // find comment begin or end if (Match_Item==1) { // begin of comment found Search(@(#85),ERRBREAK+ADVANCE) // find end of comment Continue } } GP(#75) ^) } } return ////////////////////////////////////////////////////////////////////////// // // // ShowHelpWindow. // // // ////////////////////////////////////////////////////////////////////////// :ShowHelpWindow: Win_Zoom(#76) //Restore window zoom state if (Win_Border>=2) { Win_Reserved('h',1,BOTTOM+NOBORDER) } else { Win_Reserved('h',1,BOTTOM) } Win_Switch('h') Win_Color(112) Win_Clear() Message("[VISUAL EXIT] (<\>) to search again [VISUAL ESCAPE] (<\>) to quit",EXTRA) #72 = Win_Hor //#72 = horizontal pos return ////////////////////////////////////////////////////////////////////////// // // // Open a buffer for search result // // Use buffer 90 (or 91, 92...) so that it will be the last tab // // // ////////////////////////////////////////////////////////////////////////// :OPEN_OUTPUT_FILE: // Use same directory as .ini file: Buf_Switch(#90) // tmp buffer BOF Del_Char(ALL) Reg_Ins(40) // pathname of .ini file if (Search("|{\,/}", REVERSE+ADVANCE+NOERR)) { Del_Block(CP, EOL_pos) // path only IT("search.tmp") RCB(#96, BOL_pos, CP) // pathname of search.tmp } else { RS(#96, @(#67)) // no path, use current dir RS(#96, "\search.tmp",APPEND) } Buf_Quit(OK) #61 = File_Check(@(#96)) if (#61 > 0) { Buf_Switch(#61) } else { #61 = 90 //use buffer 90 so that search.tmp will be the last tab while ((Buf_Status(#61) >= 0) && (#61 < 99)) { #61++ } Buf_Switch(#61) File_Open(@(#96), ATTACH+OVERWRITE+NOMSG) // Win_Move(Win_Num,0,WINH/2,WINW,WINH/2) // Make window half height at bottom } BOF if ( File_Exist("|(HOME)/search.syn") ) { Syntax_Load("|(HOME)/search.syn") Config(PG_E_SYNTAX,1,LOCAL) } Return ////////////////////////////////////////////////////////////////////////// // // // SAVELAST - Save or abandon last file following Break-out. // // Enter: #68 = file disposition: {0,1,2,3} == {ask, // // keep,save,abandon}. // // Return: Switched to buffer #90. // // // ////////////////////////////////////////////////////////////////////////// :SAVELAST: Buf_Switch(#90) if (Is_Open_Write && Is_Altered) { //Save or abandon last file... #100 = Win_Num if ((#101=Buf_Status) > 1) { //Force buffer's window to the top Win_Switch(#101) Update() } if (#68==0) { File_Close(CONFIRM) } else { if ( #68 == 2 ) { // Save Buf_Close() } else { if ( #68 == 3 ) { // Abandon Buf_Quit(OK) }}} Win_Switch(#100) } return ////////////////////////////////////////////////////////////////////////// // // // MAKE_DOUBLE_CLICK - Build double click event macro // // into text register 116 if it is empty // // // ////////////////////////////////////////////////////////////////////////// :MAKE_DOUBLE_CLICK: if (Reg_Size(116)) { return } // Event macro already exists Statline_Message("Creating double-click event macro") //**debug Reg_Set(116,`// Double-click event macro for Wildfilew.vdm #116 = Reg_Free Call_File(#116,"search116.vdm",NOERR) Reg_Empty(#116) `) return ////////////////////////////////////////////////////////////////////////// // // // Read settings from WILDFILW.INI // // // ////////////////////////////////////////////////////////////////////////// :READ_SETTINGS: // File_Open("|(USER_MACRO)\wildfilw.ini",OVERWRITE+NOMSG+NOEVENT) File_Open(@40,OVERWRITE+NOMSG+NOEVENT) if (Search("|