Passing the workspace as a parameter: Difference between revisions

From DataFlex Wiki
Jump to navigationJump to search
Line 48: Line 48:
     Procedure OnCreate
     Procedure OnCreate
         String sCompanyFolder stemp Programname
         String sCompanyFolder stemp Programname
         cmdline sCompanyFolder
       
 
         cmdline sCompanyFolder // get a parameter from the command line!
        //
         If (sCompanyFolder="") Move "TRAINING" to scompanyfolder //default to traing db if execeuted without param
         If (sCompanyFolder="") Move "TRAINING" to scompanyfolder //default to traing db if execeuted without param
         move (uppercase(sCompanyFolder)) to sCompanyFolder
         move (uppercase(sCompanyFolder)) to sCompanyFolder
          
          
          
         //
         Send DoOpenWorkspace (sCompanyFolder -".mApps121") //CURRENT$WORKSPACE
         Send DoOpenWorkspace (sCompanyFolder -".mApps121") //CURRENT$WORKSPACE
          
         //
         Get_Attribute DF_OPEN_PATH to sTemp         
         Get_Attribute DF_OPEN_PATH to sTemp         
         //Showln sTemp
         //Showln sTemp
          
         //
         Open refnum2
         Open refnum2
         Move (trim(refnumA2("COMPFOLD"))) to sTemp //function to get a param form the correct company control file
         Move (trim(refnumA2("COMPFOLD"))) to sTemp //function to get a param form the correct company control file
   
        //
         If (sTemp<>sCompanyFolder) Begin
         If (sTemp<>sCompanyFolder) Begin
             Send stop_box ("Company ID mismatch in refnum2 file"  * sCompanyFolder * sTemp) //dont show, it would be a security weakness
             Send stop_box ("Company ID mismatch in refnum2 file"  * sCompanyFolder * sTemp) //dont show, it would be a security weakness
Line 76: Line 77:
          
          
         Set peHelpType to htHtmlHelp
         Set peHelpType to htHtmlHelp
 
        //
         Set pbEnterKeyAsTabKey to True
         Set pbEnterKeyAsTabKey to True
         Set psProduct to "KirkNet"
         Set psProduct to "KirkNet"

Revision as of 12:01, 20 February 2008

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

psAutoOpenWorkspace

and its default is

config.ws

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.

The program

the program:

//AB-StoreStart
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        
       //Showln sTemp
       //
       Open refnum2
       Move (trim(refnumA2("COMPFOLD"))) to sTemp //function to get a param form the correct company control file
       //
       If (sTemp<>sCompanyFolder) Begin
           Send stop_box ("Company ID mismatch in refnum2 file"  * sCompanyFolder * sTemp) //dont show, it would be a security weakness
           Abort //showstopper
       End
       Set psCompanyFolder to sCompanyFolder
       
       Move (trim(refnumA2("COMPCOLR")))   to sTemp
       Set psCompanyColour to sTemp
       Set Color to clYellow
       
       Move (trim(RefNumA2("COMPANY")))    to sTemp
       Set psCompany  to sTemp
       
       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          
   End_Procedure
 End_Class