Difference between revisions of "Passing the workspace as a parameter"

From DataFlex Wiki
Jump to navigationJump to search
m (Added to the How To category)
m (Added to Tutorials category)
Line 93: Line 93:
[[Category:How To]]
[[Category:How To]]

Latest revision as of 10:45, 25 March 2020

Parameter to choose workspace used

Previously in VDF 11.1 I have created and compiled programs on my development machine with local data on drive C:and a workspace called "Garments". When publishing the program for network use, I have passed a parameter to the application "Netgarments" and have had a separate "Netgarments.ws" file which stated that the data path was on drive F: - the network drive. Thus when using the App on the network, users saw data on drive F:

How can I do this with the new workspace system in VDF12.x and beyond?

Changes in the cApplication class

With VDF12 the workspace logic has changed a little. Previously in VDF8.x .. VDF11.x the configuration of your workspace was partly stored in the registry and partly in the .ws file. Now with VDF12.x (and later) the registry settings are gone. The settings are now stored in a .sws file along with one (or more) .ws files.

In order to select the correct .ws file, the cApplication class now has a property called


and its default is


which is the name of the default .ws file. If you want to use your old .ws file, just change the value of that particular property.

An Example of a program that uses a subclass of cApplication

the program:

 Use dfAllEnt.pkg
 use DFAbout
 #REPLACE CURRENT$WORKSPACE   "Training.Mapps121" //default - modified by calling param
 Register_Object oClientArea
 // 1) use package for application workspace
 Use MyApplication.pkg //Workspc for multico workspace mapps121
 // 2) Set date attributes as needed
 Set_Date_Attribute sysdate4_State to dftrue
 Set_Date_Attribute Date4_State    to dftrue
 Set_Date_Attribute epoch_value    to 60
 // 3) Application Workspace - help type and name
 Object oApplication is a cMyApplication
 End_Object  // oApplication

The cApplication subclass

  Class MyApplication is a cApplication
    Procedure OnCreate
        String sCompanyFolder stemp Programname
        cmdline sCompanyFolder // get a parameter from the command line!
        If (sCompanyFolder="") Move "TRAINING" to scompanyfolder //default to traing db if execeuted without param
        move (uppercase(sCompanyFolder)) to sCompanyFolder
        Send DoOpenWorkspace (sCompanyFolder -".mApps121") //CURRENT$WORKSPACE
        Get_Attribute DF_OPEN_PATH to sTemp        

        //we use a file, REFNUM2, to contain info specific to this company
        Open refnum2
        Move (trim(refnumA2("COMPFOLD"))) to sTemp //function to get a param from the company control file
        If (sTemp<>sCompanyFolder) Begin
            Send stop_box ("Company ID mismatch in refnum2 file"  * sCompanyFolder * sTemp) 
            Abort //showstopper
        Set psCompanyFolder to sCompanyFolder
        //colour for visual clues
        Move (trim(refnumA2("COMPCOLR")))   to sTemp
        Set psCompanyColour to sTemp
        //Formal Company Name
        Move (trim(RefNumA2("COMPANY")))    to sTemp
        Set psCompany  to sTemp

        //and much much more, you get the picture

        Set peHelpType to htHtmlHelp
        Set pbEnterKeyAsTabKey to True
        Set psProduct to "KirkNet"
        Set psProgram to (Module_Name(Self))
        Set psHelpFile to ((Module_name(self)) + ".htm")       
        Set pbPreserveEnvironment to False