PathAtIndex - cWorkspace
Returns a single path from a string containing multiple delimited paths
Type: Function
Return Data Type: String
Parameters
| Parameter | Type | Description |
|---|---|---|
| sPaths | String | A string containing multiple paths |
| iIndex | Integer | One-based index of the path to retrieve |
Syntax
Function PathAtIndex String sPaths Integer iIndex Returns String
Call Example
Get PathAtIndex sPaths iIndex to StringVariable
Description
The PathAtIndex function is used to return a single path from a string containing multiple semi-colon delimited paths.
Use CountOfPaths to retrieve the number of paths in a string and use this function to retrieve them individually.
This example shows the paths contained in psDfPath after opening a Workspace:
Object oApplication is a cApplication
Procedure OnCreate
Handle hoWorkspace
Integer eOpened iPath iNumPaths
String sError sDfPath sPath
Get phoWorkspace To hoWorkspace
Get OpenWorkspace of hoWorkspace "ABC, Inc.Accounts" To eOpened
If (eOpened = wsWorkspaceOpened) Begin
Get psDfPath of hoWorkspace To sDfPath
Get CountOfPaths of hoWorkspace sDfPath To iNumPaths
For iPath from 1 To iNumPaths
Get PathAtIndex of hoWorkspace sDfPath iPath To sPath
Showln iPath ": " sPath
Loop
End
Else Begin // Workspace not opened
Get OpenWorkspaceErrorMessage of hoWorkspace eOpened To sError
Send Stop_Box sError "Error Opening Workspace"
Abort
End
End_Procedure
End_Object
Another typical use of this function is to return the first path of one of the properties that contains multiple paths. In this example, if you wanted to set the Initial_Folder property of an OpenDialog to the first bitmap path, this is what you would do:
// Assumes you have an open Workspace and a OpenDialog instance called oOpenDialog
Get phoWorkspace of ghoApplication To hoWorkspace
Get psBitmapPath of hoWorkspace To sBitmapPath
Get PathAtIndex of hoWorkspace sBitmapPath 1 To sPath
Set Initial_Folder of oOpenDialog To sPath
See Also
Return Value
A single path from the string of paths.