Passing the workspace as a parameter: Difference between revisions

m
Added to Tutorials category
m (Added to Tutorials category)
 
(8 intermediate revisions by 4 users not shown)
Line 21: Line 21:
If you want to use your old .ws file, just change the value of that particular property.
If you want to use your old .ws file, just change the value of that particular property.


===The program===
===An Example of a program that uses a subclass of cApplication===
the program:
the program:


<source lang="vdf">
  //AB-StoreStart
  //AB-StoreStart
  Use dfAllEnt.pkg
  Use dfAllEnt.pkg
Line 42: Line 43:
  Object oApplication is a cMyApplication
  Object oApplication is a cMyApplication
  End_Object  // oApplication
  End_Object  // oApplication
//etc
</source>


===The cApplication subclass===
===The cApplication subclass===


<source lang="vdf">
   Class MyApplication is a cApplication
   Class MyApplication is a cApplication
     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
 
         //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
          
          
        Open refnum2
        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)  
             Abort //showstopper
             Abort //showstopper
         End
         End
         Set psCompanyFolder to sCompanyFolder
         Set psCompanyFolder to sCompanyFolder
          
          
        //colour for visual clues
         Move (trim(refnumA2("COMPCOLR")))  to sTemp
         Move (trim(refnumA2("COMPCOLR")))  to sTemp
         Set psCompanyColour to sTemp
         Set psCompanyColour to sTemp
        Set Color to clYellow
          
          
        //Formal Company Name
         Move (trim(RefNumA2("COMPANY")))    to sTemp
         Move (trim(RefNumA2("COMPANY")))    to sTemp
         Set psCompany  to sTemp
         Set psCompany  to sTemp
          
 
         //and much much more, you get the picture
        //....
 
         Set peHelpType to htHtmlHelp
         Set peHelpType to htHtmlHelp
 
        //
         Set pbEnterKeyAsTabKey to True
         Set pbEnterKeyAsTabKey to True
         Set psProduct to "KirkNet"
         Set psProduct to "KirkNet"
Line 84: Line 90:
     End_Procedure
     End_Procedure
   End_Class
   End_Class
</source>
[[Category:How To]]
[[Category:Tutorials]]