//TH-Header //***************************************************************************************** // Copyright (c) 2014 KURANT Project // All rights reserved. // // $FileName : \Pkg\cWorkspaceHandlerBase.pkg // $ProjectName : The Hammer 2.0 // $Authors : wil // $Created : 02.14.2014 14:14 // $Type : GPL v2 // // Contents: // //***************************************************************************************** //TH-RevisionStart //TH-RevisionEnd Use Windows.pkg Use cLineParser.pkg Use vWin32fh.pkg Use cRegistry.pkg Use cIniFile.pkg Use cSystemStrUtils.pkg #IFNDEF ghoWorkSpaceHandlerEx Global_Variable Integer ghoWorkSpaceHandlerEx #ENDIF Define WS_WORKSPACETAG For "Workspace" Define WS_MODULETAG For "Module" Define WS_REGBASENAME For "WorkSpaces" Define WS_REGHELPNAME For "HelpPathName" // Constant strings used for the registry Define CS_BS For "\" Define CS_SOFTWARE For "SOFTWARE" Define CS_DAC For "Data Access Corporation" Define CS_DAW For "Data Access Worldwide" Define CS_DF For "DataFlex" Define CS_VDF For "Visual DataFlex" Define CS_VDFTOOLS For (CS_VDF+" Tools") Define CS_DFTOOLS For (CS_DF +" Tools") Define CS_DACVDF For (CS_DAC + CS_BS + CS_VDF + CS_BS) Define CS_DAWVDF For (CS_DAW + CS_BS + CS_VDF + CS_BS) Define CS_DAWDF For (CS_DAW + CS_BS + CS_DF + CS_BS) Define CS_DAWVDFTOOLS For (CS_DAW + CS_BS + CS_VDFTOOLS + CS_BS) Define CS_DAWDFTOOLS For (CS_DAW + CS_BS + CS_DFTOOLS + CS_BS) Define CS_SWDACVDF For (CS_SOFTWARE + CS_BS + CS_DACVDF) Define CS_SWDAWVDF For (CS_SOFTWARE + CS_BS + CS_DAWVDF) Define CS_SWDAWDF For (CS_SOFTWARE + CS_BS + CS_DAWDF ) Define CS_SWDAWVDFTOOLS For (CS_SOFTWARE + CS_BS + CS_DAWVDFTOOLS) Define CS_SWDAWDFTOOLS For (CS_SOFTWARE + CS_BS + CS_DAWDFTOOLS ) Define CS_STUDIO For "Studio" Define CS_WORKSPACES For "Workspaces" Define CS_STUDIOWORKSPACES For (CS_STUDIO + CS_BS + CS_WORKSPACES) Define CS_CURRENTWORKSPACE For "CurrentWorkSpace" Define CS_CURRENT_WORKSPACE For "Current Workspace" // The extra space is NOT a typo Define CS_SWS_PROPERTIES_KEY For "Properties" Define CS_SWS_VERSION For "Version" Define CS_SWS_WS_PATH_KEY For "WorkspacePaths" Define CS_SWS_CONFIGFILE For "ConfigFile" Define CS_SWS_TEST_KEY For "TestProjects" Define CS_SWS_PROJECTS_KEY For "Projects" Define CS_WS_DESCRIPTION For "Description" Define CS_WS_APPSRCPATH For "AppSrcPath" Define CS_WS_APPHTMLPATH For "AppHTMLPath" Define CS_WS_BITMAPPATH For "BitmapPath" Define CS_WS_DATAPATH For "DataPath" Define CS_WS_DDSRCPATH For "DDSrcPath" Define CS_WS_FILELIST For "FileList" Define CS_WS_FILELISTPATH For "FileListPath" Define CS_WS_HELPPATH For "HelpPath" Define CS_WS_HOMEPATH For "Home" Define CS_WS_IDESRCPATH For "IdeSrcPath" Define CS_WS_PROGRAMPATH For "ProgramPath" Define CS_WS_CONNECTIONS for "ConnectionIni" //@ RRS Use mProfile_StringVersion.pkg Use cFileBrowser.pkg Use cSearchPath.pkg Use cWorkspaceSortArray.pkg Use set.pkg Class cWorkSpaceTags Is a Set // Doc/Interface=Public // This function is a patched version of find_element which // does case insensitive search matching. // Workspace tags are case insensitive. Function FindWorkspace String ElemStr Returns Integer Integer ndx retVal ArrMax String ArrVal Get item_count To ArrMax Move -1 To retVal Move 0 To ndx While (ndx < ArrMax And retVal = -1) Get array_value Item ndx To ArrVal If (Uppercase(ArrVal) = Uppercase(ElemStr)) Move ndx To retVal Increment ndx Loop Function_Return retVal End_Function End_Class Class cWorkSpaceHandlerBase Is a DfObject Procedure Construct_Object Integer iRegRoot String sRegBranch Forward Send construct_object Property Boolean pbUpdateCurrentWorkspace False // This will update the registry of the current workspace when set to true Property Boolean pbEnumerateWorkspaces False // This is set to true while we are enumerating workspaces Property String psVDFVersion "7" // This is the VDF version taken from the subtree in the registry Property String psCurWrkSpace "" // The currently selected workspace tag as is stored in the registry Property String psVdfRootDir "" // public for GET and SET Property String ModuleName "" Property String HelpName "" // Public for GET, should not be directly SET Property String CurrentWorkSpaceName "" Property String CurrentModuleName "" Property String CurrentWorkspaceDescription "" Property String CurrentDataPath "" Property String CurrentBitMapPath "" Property String CurrentHelpPath "" Property String CurrentAppSrcPath "" Property String CurrentAppHtmlPath "" Property String CurrentDDSrcPath "" Property String CurrentIdeSrcPath "" Property String CurrentProgramPath "" Property String CurrentSystemDfPath "" Property String CurrentSystemMakePath "" Property String CurrentFileListPath "" Property String CurrentHomePath "" Property String CurrentConnections "" Property String CurrentWSFile "" Property String psOpenPathAddOn "" Property String psOpenPathOld "" Property String psCurrentSearchPath "" // Used by function ConvertRelativePath Object oPath Is a cLineParser Set psSepCharacter To "\" // **WVA 11/09/2005 Added the UNCPrefix as skip sequence for the parser. Set psSkipSequence To "\\" End_Object // Used by function ConvertRelativePath Object oTags Is a cLineParser Set psSepCharacter To ";" End_Object // Three arrays used to store workspace header type of data. Object oWrkSpcNames Is an Array End_Object Object oWrkSpcTags Is an cWorkSpaceTags End_Object Object oWrkSpcPaths Is an Array End_Object Property Handle phoLibraries 0 // These properties contain the data for the workspace which resembles the // current item on our oWorkspaceList object in the workspace manager // Note that this can be different from what is in the current.. properties // Most of the times THIS IS NOT what you want to use, use Current____ instead // For ex. when the user changes in the WS dialog, but does not select it, the buffer value // has changed! // psBuffer properties are INTERNAL Property String psBufferWsTag "" // Displayed Workspace Tag Property String psBufferVdfVersion "" // Displayed Version String Property String psBufferWsName "" // Displayed Description Property String psBufferHome "" // WsPath? Property String psBufferAppSrcPath "" Property String psBufferAppHtmlPath "" Property String psBufferBitmapPath "" Property String psBufferDataPath "" Property String psBufferDdSrcPath "" Property String psBufferDescription "" Property String psBufferFileList "" Property String psBufferHelpPath "" Property String psBufferIdeSrcPath "" Property String psBufferProgramPath "" Property String psBufferConnections "" Property String psBufferWsConfigFile "" // VDF12 and up use a config .ws file Get_Registry_Root To iRegRoot sRegBranch Property Integer piRegistryRoot iRegRoot Property String psRegistryBranch sRegBranch End_Procedure // Construct_Object // Convert Ansi Name to OEM Name Function AnsiNametoOemName String sName Returns String Handle hoStr String sResult Move "" To sResult Get Create (RefClass(cSystemStrUtils)) To hoStr If (hoStr) Begin Get AnsiNameToOemName Of hoStr sName To sResult Send Destroy Of hoStr End Function_Return sResult End_Function Function IsStringNumeric String sData Returns Boolean Handle hoStr Boolean bIsNumeric Move False to bIsNumeric Get Create (RefClass(cSystemStrUtils)) To hoStr If (hoStr) Begin Get IsNumeric Of hoStr sData To bIsNumeric Send Destroy Of hoStr End Function_Return bIsNumeric End_Function // IsStringNumeric Procedure StoreRegistryRoot Integer iRegRoot String sRegBranch Get_Registry_Root To iRegRoot sRegBranch Set piRegistryRoot To iRegRoot Set psRegistryBranch To sRegBranch End_Procedure // StoreRegistryRoot Procedure RestoreRegistryRoot Integer iRegRoot String sRegBranch Get piRegistryRoot To iRegRoot Get psRegistryBranch To sRegBranch Set_Registry_Root To iRegRoot sRegBranch End_Procedure // RestoreRegistryRoot Procedure Delete_Data Handle hoID Get Object_ID of oWrkSpcNames To hoID If (hoID) Begin Send Delete_Data To oWrkSpcNames End Get Object_ID Of oWrkSpcTags To hoID If (hoID) Begin Send Delete_Data To oWrkSpcTags End Get Object_ID Of oWrkSpcPaths To hoID If (hoID) Begin Send Delete_Data To oWrkSpcPaths End End_Procedure // Delete_Data // // The description of the workspace // Function WorkspaceName Integer iWorkspace Returns String String sName Get Value Of oWrkSpcNames Item iWorkspace To sName Function_Return sName End_Function // WorkspaceName Procedure Set WorkspaceName Integer iWorkspace String sName Set Value Of oWrkSpcNames Item iWorkspace To sName End_Procedure // Set WorkspaceName // Returns: // Before VDF12 this is the workspace constant // After VDF12 this is the complete location to the .sws file // Function WorkspaceTag Integer iWorkspace Returns String String sTag Get Value Of oWrkSpcTags Item iWorkspace To sTag Function_Return sTag End_Function // WorkspaceName Procedure Set WorkspaceTag Integer iWorkspace String sTag Set Value Of oWrkSpcTags Item iWorkspace To sTag End_Procedure // Set WorkspaceTag // Returns: // The workspace path before VDF12 // The .ws file location after VDF12 // Function WorkspacePath Integer iWorkspace Returns String String sPath Get Value Of oWrkSpcPaths Item iWorkspace To sPath Function_Return sPath End_Function // WorkspacePath Procedure Set WorkspacePath Integer iWorkspace String sPath Set Value Of oWrkSpcPaths Item iWorkspace To sPath End_Procedure // Set WorkspacePath Function WorkspaceCount Returns Integer Function_Return (Item_Count(oWrkSpcTags(Self))) End_Function // WorkspaceCount // The VDF version in numerical format // Same formula as the one used in the WorkspacePanel // Selected VDF Version VDF7=70, VDF8=80, VDF8.2=82 and so on // DF 20.0 = 200, DF20.1 = 201 Function StringVdfVersionToNum String sVer Returns Number Number nVer Boolean bIsNumeric Move 0 To nVer Get IsStringNumeric sVer To bIsNumeric If (bIsNumeric) Begin Move (Replaces(",",sVer,"")) To sVer // this should not happen as DAWs registry numbers are not with comma's, but there's a customer seeing it, so patched it. Move (Number(Replaces(".",sVer,""))*10) To nVer If (nVer>100) Move (nVer/10) To nVer End Function_Return nVer End_Function // StringVdfVersionToNum // The VDF version in numerical format // Same formula as the one used in the WorkspacePanel // Selected VDF Version VDF7=70, VDF8=80, VDF8.2=82 and so on Function pnBufferVdfVersion Returns Number String sVer Number nVer Get psBufferVdfVersion To sVer Get StringVdfVersionToNum sVer To nVer Function_Return nVer End_Function // pnBufferVdfVersion // The Current VDF Version // // Function fnCurrentVdfVersion Returns Number String sVersion Number nVersion Get psVDFVersion To sVersion Get StringVDFVersionToNum sVersion To nVersion Function_Return nVersion End_Function // fnCurrentVdfVersion // This function will return the registry base key based upon the version // string passed. Function fsBaseKey String sVer Returns String String sRet Number nVer Get StringVdfVersionToNum sVer To nVer If (nVer<80) Move CS_SWDACVDF To sRet Else if (nVer<180) Move CS_SWDAWVDF To sRet Else Move CS_SWDAWDF To sRet Function_Return (sRet+sVer+"\"+CS_WORKSPACES) End_Function // fsBaseKey // Converts relative pathing tokens based on a home folder. // Function ConvertRelativePath String sHome String sTag String sPath Returns String Integer iCnt iEle iPath Integer iTags Integer iRepeat String sNew sEle sCurPath Move "" To sNew If (Pos(":\",sHome)<>0) Begin // If the user puts a full path in sHome then Move sHome To sPath // sHome overrides sPath and becomes sPath itself Move ".\" To sHome End Send ParseLine To oPath sPath Move (Item_Count(oPath(Self))-1) To iCnt While "..\" In sHome Move (Replace("..\", sHome, "")) To sHome Decrement iCnt Loop Send ParseLine To oTags sTag Move "" To sTag Move (Item_Count(oTags(Self))-1) To iTags // how many relative paths? For iPath From 0 To iTags Get Value Of oTags Item iPath To sCurPath If "..\" In sCurPath Begin Move 1 To iRepeat Move (Trim(Replace("..\", sCurPath, "\"))) To sCurPath // This is a bit of a hack as it will work for the default style // .\..\..\Data style of paths, but not for all paths (but I seem to have problems coming up with a decent example, good!) While (Pos("..\",sCurPath)>0) Move (Trim(Replace("..\", sCurPath, ""))) To sCurPath Increment iRepeat Loop For iEle From 0 To (iCnt-iRepeat) Get Value Of (oPath(Self)) Item iEle To sEle If (sNew<>"") Move (sNew+"\"+sEle) To sNew Else Move sEle To sNew Loop If (sNew<>"") Move (sNew+sCurPath) To sCurPath End If ".\" In sCurPath Begin Move (Trim(Replace(".\", sCurPath, "\"))) To sCurPath For iEle From 0 To iCnt Get Value Of (oPath(Self)) Item iEle To sEle If (sNew<>"") Move (sNew+"\"+sEle) To sNew Else Move sEle To sNew Loop If (sNew<>"") Move (sNew+sCurPath) To sCurPath End If ("."=sCurPath) Begin Move "" To sCurPath For iEle From 0 To iCnt Get Value Of (oPath(Self)) Item iEle To sEle If (sNew<>"") Move (sNew+"\"+sEle) To sNew Else Move sEle To sNew Loop If (sNew<>"") Move (sNew+sCurPath) To sCurPath End If (sTag<>"") Move (sTag+";"+sCurPath) To sTag Else Move sCurPath To sTag Move "" To sNew Loop Function_Return sTag End_Function // ConvertRelativePath // // Updates the registry with the selected workspace // // sWrkSpcTag = Workspace Tag Name // sVer = Currently selected VDF Version, this does not have to match the // current version stored in the property psVDFVersion but is equal // to the registry tag format. Procedure ChangeCurrentWorkspace String sWrkSpcTag String sVer String sKey Number nVer Boolean bUpdate Get pbUpdateCurrentWorkspace To bUpdate If (bUpdate) Begin Send StoreRegistryRoot Get StringVDfVersionToNum sVer To nVer Case Begin Case (nVer<80) Set_Registry_Root To HKEY_LOCAL_MACHINE CS_SOFTWARE Move (CS_DACVDF + sVer) To sKey Set_Foreign_Profile_String sKey CS_WORKSPACES CS_CURRENTWORKSPACE To sWrkSpcTag Case Break Case (nVer>=80 and nVer<120) Set_Registry_Root TO HKEY_CURRENT_USER CS_SOFTWARE Move (CS_DAWVDF + sVer) To sKey Set_Foreign_Profile_String sKey CS_WORKSPACES CS_CURRENT_WORKSPACE To sWrkSpcTag Case Break Case (nVer>=120 and nVer<180) Set_Registry_Root To HKEY_CURRENT_USER CS_SOFTWARE Move (CS_DAWVDFTOOLS + sVer + "\" + CS_STUDIO) To sKey Set_Foreign_Profile_String sKey CS_WORKSPACES CS_CURRENT_WORKSPACE To sWrkSpcTag Case Break Case Else Set_Registry_Root To HKEY_CURRENT_USER CS_SOFTWARE Move (CS_DAWDFTOOLS + sVer + "\" + CS_STUDIO) To sKey Set_Foreign_Profile_String sKey CS_WORKSPACES CS_CURRENT_WORKSPACE To sWrkSpcTag Case Break Case End Send RestoreRegistryRoot End End_Procedure // ChangeCurrentWorkspace Function IsStudioFileInFilter String sWsFile String sVersion String sFileMask Returns String Integer iCount Integer iItem String sFileName String sPath String sWsFound String sSwsFile Handle hoSet Boolean bStop Get Create U_cFolderSet To hoSet If (hoSet) Begin Send LoadBuffer of hoSet sFileMask Get Item_Count Of hoSet To iCount If (iCount>0) Begin Decrement iCount Get psCurrentFolderName Of hoSet To sPath Move 0 To iItem while not bStop Get LongFileName Of hoSet iItem To sFileName Move (sPath+sFileName) To sFileName Get ConfigWsFile sFileName sVersion To sWsFound If (Pos(".\",sWsFound)=1) Begin Move (sPath+Replace(".\",sWsFound,"")) To sWsFound End If (lowercase(sWsFound)=lowercase(sWsFile)) Begin Move sFileName To sSwsFile // found! Move True To bStop End Increment iItem If (iItem>iCount) Begin Move True To bStop End Loop End Send Destroy Of hoSet End Function_return sSwsFile End_Function // // VDF12 + // Based on the supplied workspace .ws file this function will try to // locate the correct .sws file that belongs to it. // The supplied .ws file needs to have a fully qualified path // Function FindStudioFileForWsfile String sWsfile String sVersion Returns String Integer iCount Integer iItem String sWrkSpcTag String sPath String sFileName String sWsFound Handle hoSet Boolean bStop Move "" To sWrkSpcTag If (sWsfile<>"") Begin Get ParseFolderName sWsfile To sPath If (sPath<>"") Begin Get IsStudioFileInFilter sWsFile sVersion (sPath+"*.sws") To sWrkSpcTag If (sWrkSpcTag = "") Begin Get vParentPath sPath To sPath If (sPath<>"") Begin Get IsStudioFileInFilter sWsFile sVersion (sPath+"*.sws") To sWrkSpcTag End End End End Function_Return sWrkSpcTag End_Function // FindStudioFileForWsfile // // Reads the currently selected workspace tag from registry // // sWrkSpcTag = Workspace Tag Name // sVer = Currently selected VDF Version, this does not have to match the // current version stored in the property psVDFVersion but is equal // to the registry tag format. Function fsCurrentWorkspace String sVer Returns String String sKey String sWrkSpcTag String sWSfile Number nVer Send StoreRegistryRoot Get StringVDfVersionToNum sVer To nVer Case Begin Case (nVer<80) Set_Registry_Root To HKEY_LOCAL_MACHINE CS_SOFTWARE Move (CS_DACVDF + sVer) To sKey Get_Foreign_Profile_String sKey CS_WORKSPACES CS_CURRENTWORKSPACE To sWrkSpcTag Case Break Case (nVer>=80 and nVer<120) Set_Registry_Root To HKEY_CURRENT_USER CS_SOFTWARE Move (CS_DAWVDF + sVer) To sKey Get_Foreign_Profile_String sKey CS_WORKSPACES CS_CURRENT_WORKSPACE To sWrkSpcTag Case Break Case (nVer>=120 and nVer<180) Set_Registry_Root To HKEY_CURRENT_USER CS_SOFTWARE Move (CS_DAWVDFTOOLS + sVer + "\"+ CS_STUDIOWORKSPACES) to sKey Get_Foreign_Profile_String sKey "" CS_CURRENT_WORKSPACE to sWrkSpcTag If (sWrkSpcTag="") Begin Move (CS_DAWVDFTOOLS + sVer) to sKey Get_Foreign_Profile_String sKey "" CS_CURRENT_WORKSPACE to sWSfile Get FindStudioFileForWSfile sWsfile sVer to sWrkSpcTag End Case Else Set_Registry_Root To HKEY_CURRENT_USER CS_SOFTWARE Move (CS_DAWDFTOOLS + sVer + "\"+ CS_STUDIOWORKSPACES) to sKey Get_Foreign_Profile_String sKey "" CS_CURRENT_WORKSPACE To sWrkSpcTag If (sWrkSpcTag="") Begin Move (CS_DAWDFTOOLS + sVer) to sKey Get_Foreign_Profile_String sKey "" CS_CURRENT_WORKSPACE To sWSfile Get FindStudioFileForWSfile sWsfile sVer To sWrkSpcTag End Case Break Case End Send RestoreRegistryRoot Function_Return sWrkSpcTag End_Function // fsCurrentWorkspace // // Returns the workspace tag for the currently selected // VDF version as is currently stored in the registry. // Function CurrentWorkspaceTag Returns String String sVer String sTag Get psVDFVersion To sVer Get fsCurrentWorkspace sVer To sTag Function_Return sTag End_Function // CurrentWorkspaceTag // Gets the VDFRoot foldername for a specific VDF version // The VDFRoot folder is the folder which contains the VDF Virtual Machine // sVer = Currently selected VDF Version, this does not have to match the // current version stored in the property psVDFVersion but is equal // to the registry tag format. // Post: // - The foldername will always end with a backslash Function fsVdfRootFolder String sVer Returns String String sVdfRoot sKey sVDF Get fsBaseKey sVer To sKey Send StoreRegistryRoot Set_Registry_Root To HKEY_LOCAL_MACHINE CS_SOFTWARE Move (Replace(CS_SOFTWARE+"\",sKey,"")) To sVDF // WvA: 01-03-03, the keyname should not end with a backslash under NT to work Move (Replace("\"+CS_WORKSPACES, sVDF, "")) To sVDF Get_Foreign_Profile_String sVDF "Defaults" "VDFRootDir" To sVdfRoot Get AnsiNametoOemName sVdfRoot To sVdfRoot Get vFolderFormat sVdfRoot To sVdfRoot // Make sure the foldername ends with a "\" If (trim(sVdfRoot) = "\") Begin Set_Registry_Root To HKEY_CURRENT_USER CS_SOFTWARE Move (Replace(CS_SOFTWARE+"\",sKey,"")) To sVDF // WvA: 01-03-03, the keyname should not end with a backslash under NT to work Move (Replace("\"+CS_WORKSPACES, sVDF, "")) To sVDF Get_Foreign_Profile_String sVDF "Defaults" "VDFRootDir" To sVdfRoot Get AnsiNametoOemName sVdfRoot To sVdfRoot Get vFolderFormat sVdfRoot To sVdfRoot // Make sure the foldername ends with a "\" End Send RestoreRegistryRoot Function_Return sVdfRoot End_Function // fsVdfRootFolder // Gets the SystemDfPath for a specific VDF version // // // Function fsSystemDfPath String sVer Returns String String sSysDfPath String sKey sVDF Get fsBaseKey sVer To sKey Send StoreRegistryRoot Set_Registry_Root To HKEY_LOCAL_MACHINE CS_SOFTWARE //Move (CS_DACVDF + sVer) To sKey // **WvA: 08-03-03 Did not work for VDF8 and up Move (Replace(CS_SOFTWARE+"\",sKey,"")) To sKey Move (Replace("\"+CS_WORKSPACES, sKey, "")) To sKey Get_Foreign_Profile_String sKey CS_WORKSPACES "SystemDFPath" To sSysDfPath Get AnsiNametoOemName sSysDfPath To sSysDfPath Send RestoreRegistryRoot Function_Return sSysDfPath End_Function // fsSystemDfPath // Gets the SystemMakePath for a specific VDF version // // // Function fsSystemMakePath String sVer Returns String String sPath String sKey sVDF Get fsBaseKey sVer To sKey Send StoreRegistryRoot Set_Registry_Root To HKEY_LOCAL_MACHINE CS_SOFTWARE //Move (CS_DACVDF + sVer) To sKey // **WvA: 08-03-03 Did not work for VDF8 and up Move (Replace(CS_SOFTWARE+"\",sKey,"")) To sKey Move (Replace("\"+CS_WORKSPACES, sKey, "")) To sKey Get_Foreign_Profile_String sKey CS_WORKSPACES "SystemMakePath" To sPath Get AnsiNametoOemName sPath To sPath Send RestoreRegistryRoot Function_Return sPath End_Function // fsSystemMakePath // Retrieves the first path available in sPath if available, // otherwise the path itself is returned. // Function NextPathInFolder String sPath Returns String Integer iPos Move (Pos(';',sPath)) To iPos If (iPos<>0) Begin Move (Left(sPath,iPos-1)) To sPath End Function_Return sPath End_Function // NextPathInFolder // Strips the path from the total list of folders in sPath Function StripNextPath String sNextPath String sPath Returns String Integer iPos Move (Pos(';',sPath)) To iPos If (iPos<>0) Begin Move (Replaces(sNextPath+";",sPath,'')) To sPath End Else Begin Move (Replaces(sNextPath,sPath,'')) To sPath End Function_Return sPath End_Function // StripNextPath Function PrimaryAppSrcPath Returns String String sPath Get NextPathInFolder (CurrentAppSrcPath(Self)) To sPath Get vFolderFormat sPath To sPath Function_Return sPath End_Function Function PrimaryAppHTMLPath Returns String String sPath Get NextPathInFolder (CurrentAppHtmlPath(Self)) To sPath Get vFolderFormat sPath To sPath Function_Return sPath End_Function Function PrimaryDDSrcPath Returns String String sPath Get NextPathInFolder (CurrentDDSrcPath(Self)) To sPath Get vFolderFormat sPath To sPath Function_Return sPath End_Function Function PrimaryDataPath Returns String String sPath Get NextPathInFolder (CurrentDataPath(Self)) To sPath Get vFolderFormat sPath To sPath Function_Return sPath End_Function Function PrimaryProgramPath Returns String String sPath Get NextPathInFolder (CurrentProgramPath(Self)) To sPath Get vFolderFormat sPath To sPath Function_Return sPath End_Function // Hook method for non base class Procedure ReadLibrarySection String sSWSfile String sWSfile String sHome End_Procedure // ReadLibrarySection // Returns 1 if Successful // Reads the workspace data for all Visual DataFlex versions tested from VDF6 upto VDF9 // sWrkSpc = Workspace Tag Name // This is the full .sws file name after VDF12 // sVer = Currently selected VDF Version, this does not have to match the // current version stored in the property psVDFVersion but is equal // to the registry tag format. // sWSPath = Path where the workspace file (.ws) exists. This field is not used // for DataFlex version prior to VDF8 // After VDF12 this parameter contains the location to the .ws file, including the // filename. Usually this is a relative path // Function DoReadApplicationWorkspace String sWrkSpc String sVer String sWSPath Boolean bParseFull Returns Integer Boolean bEnumerateWorkspaces Handle hoIniFile Number nVer Integer bExists String sKey sMessage String sDescription String sSWSfile String sWSfile String sHome sApp sHTML sBmp sData sFile sDD sHelp sIDE sPrg sPath String sWrkSpcPath sConnections Move "" To sSWSfile Get StringVDfVersionToNum sVer To nVer If (nVer<80) Begin Send StoreRegistryRoot Set_Registry_Root TO HKEY_LOCAL_MACHINE CS_SOFTWARE Move (CS_DACVDF + sVer + "\"+CS_WORKSPACES) To sKey Get_Foreign_Profile_String sKey sWrkSpc CS_WS_DESCRIPTION To sDescription if (trim(sDescription) = "") begin Set_Registry_Root TO HKEY_CURRENT_USER CS_SOFTWARE Move (CS_DACVDF + sVer + "\"+CS_WORKSPACES) To sKey Get_Foreign_Profile_String sKey sWrkSpc CS_WS_DESCRIPTION To sDescription end // Get_Foreign_Profile_String sKey sWrkSpc CS_WS_APPSRCPATH To sApp Get_Foreign_Profile_String sKey sWrkSpc CS_WS_APPHTMLPATH To sHTML Get_Foreign_Profile_String sKey sWrkSpc CS_WS_BITMAPPATH To sBmp Get_Foreign_Profile_String sKey sWrkSpc CS_WS_DATAPATH To sData Get_Foreign_Profile_String sKey sWrkSpc CS_WS_DDSRCPATH To sDD Get_Foreign_Profile_String sKey sWrkSpc CS_WS_FILELISTPATH To sFile Get_Foreign_Profile_String sKey sWrkSpc CS_WS_HELPPATH To sHelp Get_Foreign_Profile_String sKey sWrkSpc CS_WS_IDESRCPATH To sIDE Get_Foreign_Profile_String sKey sWrkSpc CS_WS_PROGRAMPATH To sPrg Send RestoreRegistryRoot End Else Begin If (Pos(".sws",Lowercase(sWrkSpc))<>0) Begin Move sWrkSpc To sSWSfile If (Pos(".ws",Lowercase(sWSPath))=0) Begin // DAW's Studio also accepts it if you forget to add the .ws file extension for the ConfigFile setting. Move (Trim(sWSPath)+".ws") To sWSPath End Get ParseFolderName sWrkSpc to sWrkSpc If (Left(sWSPath,2)=".\") Begin // If the sWSPath is relative then stick the workspace path in front of it Move (sWrkSpc+replace(".\",sWSPath,"")) to sWSfile End Else Begin Move sWSPath to sWSfile // This is what you need for an ALL-in-one folder workspace setup End End Else If (Pos(".ws",Lowercase(sWSPath))=0) Begin Move (sWSPath+sWrkSpc+".ws") To sWSfile End Get vFilePathExists sWSfile To bExists If (bExists) Begin Get Create U_cInifile TO hoIniFile If (hoIniFile<>0) Begin Set psFileName Of hoIniFile To sWSFile Get SectionExists Of hoIniFile WS_WORKSPACETAG To bExists If (bExists) Begin Get ReadString Of hoIniFile WS_WORKSPACETAG CS_WS_HOMEPATH "" To sHome Get ReadString Of hoIniFile WS_WORKSPACETAG CS_WS_APPSRCPATH "" To sApp Get ReadString Of hoIniFile WS_WORKSPACETAG CS_WS_APPHTMLPATH "" To sHTML Get ReadString Of hoIniFile WS_WORKSPACETAG CS_WS_BITMAPPATH "" To sBmp Get ReadString Of hoIniFile WS_WORKSPACETAG CS_WS_DATAPATH "" To sData Get ReadString Of hoIniFile WS_WORKSPACETAG CS_WS_DDSRCPATH "" To sDD Get ReadString Of hoIniFile WS_WORKSPACETAG CS_WS_DESCRIPTION "" To sDescription Get ReadString Of hoIniFile WS_WORKSPACETAG CS_WS_FILELIST "" To sFile Get ReadString Of hoIniFile WS_WORKSPACETAG CS_WS_HELPPATH "" To sHelp Get ReadString Of hoIniFile WS_WORKSPACETAG CS_WS_IDESRCPATH "" To sIDE Get ReadString Of hoIniFile WS_WORKSPACETAG CS_WS_PROGRAMPATH "" To sPrg Get ReadString of hoIniFile WS_WORKSPACETAG CS_WS_CONNECTIONS "" to sConnections //@ RRS End Send Destroy of hoIniFile End If (bParseFull) Begin Send ReadLibrarySection sSWSfile sWSfile sHome End End Else Begin Move ("The workspace file "+sWSfile+" cannot be found.") To sMessage Error 351 sMessage Function_Return 0 End Get AnsiNametoOemName sDescription To sDescription Get AnsiNametoOemName sApp To sApp Get AnsiNametoOemName sHTML To sHTML Get AnsiNametoOemName sBmp To sBmp Get AnsiNametoOemName sData To sData Get AnsiNametoOemName sDD To sDD Get AnsiNametoOemName sFile To sFile Get AnsiNametoOemName sIDE To sIDE Get AnsiNametoOemName sPrg To sPrg // //Move (Replace((sWrkSpc+".ws"), sWSPath, "")) To sPath Get ParseFolderName sWSfile To sPath // Get ConvertRelativePath sHome sApp sPath To sApp Get ConvertRelativePath sHome sHTML sPath To sHTML Get ConvertRelativePath sHome sBmp sPath To sBmp Get ConvertRelativePath sHome sData sPath To sData Get ConvertRelativePath sHome sDD sPath To sDD Get ConvertRelativePath sHome sFile sPath To sFile Get ConvertRelativePath sHome sHelp sPath To sHelp Get ConvertRelativePath sHome sIDE sPath To sIDE Get ConvertRelativePath sHome sPrg sPath To sPrg End Set psBufferHome To sHome Set psBufferDescription To sDescription Set psBufferAppSrcPath To sApp Set psBufferAppHTMLPath To sHTML Set psBufferBitmapPath To sBmp Set psBufferDataPath To sData Set psBufferDdSrcPath To sDD Set psBufferFileList To sFile Set psBufferHelpPath To sHelp Set psBufferIdeSrcPath To sIDE Set psBufferProgramPath To sPrg Set psBufferConnections to sConnections Set psBufferWsConfigFile to sWSfile Get pbEnumerateWorkspaces To bEnumerateWorkspaces // Function_Return 1 End_Function // DoReadApplicationWorkspace // // Enumerates the workspaces area for VDF 7 or earlier and creates a list // of the available workspaces. // Function Reg_Key_Enum Integer iKey String szKeyName Returns Integer String sDesc sKey sPath sVer Number nVer Integer iWorkspaceCount Get psBufferVdfVersion To sVer Get fsBaseKey sVer To sKey Move (Replace(CS_SOFTWARE+"\",sKey,"")) To sKey Get_Foreign_Profile_String sKey szKeyName "Description" To sDesc Get AnsiNametoOemName sDesc To sDesc If (sDesc="") Begin Move ("") To sDesc End Get_Foreign_Profile_String sKey szKeyName "ProgramPath" To sPath Get vFolderFormat sPath To sPath Get WorkspaceCount To iWorkspaceCount Set WorkSpaceTag Item iWorkspaceCount To szKeyName Set WorkSpaceName Item iWorkspaceCount To sDesc Set WorkSpacePath Item iWorkspaceCount To sPath Function_Return 1 End_Function // Reg_Key_Enum // VDF12 + // Returns the config .ws file for the .sws file passed // Function ConfigWsFile String sFile String sVersion Returns String Boolean bExists Boolean bOk String sName String sHomePath String sWorksSpaceFile Handle hoIniFile Move "" To sName Move "" To sWorksSpaceFile Get Create U_cInifile TO hoIniFile If (hoIniFile<>0) Begin Get vFilePathExists sFile To bExists If (bExists) Begin Set psFileName Of hoIniFile To sFile Get KeyExists Of hoIniFile CS_SWS_WS_PATH_KEY CS_SWS_CONFIGFILE To bExists If (bExists) Begin Get ReadString Of hoIniFile CS_SWS_WS_PATH_KEY CS_SWS_CONFIGFILE "" To sWorksSpaceFile End End Send Destroy of hoIniFile End Function_Return sWorksSpaceFile End_Function // ConfigWsFile // // Sometimes the description field in the ws file is not filled in // in such a case we want to derive our description from the filename // of the studio file. // Function DeriveDescriptionFromStudioFile String sFile Returns String String sName // A description field can be missing, take the project filename as a default Get ParseFileName sFile To sName Move (replace(".sws",sName,"")) To sName Function_Return sName End_Function // DeriveDescriptionFromStudioFile // // Reads the contents of the workspace from sws and .ws file and adds the // basic information into the workspace arrays. // Procedure AddWorkspaceFromSwsFile String sVersion String sFile String sWsFile String sName Boolean bOk Integer iWorkspaceCount Get WorkspaceCount To iWorkspaceCount Set WorkSpaceTag Item iWorkspaceCount To sFile Get ConfigWsFile sFile sVersion to sWsFile // will return an empty string if the WS does not exist (for example a missing library) If (sWsFile<>"") Begin Get DoReadApplicationWorkspace sFile sVersion sWsFile false To bOk End If (bOk) Begin // Already set by DoReadApp, setting it here might just reset it back to a relative path! //Set psBufferWsConfigFile To sWsFile Get psBufferDescription To sName If (sName="") Begin Get DeriveDescriptionFromStudioFile sFile To sName Set psBufferDescription To sName End Get psBufferWsConfigFile to sWsFile End If (sName<>"") Begin Set WorkSpaceName Item iWorkspaceCount To sName Set WorkSpacePath Item iWorkSpaceCount To sWsFile End End_Procedure // AddWorkspaceFromSwsFile Procedure EnumerateLegacyVDFWSRegistryKey Handle hRootKey String sBaseKey String sTag String sDescription String sPath Boolean bOpen Boolean bExists Integer iKeyCount Integer iGetCount Integer iCount Integer iItem Integer iPos Handle hoRegistry Handle hoArray Move True To bExists Move (oWrkSpcTags(Self)) To hoArray Get Create (RefClass(cRegistry)) To hoRegistry If (hoRegistry) Begin Set pfAccessRights Of hoRegistry To KEY_READ Set phRootKey Of hoRegistry To hRootKey Get OpenKey Of hoRegistry sBaseKey To bOpen If (bOpen) Begin Get CountOfSubkeys Of hoRegistry To iKeyCount Get GetSubkeys Of hoRegistry hoArray To iGetCount Get Item_Count Of hoArray To iCount Send CloseKey Of hoRegistry For iItem From 0 To (iCount-1) Get Value Of hoArray Item iItem To sTag Get OpenKey Of hoRegistry (sBaseKey+"\"+sTag) To bOpen If (bOpen) Begin Move "" To sDescription Get ValueExists of hoRegistry "Description" to bExists If (bExists) Begin Get ReadString of hoRegistry "Description" to sDescription End Set Value of oWrkSpcNames iItem to sDescription Move "" To sPath Get ValueExists of hoRegistry "ProgramPath" to bExists // We're basing the base path of the "Programs" folder, not exactly clean, but it is quick If (bExists) Begin Get ReadString of hoRegistry "ProgramPath" to sPath Get vParentPath sPath to sPath // strip "\Programs" or whatever you called it End Set Value of oWrkSpcPaths iItem to sPath Send CloseKey of hoRegistry End Loop End Send Destroy Of hoRegistry End End_Procedure // // Enumerates the list of workspaces for the version of Visual DataFlex supplied // by the sVersion parameter. // For VDF7 and lower this data is stored in the registry. // For VDF8 and up this data is stored in a file called workspaces.ini which // can be found in the rootfolder of the visual dataflex runtimer. // Starting in VDF12 the use of the workspaces.ini file is deprecated and // the Studio only keeps a list of recent workspaces in the registry. // Post: // Also sets the current psVdfRootFolder property // Procedure DoEnumerateWorkspaces String sVersion String sCur sKey Integer hKeyWrkSpc Number nVer Integer bExists hoWSTags Integer iWrk iWorkspaceCount String sVDF sVDFRoot sWSName sWSPath sWStag sLine String sMessage Set pbEnumerateWorkspaces To True Send Delete_Data // Clear the workspace data Get fsCurrentWorkspace sVersion To sCur Get StringVDfVersionToNum sVersion To nVer Get fsVdfRootFolder sVersion To sVdfRoot Set psVdfRootDir To sVdfRoot If (nVer<80) Begin Get fsBaseKey sVersion To sKey Set psBufferVdfVersion To sVersion // Function Reg_key_Enum needs to have this set on startup Send StoreRegistryRoot Send EnumerateLegacyVDFWSRegistryKey HKEY_CURRENT_USER sKey Send EnumerateLegacyVDFWSRegistryKey HKEY_LOCAL_MACHINE sKey Send RestoreRegistryRoot End Else Begin Move (sVDFRoot+"Bin\Workspaces.ini") To sVDFRoot Get vFilePathExists sVDFRoot To bExists If (bExists) Begin Direct_Input sVDFRoot While (Not(seqeof)) Readln sLine Move (Trim(sLine)) To sLine If (sLine<>"") Begin If (Left(sLine,1)="[") Begin Get WorkspaceCount To iWorkspaceCount Move (Replace("[", sLine, "")) To sLine Move (Trim(Replace("]", sLine, ""))) To sLine Set WorkSpaceTag Item iWorkspaceCount To sLine End If "DESCRIPTION" In (Uppercase(sLine)) Begin Move (Left(sLine, Pos("=", sLine))) To sWSName Move (Replace(sWSName, sLine, "")) To sLine Move (Trim(sLine)) To sWSName Set WorkSpaceName Item iWorkspaceCount To sWSName End If (Uppercase(Left(sLine,4))="PATH") Begin Move (Left(sLine, Pos("=", sLine))) To sWSPath Move (Replace(sWSPath, sLine, "")) To sLine Get vFolderFormat (Trim(sLine)) To sWSPath Set WorkSpacePath Item iWorkspaceCount To sWSPath End End Loop Close_Input End // if file workspaces.ini exists Else Begin If (nVer<120) Begin // When on VDF12+ it's fine if the workspaces.ini file is missing // don't nag please. Move ("The file '"+sVDFRoot+"', cannot be opened.") To sMessage Error 352 sMessage End End If (nVer>=120) Begin Send ReadRecentWorkspaces sVersion End End Set pbEnumerateWorkspaces To False End_Procedure // DoEnumerateWorkspaces // Returns the workspace item number if it exists or -1 if not found // Function FindWorkspace String sWrkSpce Returns Integer Integer iWorkspace Get FindWorkspace Of oWrkSpcTags sWrkSpce To iWorkspace Function_Return iWorkspace End_Function // FindWorkspace Function AddPathToSearchPath String sNewPath String sSearchPath Returns String String sResult If (sNewPath <> '') Begin Get vFolderFormat (trim(sNewPath)) to sNewPath Move (sSearchPath + sNewPath + ";") to sResult End Else Begin Move (trim(sSearchPath)) to sResult End Function_Return sResult End_Function // AddPathToSearchPath // // Returns the dataflex search path // Function DFSearchPath Returns String String sWSSystemDFPath String sWSDataPath String sWSFileListPath String sDFPath Integer iIndex Handle hoSearchPath // Move "" To sDFPath Get CurrentSystemDFPath To sWSSystemDFPath Get CurrentDataPath To sWSDataPath Get CurrentFileListPath To sWSFileListPath // remove filelist.cfg (or similarly named filelist file) suffix from the path Move (Left(sWSFileListPath, (rightpos( "\", sWSFileListPath))-1)) To sWSFileListPath Get Create U_cSearchPath To hoSearchPath If (hoSearchPath) Begin Send AddPath Of hoSearchPath sWSDataPath Send AddPath Of hoSearchPath sWSFileListPath Send AddPath Of hoSearchPath sWSSystemDFPath Get Path Of hoSearchPath To sDFPath End Function_Return sDFPath End_Function // DFSearchPath // The Following properties need to be filled before calling this method: // psCurWrkSpace <- equal to what is passed in sWorkSpaceTag // psVdfRootDir // psVDFVersion // Procedure DoSetOpenPath String sWorkSpaceTag Handle hoLibraries String sFileList sDataPath sAppSrcPath sOpenPath sOpenPathAddOn String sDDSrcPath sBmpPath sSysDfPath sSysMakePath sVer sWSPath String sHelpPath sProgramPath sWorkSpaceDescription sWSFile String sAppHtmlPath sIdeSrcPath sHomePath sConnections String sLibraryPath String sMessage Integer iOk iWorkspace Get psVDFVersion To sVer Send DoEnumerateWorkspaces sVer If (sWorkspaceTag<>"") Begin Get FindWorkspace sWorkSpaceTag To iWorkspace If (iWorkSpace > -1) Begin Get WorkSpacePath Item iWorkspace To sWSPath Get DoReadApplicationWorkspace sWorkSpaceTag sVer sWSPath True To iOk If (iOk=1) Begin //Set_Registry_Root To HKEY_LOCAL_MACHINE CS_SOFTWARE Get psBufferDescription To sWorkSpaceDescription If (sWorkSpaceDescription="") Begin Get DeriveDescriptionFromStudioFile sWorkSpaceTag To sWorkSpaceDescription End Get psBufferDataPath To sDataPath Get psBufferAppHtmlPath To sAppHtmlPath Get psBufferAppSrcPath To sAppSrcPath Get psBufferDDSrcPath To sDDSrcPath Get psBufferIdeSrcPath To sIdeSrcPath Get psBufferBitmapPath To sBmpPath Get psBufferFileList To sFileList Get psBufferHelpPath To sHelpPath Get psBufferProgramPath To sProgramPath Get psBufferHome To sHomePath Get psBufferConnections To sConnections Get psBufferWsConfigFile To sWSFile Get phoLibraries to hoLibraries If (hoLibraries) Begin If (Item_Count(hoLibraries)>0) Begin Move "" To sLibraryPath //Get Value Of hoLibraries Item 0 To sLibraryPath //Move (sLibraryPath+"AppSrc;") To sLibraryPath //If (Right(sAppSrcPath,1)) Ne ";" Append sAppSrcPath ";" //Append sAppSrcPath sLibraryPath End End Set CurrentWorkSpaceName To sWorkSpaceTag Set CurrentWorkSpaceDescription To sWorkSpaceDescription Set CurrentAppHtmlPath To sAppHtmlPath Set CurrentAppSrcPath To sAppSrcPath Set CurrentDDSrcPath To sDDSrcPath Set CurrentDataPath To sDataPath Set CurrentIdeSrcPath To sIdeSrcPath Set CurrentBitmapPath To sBmpPath Set CurrentFileListPath To sFileList Set CurrentHelpPath To sHelpPath Set CurrentProgramPath To sProgramPath Set CurrentHomePath To sHomePath Set CurrentConnections To sConnections Set CurrentWSFile To sWSFile //@ Set CurrentSystemDFPath To sSysDfPath //@ RRS // Set CurrentSystemMakePath To sSysMakePath Get_Attribute df_Open_Path To sOpenPath If (psOpenPathOld(Self)) Eq "" Set psOpenPathOld To sOpenPath Get psOpenPathOld To sOpenPath Move (Trim(sOpenPath)) To sOpenPath If sDataPath Ne "" Append sOpenPathAddOn sDataPath ";" If sProgramPath Ne "" Append sOpenPathAddOn sProgramPath ";" If sAppSrcPath Ne "" Append sOpenPathAddOn sAppSrcPath ";" If sDDSrcPath Ne "" Append sOpenPathAddOn sDDSrcPath ";" //@ RRS To ensure the correct driver.int file is used insert sOpenPathAddOn before sOpenPath If (Right(sOpenPathAddOn,1)) Ne ";" Append sOpenPathAddOn ";" Move (sOpenPathAddOn+sOpenPath) to sOpenPath Set_Attribute df_Open_Path To sOpenPath End End Else Begin Move ("Unable to find workspace '" + Trim(sWorkSpaceTag) + "' after enumerating workspaces for DF" + Trim(sVer)) to sMessage Move (sMessage+"\nA possible cause for this error is that you have uninstalled the DataFlex version in question.\n") To sMessage Move (sMessage+"Please select another DataFlex version in the workspace selector.") to sMessage Error 354 sMessage End End End_Procedure // DoSetOpenPath // This loads the VDF version specific information // for the specified workspace. // Procedure doLoadWorkspace String sWorkspace String sRoot sVer sSysDfPath Get psVDFVersion To sVer Get fsVdfRootFolder sVer To sRoot Get fsSystemDfPath sVer To sSysDfPath Set psCurWrkSpace To sWorkspace Set psVdfRootDir To sRoot Set CurrentSystemDfPath To sSysDfPath End_Procedure // doLoadWorkspace // This loads the VDF version specific information // // Procedure doLoadVDFVersionInfo String sWorkspace Get CurrentWorkspaceTag To sWorkspace Send DoLoadWorkspace sWorkspace End_Procedure // doLoadVDFVersionInfo Procedure CheckSelectedVdfVersionExists Boolean bFound Handle hoArray Integer iRow String sVersion sSelectedVersion String[] Versions Move 0 to iRow Move False to bFound Get psVDFVersion to sSelectedVersion Move (ResizeArray(Versions,0)) to Versions Get Create (RefClass(cWorkspaceSortArray)) to hoArray If (hoArray) Begin Set pbCheckRuntimeInstalled of hoArray to True Send LoadArray of hoArray // While (iRow"-1") Begin // only tell the user when unexpected. Initial startup a DataFlex version is not selected yet, so don't tell, just select the highest one Send Info_Box ("Selected DataFlex version "+Trim(sSelectedVersion)+" was not found.\nChanging to version "+sVersion) End Set psVDFVersion to sVersion End End_Procedure Procedure InitWithCurrentWrkSpc Send CheckSelectedVdfVersionExists Send doLoadVDFVersionInfo Send DoSetOpenPath (psCurWrkSpace(Self)) End_Procedure Procedure DoInitWithWorkspace String sWorkspace Send doLoadWorkspace sWorkspace Send DoSetOpenPath sWorkspace End_Procedure // DoInitWithWorkspace End_Class // cWorkspaceHandlerBase