OpenWorkspaceFile - cWorkspace
Opens a Workspace using its filename
Type: Function
Return Data Type: Integer
Parameters
| Parameter | Type | Description |
|---|---|---|
| sWorkspaceFile | String | Name of the Workspace file |
Syntax
Function OpenWorkspaceFile String sWorkspaceFile Returns Integer
Call Example
Get OpenWorkspaceFile sWorkspaceFile to IntegerVariable
Description
The OpenWorkspaceFile function opens a Workspace by directly reading the file that describes it. If you want to open a Workspace that is registered, use OpenWorkspace instead.
The name of the Workspace file can optionally contain its extension (*.ws) and it can be qualified or non-qualified. If the name is non-qualified, then the class will look in the directory that the program started in for the file; if the name is qualified (that is, it contains a path in addition to a name), then it will look in that path for the file.
The return value is one of the following constants:
| Constant | Meaning |
|---|---|
| wsWorkspaceOpened | The Workspace was opened ok |
| wsWorkspaceFileNotFound | The file describing the Workspace(*.WS) was not found |
| wsDataPathEmpty | The DataPath entry was empty |
| wsFileListEmpty | The FileList entry was empty |
| wsFileListNotExist | The FileList.cfg file could not be found |
If the return value is not wsWorkspaceOpened, you can retrieve a description of the error by calling OpenWorkspaceErrorMessage and passing it the error code.
In this example, the program attempts to open a Workspace file named "ABC, Inc.Accounts.ws". If it fails, it informs the user why and aborts:
Object oApplication is a cApplication
Procedure OnCreate
Handle hoWorkspace
Integer eOpened
String sError
Get phoWorkspace To hoWorkspace
Get OpenWorkspaceFile of hoWorkspace "ABC, Inc.Accounts" To eOpened
If (eOpened <> wsWorkspaceOpened) Begin
Get OpenWorkspaceErrorMessage of hoWorkspace eOpened To sError
Send Stop_Box sError "Error Opening Workspace"
Abort
End
End_Procedure // OnCreate
End_Object // oApplication
Notes
If DoOpenWorkspaceFile (and thus DoOpenWorkspace) is executed twice or more, all tables in the application are closed and should be reopened using custom code. Do not forget in these cases to apply any other attributes to the tables being opened, such as manual relationships (using Set_Relate) or master/alias table attributes (see Alias Tables for more information). Such attributes are lost when tables are closed.
You may need to call DoClearPaths in conjunction with OpenWorkspaceFile. If, for example, you need to open a different workspace to get its path information, you need to call DoClearPaths before calling OpenWorkspaceFile. If the paths are not cleared before you try to open a second workspace file, the path properties will still contain the first workspace's paths.
See Also
Return Value
A constant (described below) indicating success or failure