// CFUNC.VDM - Point and shoot selection of 'C' functions. // ALL.VDM - based on CFUNC.VDM - approximates the XEDIT 'ALL' command // // Originally by: Kerry E. Wilkinson // 109 Wimbledon Lane // Owings Mills, MD 21117 // Last change: Late '97 // // Requires: VEDIT 5.00 or later. // // Usage: Select {MISC, Load/Execute macro}; enter register number // "100", enter filename "all.vdm". // //////////////// // Get_Input( 10, "Search:", NOCR | STATLINE) if( Reg_Size( 10) == 0) { return( 0)} Num_Push(77,90) // Save numeric registers used here #90 = CP #77 = config(F_F_TYPE) // add support for fixed length records #78 = config(F_OVER_MODE) #85 = Buf_Num // #85 = original edit buffer #80 = Reg_Free() // #80 = T-Reg to hold function name array Reg_Set(#80,/ /) // Insert something so next "Reg_Free" works #81 = Reg_Free() // #81 = T-Reg to hold file position array #82 = Buf_Free() // #82 = Buffer to process function name array Buf_Switch(#82) // Needed to make next "Buf_Free" work Buf_Empty(OK) File_Save_As( "ALL_WRK.!!!", OK|NOMSG) config(F_F_TYPE,#77) config(F_OVER_MODE,0) Buf_Switch(#85) // Switch back #83 = Buf_Free() // #83 = Buffer to process file position array Buf_Switch(#83) // Needed to make next "Buf_Free" work buf_Empty(OK) File_Save_As( "ALL_WRK2.!!!", OK|NOMSG) if (#80<=0 || #81<=0 || #82<=0 || #83<=0) { // If no resources... Get_Key("No T-Regs or Buffers available for run ALL",STATLINE+RAW) Num_Pop(77,90) Return } Reg_Empty(#80) // Empty #80 #84 = 0 // Init loop counter to zero #86 = Cur_Pos // #86 = original buffer's file position #87 = 0 // Clear line number register // #88 = temp used below Buf_Switch(#85) Begin_Of_File() Message("Processing file. Please wait...",STATLINE) // // Create arrays of function name and corresponding file position. // repeat (ALL) { // Start 'endless' loop Buf_Switch(#85) // Switch to original buffer Search("\@(10)",ADVANCE+ERRBREAK+REGEXP) BOL #87 = Cur_Pos // Store the function location Out_Reg(#81,APPEND) // Append file position to T-Reg #81 Num_Type(#87,LEFT) Out_Reg(CLEAR) #84++ // Increment loop counter Reg_Copy(#80,1) Buf_Switch(#82) Reg_Ins(#80) Reg_Empty(#80) Buf_Switch(#83) Reg_Ins(#81) Reg_Empty(#81) Buf_Switch(#85) Line(1,NOERR) // Continue search on next line } // End of loop // Reg_Set( 10, "Number of lines matched: ") Out_Reg(10, APPEND) Num_Type( #84) Out_Reg( CLEAR) Get_Key( @10,STATLINE) if (#84>0) { // If at least 1 function found... Win_Create(*,2,44,20,32) // Create function display window to the right Win_Switch(*) // Switch to the new window if (Is_Mono) { Win_Color(112) } // If monochrome use black chars on while else { Win_Color(32) } // If color use black chars on green Win_Clear() // Clear window with new color Buf_Switch(#82) Begin_Of_File() Win_Attach(*) // Attach special window repeat (ALL) { // Loop until or Begin_Of_Line() Block_Begin(Cur_Pos) EOL() Block_End(Cur_Pos) Begin_Of_Line() Update() // Highlight current function name #88 = Cur_Line // #88 = array index Buf_Switch(#83) Goto_Line(#88) // Index into file_position array #86 = Num_Eval() // #86 = corresponding file position Buf_Switch(#85) // Return to main buffer Goto_Pos(#86) Update() // Goto function location Begin_Of_Line() // Goto beginning of line #89 = Cur_Line Buf_Switch(#82) Win_Switch(*) // Go back to function list window Reg_Set(10,"Use cursor keys, to select, to Quit, E to Edit | Line:") Out_Reg( 10, APPEND) Num_Type( #89) Out_Reg( CLEAR) #88 = Get_Key( @10,STATLINE) if(#88=='E'+'S'*256) { // Escape Win_Delete(*) Buf_Switch(#82) Buf_Quit(OK) Buf_Switch(#83) Buf_Quit(OK) File_Delete( "ALL_WRK.!!!", OK) File_Delete( "ALL_WRK2.!!!", OK) Buf_Switch(#85) Goto_Pos(#90) Update() Num_Pop(77,90) // Restore numeric regs Return } if (#88=='R'+'T'*256) { // Return Buf_Switch(#85) #86 = Cur_Pos() Break // Break out of Repeat Loop } if (#88=='C'+'D'*256) { // Cursor Down if (Cur_Line<#84) { Do_Visual("\CD\") } } if (#88=='C'+'U'*256) { // Cursor Up if (Cur_Line>1) { Do_Visual("\CU\") } } if (#88=='P'+'D'*256) { // Page Down if ((Cur_Line+23)<#84) { Line(23,NOERR) } else { EOF() Line(-1,NOERR) } } if (#88=='P'+'U'*256) { // Page Up if (Cur_Line > 23) { Line(-23,NOERR) } else { Begin_Of_File() } } if (#88=='L'+'E'*256) { End_Of_File() Line(-1,NOERR) } if (#88=='L'+'B'*256) { Begin_Of_File() } // Home if (#88=='E' || #88 == 'e') { Reg_Empty( 10) Get_Input( 10, "Enter filename to save as:", NOCR | STATLINE) If( Reg_Size( 10) > 0) { #88 = Get_Key( "Do you want to delete selected records from original file (Y/N)?", STATLINE) If(#88=='y' || #88=='Y'){ Buf_Switch(#85) config(F_OVER_MODE,0) Buf_Switch(#83) EOF Repeat(ALL){ Line(-1,ERRBREAK) #86 = Num_Eval() Buf_Switch(#85) Goto_Pos(#86) Del_Line(1) Buf_Switch(#83) } Buf_Switch(#85) config(F_OVER_MODE,#78) File_Save() } Win_Delete(*) Buf_Switch(#83) Buf_Quit(OK) File_Delete( "ALL_WRK2.!!!", OK) Buf_Switch(#82) config(F_OVER_MODE,#78) File_Save_As( @10, OK) File_Delete( "ALL_WRK.!!!", OK) Update() Block_Begin(CLEAR) Num_Pop(77,90) return } else { Alert() } } } Win_Delete(*) Buf_Switch(#82) Buf_Quit(OK) Buf_Switch(#83) Buf_Quit(OK) } else { Buf_Switch(#82) Buf_Quit(OK) Buf_Switch(#83) Buf_Quit(OK) File_Delete( "ALL_WRK.!!!", OK) File_Delete( "ALL_WRK2.!!!", OK) Buf_Switch(#85) Goto_Pos(#90) Update() Num_Pop(77,90) // Restore numeric regs Return } Buf_Switch(#85) Goto_Pos(#86) Update() Num_Pop(77,90) // Restore numeric regs Return