OpenWorkspaceFile - cWorkspace

Opens a Workspace using its filename

Type: Function

Return Data Type: Integer

Parameters: String sWorkspaceFile

ParameterDescription
sWorkspaceFileName of the Workspace file


Return Value

A constant (described below) indicating success or failure


Syntax
Function OpenWorkspaceFile String sWorkspaceFile Returns Integer

Call: 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:

ConstantMeaning
wsWorkspaceOpenedThe Workspace was opened ok
wsWorkspaceFileNotFoundThe file describing the Workspace(*.WS) was not found
wsDataPathEmptyThe DataPath entry was empty
wsFileListEmptyThe FileList entry was empty
wsFileListNotExistThe 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

See Also

OpenWorkspace