//Use SetDir.vw // Find file view Use API_Attr.nui // Functions for querying API attributes (No User Interface) Use Spec0011.utl // Floating menues on the fly Use Buttons.utl // Button texts Use GridUtil.utl // Grid and List utilities Use Files.utl // Utilities for handling file related stuff Use SetDir.pkg // cSetOfDirectories class Use Masks_DF.nui // DataFlex related file masks Use Strings.nui // ****************************************************************** // Text search functions #IFDEF IS$WINDOWS #ELSE /oTextFileDisplayGotoLine.hdr Go to lineĿ /oTextFileDisplayGotoLine.frm Line number: _____. ___ Command line /oTextFileDisplayGotoLine.btn ______ ________ /* object oTextFileDisplayGotoLine is a app.ModalClient oTextFileDisplayGotoLine.hdr set location to 6 18 absolute on_key ksave_record send ok on_key kcancel send cancel object oFrm is a Form oTextFileDisplayGotoLine.frm set location to 1 0 relative set select_mode to MULTI_SELECT item_list on_item "" send next on_item "" send next set checkbox_item_state to DFTRUE end_item_list end_object object oBtn is a app.Button oTextFileDisplayGotoLine.btn set location to 6 0 relative item_list on_item T.BTN.OK send ok on_item T.BTN.CANCEL send cancel end_item_list end_object function iPopup.i integer lbAllowCMD returns integer local integer liRval liLine set shadow_state of (oFrm(self)) item 1 to (not(lbAllowCMD)) set select_state of (oFrm(self)) item 1 to lbAllowCMD ui_accept self to liRval if liRval eq MSG_OK begin get value of (oFrm(self)) item 0 to liLine if (select_state(oFrm(self),1)) begin move (-liLine) to liLine end end else move 0 to liLine // Means: cancelled function_return liLine end_procedure end_object // oTextFileDisplayGotoLine /oTextFileDisplay.hdr Display file __________________________________________________________________ /oTextFileDisplay.lst _______________________________________________________________________________ _______________________________________________________________________________ _______________________________________________________________________________ _______________________________________________________________________________ _______________________________________________________________________________ _______________________________________________________________________________ _______________________________________________________________________________ _______________________________________________________________________________ _______________________________________________________________________________ _______________________________________________________________________________ _______________________________________________________________________________ _______________________________________________________________________________ _______________________________________________________________________________ _______________________________________________________________________________ _______________________________________________________________________________ _______________________________________________________________________________ _______________________________________________________________________________ _______________________________________________________________________________ _______________________________________________________________________________ _______________________________________________________________________________ _______________________________________________________________________________ _______________________________________________________________________________ /oTextFileDisplay.msg Line: ___________________ ________________ /oTextFileDisplay.btn ____________ _________ /* object oTextFileDisplay is a app.ModalClient oTextFileDisplay.hdr set location to 0 0 ABSOLUTE property integer phSource public 0 object oList is a List oTextFileDisplay.lst set location to 1 0 RELATIVE on_key KEY_LEFT_ARROW send decr_hor_offset on_key KEY_RIGHT_ARROW send incr_hor_offset on_key KEY_HOME send hz_left_most property integer piHorOffSet public 0 procedure hz_left_most set piHorOffSet to 0 send update_horizon end_procedure procedure incr_hor_offset local integer liValue get piHorOffSet to liValue move (liValue+10) to liValue set piHorOffSet to liValue send update_horizon end_procedure procedure decr_hor_offset local integer liValue get piHorOffSet to liValue move (liValue-10) to liValue if (liValue<0) move 0 to liValue set piHorOffSet to liValue send update_horizon end_procedure procedure item_change integer liItm1 integer liItm2 returns integer local integer liRval forward get msg_item_change liItm1 liItm2 to liRval send update_line_counter (liRval+1) procedure_return liRval end_procedure procedure update_horizon local integer lhSource liMax liItm liOffSet set dynamic_update_state to FALSE get piHorOffSet to liOffSet get phSource to lhSource get item_count to liMax decrement liMax for liItm from 0 to liMax // get value of lhSource item liItm to lsValue // set value item liItm to (mid(lsValue,79,liOffSet+1)) set value item liItm to (mid(value(lhSource,liItm),79,liOffSet+1)) loop set dynamic_update_state to TRUE end_procedure procedure fill_list integer lhSource integer liGotoLine local integer liMax liItm liOffSet set phSource to lhSource get piHorOffSet to liOffSet set dynamic_update_state to FALSE send delete_data get item_count of lhSource to liMax decrement liMax for liItm from 0 to liMax send add_item MSG_NONE (value(lhSource,liItm)) loop if liGotoLine set current_item to (liGotoLine-1) else set current_item to 0 set dynamic_update_state to TRUE end_procedure end_object object oMsg is a Form oTextFileDisplay.msg set location to 23 0 RELATIVE set focus_mode to POINTER_ONLY item_list on_item "" send none // Current line on_item "" send none // Current search string end_item_list end_object procedure update_line_counter integer liLine local integer liMax get item_count of (oList(self)) to liMax set value of (oMsg(self)) item 0 to (string(liLine)+"/"+string(liMax)) end_procedure // Extract CMD line number from a PRN (or PRP) file line function iExtractCmdLine string lsLine returns integer local integer liPos liLen lbGtReached local string lsChar lsCmdLine move (length(lsLine)) to liLen if (liLen>8) begin move (left(lsLine,8)) to lsLine move 8 to liLen end move "" to lsCmdLine move 0 to lbGtReached // ">" character found if (lsLine contains ">") begin move 0 to liPos repeat increment liPos move (mid(lsLine,1,liPos)) to lsChar if ("0123456789" contains lsChar) begin move (append(lsCmdLine,lsChar)) to lsCmdLine end else begin if (lsChar=">") move 1 to lbGtReached else move 1000 to liPos // Break the loop end until (liPos=8 or lbGtReached<>0) end ifnot lbGtReached move "" to lsCmdLine function_return (integer(lsCmdLine)) end_function function iCmdLine2FileLine integer lhSource integer liSearchLine returns integer local integer liItm liMax liCmdLine liPreviousItem move -1 to liPreviousItem get item_count of lhSource to liMax decrement liMax for liItm from 0 to liMax get iExtractCmdLine (value(lhSource,liItm)) to liCmdLine if (liCmdLine<>0) begin if (liCmdLine=liSearchLine) function_return (liItm+1) if (liCmdLine>liSearchLine) begin if (liPreviousItem<>-1) function_return (liPreviousItem+1) else function_return (liItm+1) end move liItm to liPreviousItem end loop function_return -1 end_function procedure DoGotoLine local integer liLine lbAllowCMD lhSource local string lsFile get psFile of (phSource(self)) to lsFile move (lowercase(right(lsFile,4))) to lsFile move (lsFile=".prp" or lsFile=".prn") to lbAllowCMD get iPopup.i of (oTextFileDisplayGotoLine(self)) lbAllowCMD to liLine if (liLine>0) begin // > 0 means CMD line option wasn't checked set current_item of (oList(self)) to (liLine-1) end else begin // <0 means CMD line option was selected get phSource to lhSource get iCmdLine2FileLine lhSource (0-liLine) to liLine if (liLine=-1) send obs "The command line number specified is higher than any" "command line numbers present in this file" else set current_item of (oList(self)) to (liLine-1) end end_procedure on_key KEY_CTRL+KEY_G send DoGotoLine object oBtn is a app.Button oTextFileDisplay.btn set location to 23 55 RELATIVE item_list on_item "Go to line" send DoGotoLine on_item "Close" send Cancel end_item_list end_object register_function psFile returns string procedure popup.ii integer lhSource integer liGotoLine local integer liRval set piHorOffSet of (oList(self)) to 0 set value item 0 to (psFile(lhSource)) send fill_list to (oList(self)) lhSource liGotoLine ui_accept self to liRval end_procedure end_object // oTextFileDisplay /oTextSearchPn.hdr Ŀ /oTextSearchPn.frm Search text: ______________________________________________________ ___ Case sensitive ___ Search words only (not impl) ___ Do not search within comments /oTextSearchPn.btn __________ __________ /* define SourceWordCharacters for "ABCDEFGHIJKLMNOPQRSTUVXYZ_$?!0123456789@" object oTextSearchPn is a app.ModalClient oTextSearchPn.hdr set location to 6 11 ABSOLUTE on_key ksave_record send ok on_key kcancel send cancel property integer pbDetach public 0 // 0=attach, 1=detach object oForm is a Form oTextSearchPn.frm set select_mode to MULTI_SELECT set location to 1 0 RELATIVE on_key kenter send ok item_list on_item "" send next on_item "" send next set checkbox_item_state to TRUE on_item "" send next set checkbox_item_state to TRUE set shadow_state to TRUE on_item "" send next set checkbox_item_state to TRUE set select_state to TRUE end_item_list end_object object oBtn is a app.Button oTextSearchPn.btn set location to 8 0 RELATIVE item_list on_item "Search" send ok on_item "Cancel" send cancel end_item_list end_object function sSearchValue returns string local integer lhMsg lhForm local string lsValue ui_accept self to lhMsg if (lhMsg=MSG_OK) begin move (oForm(self)) to lhForm get value of lhForm item 0 to lsValue end else move "" to lsValue function_return lsValue end_function function bCaseSens returns integer function_return (select_state(oForm(self),1)) end_function function bWordOnly returns integer function_return (select_state(oForm(self),2)) end_function function bExclComments returns integer function_return (select_state(oForm(self),3)) end_function end_object // oTextSearchPn class cSource is an cArray procedure construct_object forward send construct_object property string psFile public "" end_procedure procedure DisplayFile integer liGotoLine // send obs "DisplayFile" (psFile(self)) liGotoLine send popup.ii to (oTextFileDisplay(self)) self liGotoLine end_procedure procedure read_file string lsFile local integer liChannel lbSeqEof liItem local string lsLine set psFile to lsFile send delete_data get SEQ_DirectInput lsFile to liChannel if (liChannel>=0) begin move 0 to liItem repeat readln channel liChannel lsLine move (seqeof) to lbSeqEof ifnot lbSeqEof set value item liItem to lsLine increment liItem until lbSeqEof send SEQ_CloseInput liChannel end end_procedure procedure DoReset send delete_data end_procedure function sRemoveComments string lsLine returns string local integer liPos move (pos("/"+"/",lsLine)) to liPos if liPos move (left(lsLine,liPos-1)) to lsLine function_return lsLine end_function procedure file_search_text integer lhMsg integer lhObj string lsText integer lbCaseSens integer lbWordOnly integer lbExclComments local integer liMax liItem lhSelf local string lsLine lsFile get psFile to lsFile get item_count to liMax decrement liMax move self to lhSelf for liItem from 0 to liMax get value item liItem to lsLine ifnot lbCaseSens move (lowercase(lsLine)) to lsLine if lbExclComments get sRemoveComments lsLine to lsLine if (lsLine contains lsText) begin if lbWordOnly begin //SourceWordCharacters end get value item liItem to lsLine // Get original line send lhMsg to lhObj lsLine lsFile (liItem+1) lhSelf end loop end_procedure end_class // cSourceFile class cSourceFolder is a cArray procedure construct_object integer liImg forward send construct_object liImg property integer piCounter public 0 property integer piFileCount public 0 end_procedure item_property_list item_property string psFile.i item_property integer phSource.i end_item_property_list cSourceFolder procedure add_file string lsFile integer lhSource local integer liRow get row_count to liRow set psFile.i liRow to lsFile set phSource.i liRow to lhSource end_procedure procedure DoReset local integer liMax liRow lhSource get row_Count to liMax decrement liMax for liRow from 0 to liMax get phSource.i liRow to lhSource if lhSource begin send DoReset to lhSource send destroy_object to lhSource end loop send delete_data end_procedure procedure CountFile string lsFile string lsFolder set piFileCount to (piFileCount(self)+1) end_procedure procedure HandleFile string lsFile string lsFolder local integer lhSource liCounter object oSource is a cSource NO_IMAGE move self to lhSource send read_file (Files_AppendPath(lsFolder,lsFile)) end_object send add_file lsFile lhSource get piCounter to liCounter increment liCounter set piCounter to liCounter send ScreenEndWait_Update liCounter end_procedure procedure search_text string lsText integer lhMsg integer lhObj integer lbCaseSens integer lbWordOnly integer lbExclComments local integer liMax liRow lhSource get row_count to liMax decrement liMax send ScreenEndWait_On 0 liMax send ScreenEndWait_Update 0 send ScreenEndWait_SetText "Searching..." for liRow from 0 to liMax get phSource.i liRow to lhSource send file_search_text to lhSource lhMsg lhObj lsText lbCaseSens lbWordOnly lbExclComments send ScreenEndWait_Update liRow loop send ScreenEndWait_Off end_procedure end_class // cSourceFolder object oSourceFolder is a cSourceFolder NO_IMAGE end_object /oTextSearchResultDisplay.hdr Search result ________________________________________________________ /oTextSearchResultDisplay.lst _______________________________________________________________________________ _______________________________________________________________________________ _______________________________________________________________________________ _______________________________________________________________________________ _______________________________________________________________________________ _______________________________________________________________________________ _______________________________________________________________________________ _______________________________________________________________________________ _______________________________________________________________________________ _______________________________________________________________________________ _______________________________________________________________________________ _______________________________________________________________________________ _______________________________________________________________________________ _______________________________________________________________________________ _______________________________________________________________________________ _______________________________________________________________________________ _______________________________________________________________________________ _______________________________________________________________________________ _______________________________________________________________________________ _______________________________________________________________________________ _______________________________________________________________________________ _______________________________________________________________________________ /oTextSearchResultDisplay.msg ______________________________________________________ /oTextSearchResultDisplay.btn __________ __________ /* object oTextSearchResultDisplay is a app.ModalClient oTextSearchResultDisplay.hdr set location to 0 0 ABSOLUTE property integer piSearchResultFileCount public 0 property integer piSearchResultOccuranceCount public 0 object oList is a List oTextSearchResultDisplay.lst set location to 1 0 RELATIVE property string psFile public "" procedure AddLine string lsLine string lsFile integer liLineNo integer lhSource local string lsLineNo if (lsFile<>psFile(self)) begin set psFile to lsFile send add_item MSG_NONE ("--- "+lsFile+": ----------------------------------") set piSearchResultFileCount to (piSearchResultFileCount(self)+1) set aux_value item (item_count(self)-1) to lhSource end if (liLineNo<10000) get IntToStrRzf liLineNo 5 to lsLineNo else get IntToStrRzf liLineNo 8 to lsLineNo send add_item MSG_NONE (lsLineNo+": "+lsLine) set piSearchResultOccuranceCount to (piSearchResultOccuranceCount(self)+1) set aux_value item (item_count(self)-1) to lhSource end_procedure procedure DoDisplayFile local integer lhSource liLine local string lsLine if (item_count(self)) begin get aux_value item CURRENT to lhSource get value item CURRENT to lsLine if (left(lsLine,1)="-") move 0 to liLine else move (ExtractWord(lsLine,":",1)) to liLine send message_set "Opening file..." send DisplayFile to lhSource liLine send message_set "" end end_procedure on_key KENTER send DoDisplayFile procedure key integer liKey send message_clear forward send key liKey end_procedure end_object procedure AddResult string lsLine string lsFile integer liLineNo integer lhSource send AddLine to (oList(self)) lsLine lsFile liLineNo lhSource end_procedure procedure DoSearch local integer lhSelf lhList local integer lbCaseSens lbWordOnly lbExclComments local string lsSearchValue get sSearchValue of (oTextSearchPn(Self)) to lsSearchValue if (lsSearchValue<>"") begin set piSearchResultFileCount to 0 set piSearchResultOccuranceCount to 0 get bCaseSens of (oTextSearchPn(self)) to lbCaseSens get bWordOnly of (oTextSearchPn(self)) to lbWordOnly get bExclComments of (oTextSearchPn(self)) to lbExclComments ifnot lbCaseSens move (lowercase(lsSearchValue)) to lsSearchValue move (oList(self)) to lhList set dynamic_update_state of lhList to FALSE move self to lhSelf send delete_data to lhList send header_clear set psFile of lhList to "" send search_text to (oSourceFolder(self)) lsSearchValue MSG_AddResult lhSelf lbCaseSens lbWordOnly lbExclComments ifnot (item_count(lhList)) begin send obs "Text not found" send message_set "No occurances" end else begin send header_set (string(piSearchResultOccuranceCount(self))+" occurances in "+string(piSearchResultFileCount(self))+" files") end set dynamic_update_state of lhList to TRUE send activate to lhList set current_item of lhList to 0 end end_procedure object oMsg is a Form oTextSearchResultDisplay.msg set location to 23 0 RELATIVE set focus_mode to POINTER_ONLY item_list on_item "" send none end_item_list end_object procedure header_set string lsValue set value item 0 to lsValue end_procedure procedure header_clear send header_set "" end_procedure send header_clear procedure message_set string lsValue set value of (oMsg(self)) item 0 to lsValue end_procedure procedure message_clear send message_set "" end_procedure on_key KEY_CTRL+KEY_S send DoSearch object oBtn is a app.Button oTextSearchResultDisplay.btn set location to 23 55 RELATIVE item_list on_item "Search" send DoSearch on_item "Close" send Cancel end_item_list end_object procedure popup integer liFilesRead local integer lhMsg send message_set (string(liFilesRead)+" files read") send deferred_message MSG_DoSearch // Immediately popup the search value dialog ui_accept self to lhMsg send delete_data to (oList(self)) send header_clear to (oList(self)) end_procedure end_object // oTextSearchResultDisplay // End text search functions // ****************************************************************** #ENDIF object oSetOfDirectories is a cSetOfDirectories NO_IMAGE #IFDEF IS$WINDOWS object oWait is a StatusPanel set allow_cancel_state to DFFALSE end_object procedure OnWait_On string lsCaption set caption_text of (oWait(self)) to lsCaption set title_text of (oWait(self)) to "" set message_text of (oWait(self)) to "" set action_text of (oWait(self)) to "" send Start_StatusPanel to (oWait(self)) end_procedure procedure OnWait_SetText1 string lsValue set Message_Text of (oWait(self)) to lsValue end_procedure procedure OnWait_SetText2 string lsValue set Action_Text of (oWait(self)) to lsValue end_procedure procedure OnWait_Off send Stop_StatusPanel to (oWait(self)) end_procedure #ELSE procedure OnWait_On string lsCaption send ScreenEndWait_On 0 0 send ScreenEndWait_SetText lsCaption end_procedure procedure OnWait_SetText1 string lsValue send ScreenEndWait_SetText lsValue end_procedure procedure OnWait_SetText2 string lsValue send ScreenEndWait_SetText2 lsValue end_procedure procedure OnWait_Off send ScreenEndWait_Off end_procedure #ENDIF end_object object oSetOfFilesNew is a cSetOfFilesNew NO_IMAGE set piSOD_Object to (oSetOfDirectories(self)) end_object #IFDEF IS$WINDOWS Use Buttons.utl // Button texts Use APS // Auto Positioning and Sizing classes for VDF activate_view Activate_FindFileResultVw for oNewFindFileResultVw object oNewFindFileResultVw is a aps.View label "Find file, result" on_key kuser send Activate_SetDirTestVw on_key kcancel send close_panel object oLst is a cSetOfFilesListNew set size to 200 0 set piSOF_Object to (oSetOfFilesNew(self)) procedure OnListFilled integer liFileCount number lnBytes send total_display (SEQ_FileSizeToString(lnBytes)+" in "+string(liFileCount)+" files") end_procedure procedure DoReset forward send DoReset send Activate_SetDirTestVw end_procedure end_object send aps_goto_max_row object oSelectTxt is a aps.TextBox end_object set auto_size_state of (oSelectTxt(self)) to DFTRUE procedure total_display string lsValue set value of (oSelectTxt(self)) to lsValue end_procedure object oBtn1 is a aps.Multi_Button on_item "Reset list" send DoReset to (oLst(self)) end_object object oBtn2 is a aps.Multi_Button on_item "Copy files" send DoCopyFilesToDirectory to (oLst(self)) end_object object oBtn3 is a aps.Multi_Button on_item t.btn.close send close_panel end_object send aps_locate_multi_buttons set Border_Style to BORDER_THICK // Make panel resizeable procedure aps_onResize integer delta_rw# integer delta_cl# send aps_resize (oLst(self)) delta_rw# 0 // delta_cl# send aps_auto_locate_control (oSelectTxt(self)) SL_DOWN (oLst(self)) send aps_register_multi_button (oBtn1(self)) send aps_register_multi_button (oBtn2(self)) send aps_register_multi_button (oBtn3(self)) send aps_locate_multi_buttons send aps_auto_size_container end_procedure procedure fill_list send fill_list to (oLst(self)) end_procedure end_object // oNewFindFileResultVw procedure Activate_FindFileResultVwReFill send fill_list to (oNewFindFileResultVw(self)) send Activate_FindFileResultVw end_procedure activate_view Activate_SetDirTestVw for oNewFindFileVw object oNewFindFileVw is a aps.View label "Find file" on_key kuser send Activate_FindFileResultVw set pMinimumSize to 220 0 on_key kcancel send close_panel object oLstHeader is a aps.Textbox label "Folders in search path" end_object object oLst is a cSetOfDirectoriesList snap SL_DOWN set size to 170 0 set piSetOfDirectoriesObject to (oSetOfDirectories(self)) register_object oLstTotal set Horz_Scroll_Bar_Visible_State to false procedure OnListChanged integer liItems set value of (oLstTotal(self)) to (" "+string(liItems)+" folders") end_procedure end_object object oLstTotal is a aps.Textbox label " 0 folders " end_object send aps_goto_max_row object oFrm is a aps.Form abstract AFT_ASCII80 label "Find this file (wildcards allowed):" set p_extra_internal_width to -240 register_object oBtn4 on_key kenter send goto_search_button end_object procedure DoAddOne send DoAddDirectory to (oLst(self)) end_procedure procedure DoAddSub send DoAddSubDirectories to (oLst(self)) end_procedure procedure DoMakePath local integer lhoWorkSpace local string lsPath get_profile_string "DfComp" "MakePath" to lsPath #IFDEF get_DFMatrix_WorkSpaceLoaded if (DFMatrix_WorkSpaceLoaded()) begin get phoWorkspace of ghoApplication To lhoWorkSpace move (psAppSrcPath(lhoWorkSpace)+";"+psProgramPath(lhoWorkSpace)+";"+psDataPath(lhoWorkSpace)+";"+psDdSrcPath(lhoWorkSpace)+";"+psHelpPath(lhoWorkSpace)+";"+psSystemMakePath(lhoWorkSpace)) to lsPath end #ENDIF send DoAddSearchPath to (oLst(self)) lsPath end_procedure procedure DoDFPath local integer lhoWorkSpace local string lsPath #IFDEF get_DFMatrix_WorkSpaceLoaded get phoWorkspace of ghoApplication To lhoWorkSpace if (DFMatrix_WorkSpaceLoaded()) move (psDfPath(lhoWorkSpace)) to lsPath else move (API_AttrValue_GLOBAL(DF_OPEN_PATH)) to lsPath // Oem fixed! move (ToOem(lsPath)) to lsPath #ELSE move (API_AttrValue_GLOBAL(DF_OPEN_PATH)) to lsPath #ENDIF send DoAddSearchPath to (oLst(self)) lsPath end_procedure send DoDFPath // Default value procedure DoPath send DoAddSearchPath to (oLst(self)) (API_OtherAttr_Value(OA_PATH)) end_procedure procedure DoReset send DoReset to (oLst(self)) end_procedure object oBtn1 is a aps.Button snap SL_RIGHT relative_to (oLst(self)) set size to 14 70 procedure PopupFM send FLOATMENU_PrepareAddItem msg_DoAddOne "One folder" send FLOATMENU_PrepareAddItem msg_DoAddSub "Sub-folders" send FLOATMENU_PrepareAddItem msg_DoMakePath "MakePath" send FLOATMENU_PrepareAddItem msg_DoDFPath "DFPath" send FLOATMENU_PrepareAddItem msg_DoPath "EXE search path" send FLOATMENU_PrepareAddItem msg_none "" send FLOATMENU_PrepareAddItem msg_DoReset "Reset list" send popup to (FLOATMENU_Apply(self)) end_procedure on_item "Add folders" send PopupFM end_object object oBtn2 is a aps.Button snap SL_DOWN set size to 14 70 on_item "Remove from list" send DoRemoveDirectory to (oLst(self)) end_object object oBtn3 is a aps.Button snap SL_DOWN set size to 14 70 on_item "Reset list" send DoReset end_object object oSpacer1 is a aps.Textbox label " " snap SL_DOWN end_object object oBtn4 is a aps.Button snap SL_DOWN set size to 14 70 on_item "Find file" send DoFindFile end_object object oBtn4 is a aps.Button snap SL_DOWN set size to 14 70 register_procedure DoFindDFSource register_procedure DoFindDFData register_procedure DoFindDFRuntime register_procedure DoFindDFAll procedure PopupFM send FLOATMENU_PrepareAddItem msg_DoFindDFSource "DF source code" send FLOATMENU_PrepareAddItem msg_DoFindDFData "DF data files" send FLOATMENU_PrepareAddItem msg_DoFindDFRuntime "DF runtime files" send FLOATMENU_PrepareAddItem msg_DoFindDFAll "All DF files" send popup to (FLOATMENU_Apply(self)) end_procedure on_item "Special find (slow)" send PopupFM end_object procedure goto_search_button send activate to (oBtn4(self)) end_procedure object oBtn5 is a aps.Button snap SL_DOWN set size to 14 70 on_item "Scan PR? file" send DoFindPrnFile end_object object oFirstOccuranceOnly is a aps.CheckBox label "1st occur. only" snap SL_DOWN end_object object oSpacer2 is a aps.Textbox label " " snap SL_DOWN end_object object oBtnClose is a aps.Button snap SL_DOWN set size to 14 70 on_item t.btn.close send close_panel end_object procedure DoFindFile local integer lbFirstOnly local string lsFileMask get value of (oFrm(self)) item 0 to lsFileMask if (lsFileMask<>"") begin get select_state of (oFirstOccuranceOnly(self)) to lbFirstOnly send DoFindFile to (oSetOfFilesNew(self)) lsFileMask lbFirstOnly send Activate_FindFileResultVwReFill end else begin send obs "You must enter a file name before finding." send activate to (oFrm(self)) end end_procedure procedure DoFindDFSource local integer lbFirstOnly get select_state of (oFirstOccuranceOnly(self)) to lbFirstOnly send DoFindFileBySetOfMasks to (oSetOfFilesNew(self)) (oSetOfMasks_DFSource(self)) lbFirstOnly send Activate_FindFileResultVwReFill end_procedure procedure DoFindDFData local integer lbFirstOnly get select_state of (oFirstOccuranceOnly(self)) to lbFirstOnly send DoFindFileBySetOfMasks to (oSetOfFilesNew(self)) (oSetOfMasks_DFData(self)) lbFirstOnly send Activate_FindFileResultVwReFill end_procedure procedure DoFindDFRuntime local integer lbFirstOnly get select_state of (oFirstOccuranceOnly(self)) to lbFirstOnly send DoFindFileBySetOfMasks to (oSetOfFilesNew(self)) (oSetOfMasks_DFRuntime(self)) lbFirstOnly send Activate_FindFileResultVwReFill end_procedure procedure DoFindDFAll local integer lbFirstOnly get select_state of (oFirstOccuranceOnly(self)) to lbFirstOnly send DoFindFileBySetOfMasks to (oSetOfFilesNew(self)) (oSetOfMasks_DFAll(self)) lbFirstOnly send Activate_FindFileResultVwReFill end_procedure procedure DoFindPrnFile local integer lbFirstOnly local string lsPrnFile get SEQ_SelectFile "Select compiler listing file" "Compiler listing (*.prn)|*.PRN|Precompile listing (*.prp)|*.PRP" to lsPrnFile if lsPrnFile ne "" begin get select_state of (oFirstOccuranceOnly(self)) to lbFirstOnly send DoFindFilesCompilerListing to (oSetOfFilesNew(self)) lsPrnFile lbFirstOnly send Activate_FindFileResultVwReFill end end_procedure procedure aps_beautify send aps_align_by_moving (oFrm(self)) (oLst(self)) SL_ALIGN_RIGHT send aps_align_by_moving (oLstTotal(self)) (oLst(self)) SL_ALIGN_BOTTOM end_procedure set Border_Style to BORDER_THICK // Make panel resizeable procedure aps_onResize integer delta_rw# integer delta_cl# send aps_resize (oLst(self)) delta_rw# 0 // delta_cl# send aps_auto_locate_control (oFrm(self)) SL_DOWN (oLst(self)) send aps_beautify send aps_register_max_rc (oBtn1(self)) send aps_auto_size_container end_procedure end_object // oNewFindFileVw #ELSE /NewFindFileResult.hdr Find file, resultĿ /NewFindFileResult.lst File name Ext Size Modified Directory ____________ ___ ______ ________________ ____________________________________ ____________ ___ ______ ________________ ____________________________________ ____________ ___ ______ ________________ ____________________________________ ____________ ___ ______ ________________ ____________________________________ ____________ ___ ______ ________________ ____________________________________ ____________ ___ ______ ________________ ____________________________________ ____________ ___ ______ ________________ ____________________________________ ____________ ___ ______ ________________ ____________________________________ ____________ ___ ______ ________________ ____________________________________ ____________ ___ ______ ________________ ____________________________________ /NewFindFileResult.Total ________________________________ /NewFindFileResult.btn ______________ ______________ ______________ ______________ ___________ Ctrl+E Ctrl+S F5 Ctrl+C Esc /* activate_view Activate_FindFileResultVw for oNewFindFileResultVw object oNewFindFileResultVw is a app.Client NewFindFileResult.hdr set location to 4 0 absolute on_key kuser send Activate_SetDirTestVw object oLst is a cSetOfFilesListNew NewFindFileResult.lst set location to 1 0 relative set piSOF_Object to (oSetOfFilesNew(self)) on_key KENTER send display_file procedure OnListFilled integer liFileCount number lnBytes send total_display (SEQ_FileSizeToString(lnBytes)+" in "+string(liFileCount)+" files") end_procedure procedure DoReset forward send DoReset send Activate_SetDirTestVw end_procedure procedure CallProcedureForAllFiles integer lhMsg integer lhObj local integer liRow liBase lhSOF liSetOfFilesRow liMax local string lsFile lsFolder get piSOF_Object to lhSOF get Grid_RowCount self to liMax decrement liMax for liRow from 0 to liMax get Grid_RowBaseItem self liRow to liBase get aux_value item liBase to liSetOfFilesRow get sFileName.i of lhSOF liSetOfFilesRow to lsFile get psFilePath.i of lhSOF liSetOfFilesRow to lsFolder send lhMsg to lhObj lsFile lsFolder loop end_procedure procedure DoTextSearch local integer lhSourceFiles // if (MB_Verify("Read listed files to prepare for text search?",1)) begin move (oSourceFolder(self)) to lhSourceFiles send DoReset to lhSourceFiles send ScreenEndWait_On 0 100 send ScreenEndWait_Update 0 send ScreenEndWait_SetText "Reading folder" set piCounter of lhSourceFiles to 0 set piFileCount of lhSourceFiles to 0 send CallProcedureForAllFiles MSG_CountFile lhSourceFiles send ScreenEndWait_On 0 (piFileCount(lhSourceFiles)) send ScreenEndWait_Update 0 send ScreenEndWait_SetText "Reading source files" send CallProcedureForAllFiles MSG_HandleFile lhSourceFiles send sort_rows to lhSourceFiles 0 // Sort by filename send ScreenEndWait_Off send popup to (oTextSearchResultDisplay(self)) (row_count(lhSourceFiles)) send DoReset to lhSourceFiles // end end_procedure procedure DoEditFile local integer lhSOF liBase liRow local string lsFile lsFolder if (item_count(self)) begin get Grid_BaseItem self to liBase get piSOF_Object to lhSOF get aux_value item liBase to liRow get sFileName.i of lhSOF liRow to lsFile get psFilePath.i of lhSOF liRow to lsFolder get Files_AppendPath lsFolder lsFile to lsFile #IFDEF IS$WINDOWS runprogram BACKGROUND ("notepad "+lsFile) #ELSE #IFDEF _UNIX_ runprogram wait ("vi "+lsFile) #ELSE runprogram wait ("edit "+lsFile) #ENDIF send refresh_screen #ENDIF end end_procedure procedure display_file local integer lhSOF liBase liRow lhSource local string lsFile lsFolder if (item_count(self)) begin get Grid_BaseItem self to liBase get piSOF_Object to lhSOF get aux_value item liBase to liRow get sFileName.i of lhSOF liRow to lsFile get psFilePath.i of lhSOF liRow to lsFolder get Files_AppendPath lsFolder lsFile to lsFile #IFDEF IS$WINDOWS #ELSE object oSource is a cSource //kjhfkdjhsdkfjsd move self to lhSource send read_file lsFile end_object send DisplayFile to lhSource 0 // Line=0 send destroy_object to lhSource #ENDIF end end_procedure end_object on_key KCLEAR send DoReset to (oLst(self)) on_key KEY_CTRL+KEY_C send DoCopyFilesToDirectory to (oLst(self)) on_key KEY_CTRL+KEY_E send DoEditFile to (oLst(self)) on_key KEY_CTRL+KEY_S send DoTextSearch to (oLst(self)) object oSelectTxt is a Form NewFindFileResult.Total set focus_mode to POINTER_ONLY set window_color item 0 to 2 set location to 13 0 relative item_list on_item "" send none end_item_list end_object procedure total_display string lsValue set value of (oSelectTxt(self)) item 0 to lsValue end_procedure object oBtn1 is a app.Button NewFindFileResult.btn set location to 14 0 relative item_list on_item "Edit file" send DoEditFile to (oLst(self)) on_item "Text search" send DoTextSearch to (oLst(self)) on_item "Reset list" send DoReset to (oLst(self)) on_item "Copy files" send DoCopyFilesToDirectory to (oLst(self)) on_item t.btn.close send request_cancel end_item_list end_object procedure fill_list send fill_list to (oLst(self)) end_procedure end_object // oNewFindFileResultVw procedure Activate_FindFileResultVwReFill send fill_list to (oNewFindFileResultVw(self)) send Activate_FindFileResultVw end_procedure /NewFindFileVw.Hdr Find file:Ŀ /NewFindFileVw.Lst Search path: __________________________________________________________ __________________________________________________________ __________________________________________________________ __________________________________________________________ __________________________________________________________ __________________________________________________________ __________________________________________________________ __________________________________________________________ __________________________________________________________ __________________________________________________________ __________________________________________________________ __________________________________________________________ __________________________________________________________ __________________________________________________________ /NewFindFileVw.Total ___________________ /NewFindFileVw.Frm Find this file (wildcards allowed):[____________________] /NewFindFileVw.Btn1 _______________ cA _______________ sF2 _______________ F5 _______________ F9 _______________ cS _______________ cP /NewFindFileVw.Cb ___ 1st occur only /NewFindFileVw.Btn2 _______________ /* Use App.utl // Character Mode classes Use Buttons.utl // Button texts activate_view Activate_SetDirTestVw for oNewFindFileVw object oNewFindFileVw is a app.Client NewFindFileVw.Hdr action_bar (main_menu(self)) set location to 2 1 absolute on_key kuser send Activate_FindFileResultVw object oLst is a cSetOfDirectoriesList NewFindFileVw.Lst set location to 1 0 relative set piSetOfDirectoriesObject to (oSetOfDirectories(self)) register_object oLstTotal procedure OnListChanged integer liItems set value of (oLstTotal(self)) item 0 to (string(liItems)+" folders") end_procedure end_object object oLstTotal is a Form NewFindFileVw.Total set location to 17 0 relative set focus_mode to POINTER_ONLY set window_color item 0 to 2 item_list on_item "0 folders" send none end_item_list end_object object oFrm is a Form NewFindFileVw.Frm set location to 18 0 relative on_key kenter send goto_search_button item_list on_item "" send goto_search_button end_item_list end_object procedure activate_scope forward send activate_scope send activate to (oFrm(self)) end_procedure procedure DoAddOne send DoAddDirectory to (oLst(self)) end_procedure procedure DoAddSub send DoAddSubDirectories to (oLst(self)) end_procedure procedure DoDFPath local string lsPath move (API_AttrValue_GLOBAL(DF_OPEN_PATH)) to lsPath send DoAddSearchPath to (oLst(self)) lsPath end_procedure send DoDFPath //Default value procedure DoPath send DoAddSearchPath to (oLst(self)) (API_OtherAttr_Value(OA_PATH)) end_procedure procedure DoReset send DoReset to (oLst(self)) end_procedure object oBtn1 is a app.Button NewFindFileVw.Btn1 set location to 1 60 relative procedure PopupFM1 send FLOATMENU_PrepareAddItem msg_DoAddOne "One folder" send FLOATMENU_PrepareAddItem msg_DoAddSub "Sub-folders" send FLOATMENU_PrepareAddItem msg_DoDFPath "DFPath" send FLOATMENU_PrepareAddItem msg_DoPath "EXE search path" send FLOATMENU_PrepareAddItem msg_none "" send FLOATMENU_PrepareAddItem msg_DoReset "Reset list" send popup to (FLOATMENU_Apply(self)) end_procedure register_procedure DoFindDFSource register_procedure DoFindDFData register_procedure DoFindDFRuntime register_procedure DoFindDFAll procedure PopupFM2 send FLOATMENU_PrepareAddItem msg_DoFindDFSource "DF source code" send FLOATMENU_PrepareAddItem msg_DoFindDFData "DF data files" send FLOATMENU_PrepareAddItem msg_DoFindDFRuntime "DF runtime files" send FLOATMENU_PrepareAddItem msg_DoFindDFAll "All DF files" send popup to (FLOATMENU_Apply(self)) end_procedure item_list on_item "Add folders" send PopupFM1 on_item "Rem from list" send DoRemoveDirectory to (oLst(self)) on_item "Reset list" send DoReset on_item "Find file" send DoFindFile on_item "Special find" send PopupFM2 on_item "Scan PR? file" send DoFindPrnFile end_item_list end_object procedure goto_search_button send activate to (oBtn1(self)) set current_item of (oBtn1(self)) to 3 end_procedure object oFirstOccuranceOnly is a Button NewFindFileVw.Cb set location to 16 60 relative set select_mode to multi_select on_key kdownarrow send switch on_key kuparrow send switch_back on_key kswitch send switch on_key kswitch_back send switch_back item_list on_item "" send none set checkbox_item_state to true set select_state to false end_item_list end_object object oBtnClose is a app.Button NewFindFileVw.Btn2 set location to 18 60 relative item_list on_item t.btn.close send request_cancel end_item_list end_object procedure DoFindFile local integer lbFirstOnly local string lsFileMask get value of (oFrm(self)) item 0 to lsFileMask if (lsFileMask<>"") begin get select_state of (oFirstOccuranceOnly(self)) item 0 to lbFirstOnly send DoFindFile to (oSetOfFilesNew(self)) lsFileMask lbFirstOnly send Activate_FindFileResultVwReFill end else begin send obs "You must enter a file name before finding." send activate to (oFrm(self)) end end_procedure procedure DoFindDFSource local integer lbFirstOnly get select_state of (oFirstOccuranceOnly(self)) item 0 to lbFirstOnly send DoFindFileBySetOfMasks to (oSetOfFilesNew(self)) (oSetOfMasks_DFSource(self)) lbFirstOnly send Activate_FindFileResultVwReFill end_procedure procedure DoFindDFData local integer lbFirstOnly get select_state of (oFirstOccuranceOnly(self)) item 0 to lbFirstOnly send DoFindFileBySetOfMasks to (oSetOfFilesNew(self)) (oSetOfMasks_DFData(self)) lbFirstOnly send Activate_FindFileResultVwReFill end_procedure procedure DoFindDFRuntime local integer lbFirstOnly get select_state of (oFirstOccuranceOnly(self)) item 0 to lbFirstOnly send DoFindFileBySetOfMasks to (oSetOfFilesNew(self)) (oSetOfMasks_DFRuntime(self)) lbFirstOnly send Activate_FindFileResultVwReFill end_procedure procedure DoFindDFAll local integer lbFirstOnly get select_state of (oFirstOccuranceOnly(self)) item 0 to lbFirstOnly send DoFindFileBySetOfMasks to (oSetOfFilesNew(self)) (oSetOfMasks_DFAll(self)) lbFirstOnly send Activate_FindFileResultVwReFill end_procedure procedure DoFindPrnFile local integer lbFirstOnly local string lsPrnFile get SEQ_SelectFile "Select compiler listing file" "Compiler listing (*.prn)|*.PRN|Precompile listing (*.prp)|*.PRP" to lsPrnFile if lsPrnFile ne "" begin get select_state of (oFirstOccuranceOnly(self)) item 0 to lbFirstOnly send DoFindFilesCompilerListing to (oSetOfFilesNew(self)) lsPrnFile lbFirstOnly send Activate_FindFileResultVwReFill end end_procedure on_key KEY_CTRL+KEY_A send PopupFM1 to (oBtn1(self)) on_key KDELETE_RECORD send DoRemoveDirectory to (oLst(self)) on_key KCLEAR send DoReset on_key KFIND send DoFindFile on_key KEY_CTRL+KEY_S send PopupFM2 to (oBtn1(self)) on_key KEY_CTRL+KEY_P send DoFindPrnFile end_object // oNewFindFileVw #ENDIF