// Use wa1pfolders.nui // Folders and XML envelopes use files.nui use DfDir.nui // Indentify the location DF files and directories use WinFolder.nui // WinFolder_ReadFolder message use Dates.nui // Date routines (No User Interface) use Strings.nui // String manipulation for VDF and 3.2 (No User Interface) enumeration_list define WA1P_FOLDER_PRIV_ROOT // data\wa1p define WA1P_FOLDER_PRIV_TMP // data\wa1p\tmp define WA1P_FOLDER_PRIV_XML // data\wa1p\xml define WA1P_FOLDER_PRIV_XML_TEMPL // data\wa1p\xml-templates end_enumeration_list desktop_section object oWA1P_Folders is a cArray function verify_folder integer liFolder integer lbAttemptCreate returns string integer lbCreateError lbExists string lsFolder get value item liFolder to lsFolder if (lsFolder="") begin if (liFolder=WA1P_FOLDER_PRIV_ROOT) begin get dfdir_location DFDIR_FILELIST_CFG to lsFolder get Files_AppendPath lsFolder "wa1p" to lsFolder get SEQ_FileExists lsFolder to lbExists if (lbExists=SEQIT_DIRECTORY) set value item WA1P_FOLDER_PRIV_ROOT to lsFolder else begin if (lbAttemptCreate<>0 and lbExists<>SEQIT_FILE) begin get wvaWin32_CreateDirectory (ToAnsi(lsFolder)) to lbCreateError if lbCreateError move "" to lsFolder else set value item WA1P_FOLDER_PRIV_ROOT to lsFolder end else move "" to lsFolder end end if (liFolder=WA1P_FOLDER_PRIV_TMP or liFolder=WA1P_FOLDER_PRIV_XML or liFolder=WA1P_FOLDER_PRIV_XML_TEMPL) begin // If private folder get verify_folder WA1P_FOLDER_PRIV_ROOT TRUE to lsFolder if (lsFolder<>"") begin if (liFolder=WA1P_FOLDER_PRIV_TMP) get Files_AppendPath lsFolder "tmp" to lsFolder if (liFolder=WA1P_FOLDER_PRIV_XML) get Files_AppendPath lsFolder "xml" to lsFolder if (liFolder=WA1P_FOLDER_PRIV_XML_TEMPL) get Files_AppendPath lsFolder "xml-templates" to lsFolder get SEQ_FileExists lsFolder to lbExists if (lbExists=SEQIT_DIRECTORY) set value item liFolder to lsFolder else begin if (lbAttemptCreate<>0 and lbExists<>SEQIT_FILE) begin get wvaWin32_CreateDirectory (ToAnsi(lsFolder)) to lbCreateError if lbCreateError move "" to lsFolder else set value item liFolder to lsFolder end else move "" to lsFolder end end end end function_return lsFolder end_function end_object end_desktop_section function WA1P_DirectOutput global integer liFolder string lsFile returns integer integer liChannel string lsFolder get verify_folder of oWA1P_Folders liFolder TRUE to lsFolder // Create if necessary if (lsFolder="") function_return -1 get Files_AppendPath lsFolder lsFile to lsFile get SEQ_DirectOutput lsFile to liChannel function_return liChannel end_function function WA1P_DirectInput global integer liFolder string lsFile returns integer integer liChannel string lsFolder get verify_folder of oWA1P_Folders liFolder FALSE to lsFolder // If not there, don't create if (lsFolder="") function_return -1 get Files_AppendPath lsFolder lsFile to lsFile get SEQ_DirectInput lsFile to liChannel function_return liChannel end_function function WA1P_FileExists global integer liFolder string lsFile returns integer integer liRval string lsFolder get verify_folder of oWA1P_Folders liFolder FALSE to lsFolder // If not there, don't create if (lsFolder="") function_return 0 get Files_AppendPath lsFolder lsFile to lsFile get SEQ_FileExists lsFolder to liRval function_return liRval end_function function WA1P_Folder global integer liFolder integer lbAttemptCreate returns string string lsFolder get verify_folder of oWA1P_Folders liFolder lbAttemptCreate to lsFolder // Create if necessary function_return lsFolder end_function // ************************** // **** XML envelopes **** // ************************** enumeration_list define WA1P_XML_FORM define WA1P_XML_FIELDSET define WA1P_XML_FORM_LAYOUT define WA1P_XML_FIELDSET_LAYOUT define WA1P_XML_PAGE_LAYOUT define WA1P_XML_ALL_LAYOUT // This particular one has to come after the other layout symbol define WA1P_XML_CSS_STYLE define WA1P_XML_BUTTONBAR end_enumeration_list desktop_section object oWa1pXmlExtensions is a cArray // These files all resides within the XML folder item_property_list item_property string psExtension.i item_property string psNamePluralis.i item_property string psNameSingularis.i end_item_property_list procedure add_extensions integer liXmlType string lsExtension string lsNameSingul string lsNamePlural set psExtension.i liXmlType to lsExtension set psNamePluralis.i liXmlType to lsNamePlural set psNameSingularis.i liXmlType to lsNameSingul end_procedure send add_extensions WA1P_XML_FORM ".form.xml" "form" "Forms" send add_extensions WA1P_XML_FIELDSET ".fieldset.xml" "field set" "Field sets" send add_extensions WA1P_XML_FORM_LAYOUT ".frm.layout.xml" "form layout" "Form layouts" send add_extensions WA1P_XML_FIELDSET_LAYOUT ".fst.layout.xml" "field set layout" "Field set layouts" send add_extensions WA1P_XML_PAGE_LAYOUT ".pge.layout.xml" "page layout" "Page layouts" send add_extensions WA1P_XML_ALL_LAYOUT ".layout.xml" "any layout" "All layouts" send add_extensions WA1P_XML_CSS_STYLE ".css.xml" "CSS style" "CSS styles" send add_extensions WA1P_XML_BUTTONBAR ".btb.xml" "btn bar" "Button bars" function xml_file_mask integer liXmlType returns string string lsValue get Wa1p_Folder WA1P_FOLDER_PRIV_XML true to lsValue get Files_AppendPath lsValue ("*"+psExtension.i(self,liXmlType)) to lsValue function_return lsValue end_function procedure callback_files integer liXmlType integer lhMsg integer lhObj integer liMax liRow lhWinFolderEntries liLen number lnTime string lsMask lsFolder lsTime lsName lsExt date ldDate get xml_file_mask liXmlType to lsMask send WinFolder_ReadFolder lsMask // Defined in WinFolder.nui get Wa1p_Folder WA1P_FOLDER_PRIV_XML false to lsFolder get psExtension.i liXmlType to lsExt move (length(lsExt)) to liLen move oWinFolderEntries to lhWinFolderEntries get row_count of lhWinFolderEntries to liMax decrement liMax for liRow from 0 to liMax ifnot (pbFolder.i(lhWinFolderEntries,liRow)) begin get pnLastWrite.i of lhWinFolderEntries liRow to lnTime get TS_ExtractDate lnTime to ldDate get TS_ExtractTime lnTime to lsTime get psFileName.i of lhWinFolderEntries liRow to lsName get StringLeftBut lsName liLen to lsName send lhMsg of lhObj lsName ldDate lsTime liXmlType // procedure HandleFile string lsName date ldDate string lsTime integer liXmlType end loop end_procedure function iFindType.s string lsFileName returns integer integer liMax liRow liLen string lsExtension move (lowercase(lsFileName)) to lsFileName get row_count to liMax decrement liMax for liRow from 0 to liMax get psExtension.i liRow to lsExtension move (length(lsExtension)) to liLen if (right(lsFileName,liLen)=lsExtension) function_return liRow loop function_return -1 end_function end_object // oWa1pXmlExtensions end_desktop_section function wa1p_xml_full_filename global integer liXmlType string lsName returns string string lsFolder lsExtension lsValue get WA1P_Folder WA1P_FOLDER_PRIV_XML true to lsFolder get psExtension.i of oWa1pXmlExtensions liXmlType to lsExtension get Files_AppendPath lsFolder lsName to lsValue move (lsValue+lsExtension) to lsValue function_return (replaces("..",lsValue,".")) end_function function wa1p_xml_file_exists global integer liXmlType string lsName returns integer integer lbRval string lsFile get wa1p_xml_full_filename liXmlType lsName to lsFile get SEQ_FileExists lsFile to lbRval function_return lbRval end_function procedure wa1p_xml_callback_files global integer liXmlType integer lhMsg integer lhObj send callback_files of oWa1pXmlExtensions liXmlType lhMsg lhObj end_procedure function wa1p_xml_type_name global integer liXmlType integer lbPluralis returns string if lbPluralis function_return (psNamePluralis.i(oWa1pXmlExtensions,liXmlType)) else function_return (psNameSingularis.i(oWa1pXmlExtensions,liXmlType)) end_function function wa1p_xml_filename_type global string lsFileName returns integer function_return (iFindType.s(oWa1pXmlExtensions,lsFileName)) end_function function wa1p_xml_filename_type_name global string lsFileName returns string integer liXmlType get wa1p_xml_filename_type lsFileName to liXmlType function_return (wa1p_xml_type_name(liXmlType,false)) end_function