// Use FvHomDir.pkg // Dialogs for saving and opening FastViews Use Files.utl // Utilities for handling file related stuff Use ItemProp.nui // ITEM_PROPERTY command for use within arrays Use WildCard.nui // WildCardMatch function Use WinUser.nui // User_Windows_User_Name function desktop_section object oFastViewsOnDisk is a cArray property string psCurrentDirectory public "" property string psCurrentMask public "" property integer piCurrentSortOrder public 0 item_property_list item_property string psFileName.i item_property integer piMainFile.i item_property integer piChildFile.i item_property integer piViewType.i item_property string psViewTitle.i item_property string psMainFileName.i item_property number pnDateTime.i item_property integer piSize.i end_item_property_list procedure AddFile string lsFile string lsDir integer liSize number lnDateTime integer liFile liChannel liRow string lsViewTitle lsChildName if (WildCardMatch(lsFile)) begin get row_count to liRow set psFileName.i liRow to lsFile get SEQ_ComposeAbsoluteFileName lsDir lsFile to lsFile get SEQ_DirectInput lsFile to liChannel set pnDateTime.i liRow to lnDateTime set piSize.i liRow to liSize if (liChannel>-1) begin readln channel liChannel lsFile if (lsFile="FastView 1.0 - View definition") begin readln lsViewTitle set psViewTitle.i liRow to lsViewTitle readln liFile // ViewType set piViewType.i liRow to liFile // ViewType readln lsFile // Throw away UseGenericDD readln liFile // Main File set piMainFile.i liRow to liFile set psMainFileName.i liRow to (FDX_AttrValue_FILE(ghFDX,DF_FILE_DISPLAY_NAME,liFile)) readln liFile // Child file set piChildFile.i liRow to liFile if (lsViewTitle="") begin get piMainFile.i liRow to liFile get FDX_AttrValue_FILELIST ghFDX DF_FILE_DISPLAY_NAME liFile to lsViewTitle get piChildFile.i liRow to liFile if liFile begin get FDX_AttrValue_FILELIST ghFDX DF_FILE_DISPLAY_NAME liFile to lsChildName move (lsViewTitle*"/"*lsChildName) to lsViewTitle end set psViewTitle.i liRow to lsViewTitle end end send SEQ_CloseInput liChannel end end end_procedure procedure DoSort integer liColumn set piCurrentSortOrder to liColumn send sort_rows liColumn end_procedure procedure ReadDirectory string lsDir string lsMask send WildCardMatchPrepare lsMask send delete_data set psCurrentDirectory to lsDir set psCurrentMask to lsMask send SEQ_Load_ItemsInDir lsDir send SEQ_CallBack_ItemsInDir SEQCB_FILES_ONLY MSG_AddFile self end_procedure procedure ReReadDir send ReadDirectory (psCurrentDirectory(self)) (psCurrentMask(self)) send DoSort (piCurrentSortOrder(self)) end_procedure // ------------------------------------------------------------ // From here on down (inside this object) is only concerned with // the CopyFilesFromRootToUser procedure (and has nothing to do // with the above). property integer piFileCount public 0 property string psTargetPath public "" procedure HandleFileCount string lsFile string lsPath if (WildCardMatch(lsFile)) set piFileCount to (piFileCount(self)+1) end_procedure procedure HandleFileCopy string lsFile string lsPath integer lbHopefullySuccess string lsTargetPath if (WildCardMatch(lsFile)) begin get Files_AppendPath lsPath lsFile to lsPath get psTargetPath to lsTargetPath get Files_AppendPath lsTargetPath lsFile to lsTargetPath get SEQ_CopyFile lsPath lsTargetPath to lbHopefullySuccess end end_procedure procedure CopyFilesFromRootToUser string lsRootPath string lsPath set piFileCount to 0 send SEQ_Load_ItemsInDir lsRootPath send WildCardMatchPrepare "*.fvw" // Views send SEQ_CallBack_ItemsInDir SEQCB_FILES_ONLY MSG_HandleFileCount self send WildCardMatchPrepare "*.fvc" // Collections send SEQ_CallBack_ItemsInDir SEQCB_FILES_ONLY MSG_HandleFileCount self if (piFileCount(self)) begin // Only if there were any files at all if (MB_Verify("Do you want to copy the view definitions of the previous version of FastView?",1)) begin set psTargetPath to lsPath send WildCardMatchPrepare "*.fvw" // Views send SEQ_CallBack_ItemsInDir SEQCB_FILES_ONLY MSG_HandleFileCopy self send WildCardMatchPrepare "*.fvc" // Collections send SEQ_CallBack_ItemsInDir SEQCB_FILES_ONLY MSG_HandleFileCopy self end end end_procedure end_object // oFastViewsOnDisk end_desktop_section function FastView_HomeDirectory global returns string function_return (psCurrentDirectory(oFastViewsOnDisk(self))) end_function function FastView_RootDirectory global returns string string lsRval get FastView_HomeDirectory to lsRval if (lsRval<>"") get SEQ_ExtractPathFromFileName lsRval to lsRval function_return lsRval end_function procedure FastView_SetupHomeDirectory global returns integer integer liExists lbCreateError lhChannel lbFastViewRootFolderExists string lsFileListPath lsPath lsReadMe lsUser lsRootPath set psCurrentDirectory of (oFastViewsOnDisk(self)) to "" get SEQ_FindFileAlongDFPath "filelist.cfg" to lsPath get Files_AppendPath lsPath "FastView" to lsPath get SEQ_FileExists lsPath to lbFastViewRootFolderExists move lsPath to lsRootPath // move (SEQ_ComposeAbsoluteFileName(lsPath,"FastView")) to lsPath get User_Windows_User_Name to lsUser get Files_AppendPath lsPath lsUser to lsPath get SEQ_FileExists lsPath to liExists if (liExists=SEQIT_NONE) begin if (MB_Verify4("FastView needs to create a folder for saving view definitions.","","The folder will be located under the 'data' folder at this location:",lsPath,DFTRUE)) begin ifnot lbFastViewRootFolderExists begin // First we create the root folder if necessary- get wvaWin32_CreateDirectory (ToAnsi(lsRootPath)) to lbCreateError if lbCreateError begin send obs "Sorry! Folder could not be created." lsPath "View definitions can not be saved to disk" function_return DFFALSE end end get wvaWin32_CreateDirectory (ToAnsi(lsPath)) to lbCreateError if lbCreateError begin send obs "Sorry! Folder could not be created." lsPath "View definitions can not be saved to disk." function_return DFFALSE end else begin get SEQ_ComposeAbsoluteFileName lsPath "ReadMe.txt" to lsReadMe move (SEQ_DirectOutput(lsReadMe)) to lhChannel if (lhChannel>=0) begin writeln channel lhChannel ; "This folder was created by the FastView program as a placeholder" writeln "for FastView definitions and associated files." writeln "" writeln "Extensions are as follows:" writeln "" writeln " *.fvw Files containing the definition of a View" writeln "" writeln " *.fvc Such a file defines a group of views (and thus" writeln " .fvw files) that may be opened in one go using" writeln " the 'Open View Collection' feature of FastView." writeln " Deleting such a file does not delete the view " writeln " definitions themselves, only the grouping of them." writeln "" writeln " Default.fvc If this file is present FastView automatically" writeln " load this on starting the program." writeln "" writeln " FastLoad.fdx This file is used if the 'fast load' option is" writeln " enabled. Deleting the file will simply disable" writeln " 'fast load'. It may be re-enabled by selecting" writeln " 'File'->'WS Options'->'Fastload'" writeln "" writeln "This folder may safely be removed if the FastView program is no" writeln "longer used." send SEQ_CloseOutput lhChannel end if lbFastViewRootFolderExists begin // Here we ask the user if he wants to copy the previous contents of // the FastView folder into the new folder. send CopyFilesFromRootToUser of oFastViewsOnDisk lsRootPath lsPath end end set psCurrentDirectory of (oFastViewsOnDisk(self)) to lsPath function_return DFTRUE end else function_return DFFALSE end if (liExists=SEQIT_FILE) begin send obs "Path must be a folder (and not a file)" lsPath "View definitions can not be saved to disk" function_return DFFALSE end if (liExists=SEQIT_DIRECTORY) begin set psCurrentDirectory of (oFastViewsOnDisk(self)) to lsPath function_return DFTRUE end end_procedure desktop_section object oFastViewOpenFileSL is a aps.ModalPanel label "Open FastView definition" set locate_mode to CENTER_ON_SCREEN on_key ksave_record send close_panel_ok on_key kcancel send close_panel property integer piResult public DFFALSE object oLst is a aps.Grid // send GridPrepare_AddCheckBoxColumn send GridPrepare_AddColumn "View title" AFT_ASCII30 send GridPrepare_AddColumn "Type" AFT_ASCII3 send GridPrepare_AddColumn "Main table" AFT_ASCII20 send GridPrepare_AddColumn "File name" AFT_ASCII20 send GridPrepare_AddColumn "Size" AFT_NUMERIC4.0 send GridPrepare_AddColumn "Modified" AFT_ASCII20 send GridPrepare_Apply self on_key KEY_CTRL+KEY_R send sort_data on_key KEY_CTRL+KEY_W send DoWriteToFile on_key kEnter send close_panel_ok procedure mouse_click integer liItem integer liGrb if ((liItem-1)"") begin get SEQ_ComposeAbsoluteFileName lsPath lsFile to lsFile function_return lsFile end function_return "" end_function function FastView_FileExists global string lsFile returns integer local string lsPath get FastView_RootDirectory to lsPath if (lsPath<>"") begin get SEQ_ComposeAbsoluteFileName lsPath lsFile to lsFile function_return (SEQ_FileExists(lsFile)) end function_return DFFALSE end_procedure function FastView_DirectInput global string lsFile returns integer local string lsPath get FastView_RootDirectory to lsPath if (lsPath<>"") begin get SEQ_ComposeAbsoluteFileName lsPath lsFile to lsFile function_return (SEQ_DirectInput(lsFile)) end function_return -1 end_procedure function FastView_DirectOutput global string lsFile returns integer local string lsPath get FastView_RootDirectory to lsPath if (lsPath<>"") begin get SEQ_ComposeAbsoluteFileName lsPath lsFile to lsFile function_return (SEQ_DirectOutput(lsFile)) end function_return -1 end_procedure