Add Workspace Parameter: Difference between revisions
From DataFlex Wiki
Jump to navigationJump to search
mNo edit summary |
m Use RefClass instead of the legacy U_ notation |
||
Line 8: | Line 8: | ||
String sWorkspaceWSFile | String sWorkspaceWSFile | ||
Handle hoWorkspace hoIniFile | Handle hoWorkspace hoIniFile | ||
Move (phoWorkSpace(ghoApplication)) to hoWorkspace | Move (phoWorkSpace(ghoApplication)) to hoWorkspace | ||
Get psWorkspaceWSFile of hoWorkspace to sWorkspaceWSFile | Get psWorkspaceWSFile of hoWorkspace to sWorkspaceWSFile | ||
Get Create | Get Create (RefClass(cIniFile)) to hoIniFile | ||
Set psFilename of hoIniFile to sWorkspaceWSFile | If (hoIniFile) Begin | ||
Set psFilename of hoIniFile to sWorkspaceWSFile | |||
Get ReadString of hoIniFile 'Workspace' sKey ' ' to sValue | |||
Send Destroy of hoIniFile | |||
End | |||
Function_Return sValue | Function_Return sValue | ||
End_Function | End_Function | ||
Line 24: | Line 27: | ||
</source> | </source> | ||
Add a new DocsFolder option to the .ws file like so: | |||
<source lang="ini"> | <source lang="ini"> | ||
//The .ws file may look like this: | //The .ws file may look like this: |
Latest revision as of 12:02, 27 July 2019
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 (RefClass(cIniFile)) to hoIniFile If (hoIniFile) Begin Set psFilename of hoIniFile to sWorkspaceWSFile Get ReadString of hoIniFile 'Workspace' sKey ' ' to sValue Send Destroy of hoIniFile End 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
Add a new DocsFolder option to the .ws file like so:
//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