Determining the path to special locations such as the user profile folder

OpenScript ››

DETAILS

The function ASYM_StandardFolderPath() will returns the path to any of a bunch of standard Windows folders. This function can be used to get a path when you want to read or write files in any of these standard folders.


Please note that this function is considered unsupported as well as it is not in the ToolBook help system. This is because it has not yet been fully tested by the Quality Assurance team. However Technical Support is documenting this because it appears to be very stable at this time. This feature will be added in an official capacity in a future release of ToolBook.


This function exists within the Runtime System Book (TB115R.SBK). It is necessary to ensure that this Runtime System Book is added to your Bound System Books list (see File menu), in order for the function to work properly in the Runtime engine. If you forget to do this, the function will return NULL.


NOTE:

OpenScript is a programming language within ToolBook. It is more powerful than the Actions Editor programming language, however it only works within Native ToolBook. OpenScript does not function within a Web Published lesson.


using the function

Syntax:


x = ASYM_StandardFolderPath(<folder name>)

Parameters:


<folder name>

A descriptive name of the folder you are looking for. Can be any of the following values:

ApplicationData

The current user's Application Data directory (typically C:\Documents and Settings\<user name>\Application Data)

DesktopDirectory

The current user's Desktop directory (typically C:\Documents and Settings\<user name>\Desktop)

Documents

The My Documents directory (typically C:\Documents and Settings\<user name>\My Documents)

Favorites

The current user's Favorites directory (typically C:\Documents and Settings\<user name>\Favorites)

Music

The My Music directory (typically C:\Documents and Settings\<user name>\My Documents\My Music).

This value is not supported under Windows 2000.

Pictures

The My Pictures directory (typically C:\Documents and Settings\<user name>\My Documents\My Pictures)

Profile

The current user's root profile directory (typically C:\Documents and Settings\<user name>)

ProgramFiles

The Program Files directory (typically C:\Program Files)

Programs

The current user's Start Menu "All Programs" directory (typically C:\Documents and Settings\<user name>\Start Menu\Programs)

Recent

The current user's Recent directory (typically C:\Documents and Settings\<user name>\Recent)

SendTo

The current user's SendTo directory (typically C:\Documents and Settings\<user name>\SendTo)

StartMenu

The current user's Start Menu directory (typically C:\Documents and Settings\<user name>\Start Menu)

Startup

The directory that corresponds to the current user's Startup program group (typically C:\Documents and Settings\<user name>\Start Menu\Programs\Startup)

Video

The directory that corresponds to the My Video directory (typically C:\Documents and Settings\<user name>\My Documents\My Videos).

This value is not supported under Windows 2000.

LocalApplicationData

The current user's local application data directory (typically C:\Documents and Settings\<user name>\Local Settings\Application Data)

CommonApplicationData

The All Users application data directory (typically C:\Documents and Settings\All Users\Application Data)

CommonDesktopDirectory

The directory that contains items that appear on the desktop for all users (typically C:\Documents and Settings\All Users\Desktop)

CommonDocuments

The directory that contains documents that are common to all users (typically C:\Documents and Settings\All Users\Document)

CommonFavorites

The directory that contains favorite items that are common to all users (typically C:\Documents and Settings\All Users\Favorites)

CommonMusic

The directory that contains music that is common to all users (typically C:\Documents and Settings\All Users\Documents\My Music).

This value is not supported under Windows 2000.

CommonPictures

The directory that contains pictures that are common to all users (typically C:\Documents and Settings\All Users\Documents\My Pictures).

This value is not supported under Windows 2000.

CommonPrograms

The directory that contains program groups that appear on the Start menu for all users (typically C:\Documents and Settings\All Users\Start Menu\Programs)

CommonStartMenu

The directory that contains programs and folders that appear on the Start menu for all users (typically C:\Documents and Settings\All Users\Start Menu)

CommonStartup

The directory that contains programs that appear in the Startup program group for all users (typically C:\Documents and Settings\All Users\Start Menu\Programs\Startup)

CommonVideo

The directory that contains video files that are common to all users (typically C:\Documents and Settings\All Users\Documents\My Videos).

This value is not supported under Windows 2000.

Returns:

If the function succeeds, it returns the path to the specified directory without a trailing backslash. If the function fails, returns null and sets sysError to one of the following values:

null

The function succeeded, but the requested directory does not exist on this computer. This is not considered an error situation.

Invalid folder name

The folder name was not one of those listed above.

Invalid parameter

The folder name was one of those listed above, but is not supported by the current operating system.


Example

-- The following call will typically return

-- "C:\Documents and Settings\<user name>\Application Data"

applicationDataPath = ASYM_StandardFolderPath("ApplicationData")

if applicationDataPath <> null

configFileName = applicationDataPath & "\MyApp\config.txt"

openFile configFileName

readFile configFileName to EOF

...

end


MORE useful paths

There are three other locations which you might want to know how to programmatically obtain the path of:


ToolBook Product Folder

This is the folder where the ToolBook Authoring components are installed. For ToolBook 11.5 this is typically:


C:\Program Files\ToolBook\Instructor 11.5\


You can use the following function to retrieve this specific value:


x = ASYM_ProductDirectory()

ToolBook System Folder

This is the folder where the ToolBook Runtime components are installed. This is typically:


C:\Program Files\Common Files\ToolBook\TBSystem\


You can use the following system property to reference this specific value:


x = sysToolBookDirectory

ToolBook File Currently Open

This is the folder where your TBK file is currently at. Use the following function to obtain this value:


x = ASYM_PathOfFile(name of this book)



Created with the Personal Edition of HelpNDoc: Free EPub and documentation generator