Add Workspace Parameter: Difference between revisions

From DataFlex Wiki
Jump to navigationJump to search
(Changing How To/Cookbook -> Tutorials)
mNo edit summary
Line 3: Line 3:
I just put this code near the bottom of the source (.src)
I just put this code near the bottom of the source (.src)


<source lang="vdf">
  Function MyValueWS String sKey Returns String
  Function MyValueWS String sKey Returns String
     String sValue
     String sValue
Line 33: Line 34:
  Description=MASS - Membership Administration Software Solution - CEPU
  Description=MASS - Membership Administration Software Solution - CEPU
  DocsFolder=c:\Test\Docs
  DocsFolder=c:\Test\Docs
</source>


[[Category:Tutorials]]
[[Category:Tutorials]]

Revision as of 18:20, 8 June 2008

How to add a parameter in your .ws file and pass it in to your program. In this example I need to know where the document folder is found for each user, usually the same location for all users. This then allows the Docs folder to be found anywhere on a network. I use a global variable to store the location. If not defined in the .ws file default it from the home location.

I just put this code near the bottom of the source (.src)

 Function MyValueWS String sKey Returns String
    String sValue
    String sWorkspaceWSFile 
    Handle hoWorkspace hoIniFile
    Move (phoWorkSpace(ghoApplication)) to hoWorkspace
    Get psWorkspaceWSFile of hoWorkspace to sWorkspaceWSFile 
    Get Create U_cIniFile to hoIniFile
    Set psFilename of hoIniFile to sWorkspaceWSFile 
    Get ReadString of hoIniFile 'Workspace' sKey ' ' to sValue
    Send Destroy of hoIniFile 
    Function_Return sValue
 End_Function
 
 Get MyValueWS "DocsFolder" to gsDocsFolder 
 If gsDocsFolder eq "" Begin
    Get psHome of (phoWorkspace(oApplication(Self))) to gsDocsFolder
    Move (gsDocsFolder-"Docs") to gsDocsFolder
 End


 //The .ws file may look like this:
 [Workspace]
 Home=..\
 BitmapPath=.\Bitmaps
 DataPath=c:\Members\CEPU
 HelpPath=.\Help
 ProgramPath=.\Programs
 FileList=c:\Members\CEPU\Filelist.cfg
 Description=MASS - Membership Administration Software Solution - CEPU
 DocsFolder=c:\Test\Docs