GetFolder


The GetFolder function returns the name of a folder. The folder browser can access any folder on the system, including shared network folders and the Windows desktop. The selected folder is returned without a trailing backslash.

 

Syntax

sNewFolder, bSuccess = GetFolder( sStartFolder )

where

    sStartFolder is the path to the initial folder.

    bSuccess is an optional success flag. If [OK] is clicked, the function returns the folder name sFolder and bSuccess=true. If the dialog is canceled, "",false is returned.

  

The dialog consists of a history drop box at top, and a large tree control below. You can select folders from the history list, then click the down-arrow to update the new folder into the tree control. The [Refresh] button updates the tree with any file system changes that have occurred while the dialog is open.

The initial path, sStartFolder, may look something like this (note the double backslashes in this literal string):

     "C:\\Documents and Settings\\Default User\\My Documents\\Images"

If the user cancels the dialog using any closing method other than [OK], this function returns boolean false as the second argument. You do not have to use the second return value in the script.

The Desktop item forms the root of the file system tree. If Desktop is selected and[OK] is clicked, then the return value is an empty string, "", and bSuccess=true. Similarly, ifDesktop\My Computer\C: is selected, then the return value is C:\.

Example

Let sPath = "C:\\Documents and Settings\\Default User\\My Documents". Then

sFolder, bSuccess = GetFolder(sPath) ; Assert(bSuccess)

 

opens the folder dialog at the position of "My Documents". The Assert following GetFolder is used to test how the user closed the dialog. If the user did not click [OK], then GetFolder returns bSuccess=false.

Related Topics

GetString

GetFileName