Here's a function I created that does what you want.
Note that this editor uses a non-monospaced font so the formatting is screwy.
Olan
//*********************************************************************
// Object : n_cst_rpt_liblist
// Function : of_Get_library_list()
//
// Ancestor : (None)
// Access : public
// Arguments : (None)
//
// Returns : String
// Throws :
//
// Description : Returns the library list for the application,
// including the locations where the client has placed
// the application-specific Report Library (PBL) that
// was delivered with the application.
//
// Example: SWAT_RPTS on "M:\Shared\Reports".
//
//********************************************************************
// Revision History
//
// Developer Date Version Description
// --------- ----------- ----------- -------------------------------
// O Knight 24-SEP-2003 3.0.1.5 Replaced listbox with PFC code.
// O Knight 09/11/2003 3.0.1.4 Initial version.
//
//********************************************************************
// Copyright © 1994-2003 Intec Telecom Systems.
//********************************************************************
boolean lb_exists
long ll_rowcount, ll_row, ll_result, ll_pos, ll_idx
long ll_jdx, ll_count
n_cst_filesrv inv_filesrv
n_ds lds
string ls_libraries, ls_lib_path, ls_applid, ls_new
string ls_currdir, ls_filename
n_cst_dirattrib lnv_dirlist []
// Get the current set of libraries associated with this application
ls_libraries = GetLibraryList ()
f_SetFilesrv (inv_filesrv, TRUE)
ls_currdir = inv_filesrv.of_GetCurrentDirectory ()
// Create the datastore to access the System Preferences table
lds = CREATE n_ds
lds.DataObject = "d_rpt_system_preferences"
ll_result = lds.SetTransObject (SQLCA)
// See if the user has any Report Library Paths defined
// in the System Preferences table (Chas.prfrnc)
FOR ll_idx = 1 TO 2
IF (ll_idx = 1) THEN
ls_applid = gnv_app.is_appl_id // Is an application-specific path defined?
ELSE
SetNull (ls_applid) // Is a global library path defined?
END IF
ll_rowcount = lds.Retrieve (ls_applid)
IF (ll_rowcount > 0) THEN
// Get the library path specified
ls_lib_path = lds.GetItemString (1, "value")
// Ensure that the library path is not null
IF (IsNull (ls_lib_path)) OR (TRIM (ls_lib_path) = "") THEN CONTINUE
// Does the path already exist in the library list?
ll_pos = Pos (Upper (ls_libraries), Upper (ls_lib_path))
IF (ll_pos = 0) THEN
// See if any PBLs are in this library path
lb_exists = DirectoryExists ( ls_lib_path )
IF (NOT (lb_exists)) THEN CONTINUE
// Get the list of PBLs from this directory
ls_new = ls_lib_path + "\*.pbl"
ll_count = inv_filesrv.of_DirList (ls_new, 0, lnv_dirlist)
// Add these PBLs to the application's library list
FOR ll_jdx = 1 TO ll_count
// Get the next PBL listed
ls_filename = Lower (Trim (lnv_dirlist [ll_jdx].is_filename))
ls_new = ls_lib_path + "\" + ls_filename
// Add the library to the application library list
ls_libraries = ls_libraries + "," + ls_new
// Increment the number of libraries added
il_libs_added ++
NEXT
// Update the set of libraries for the application
IF (ll_jdx > 0) THEN
// ---------------------------------------------------------------
// This next step is what allows PBLs that are not associated with
// the current application to be included in the application.
//
// NOTE: YOU CANNOT TEST THIS FEATURE IN THE DEVELOPMENT IDE!!!!
// YOU CAN ONLY USE IT IN A RUNTIME ENVIRONMENT!!!!
// ---------------------------------------------------------------
ll_result = SetLibraryList (ls_libraries)
END IF
END IF
END IF
NEXT
IF (IsValid (lds)) THEN DESTROY lds
IF (IsValid (inv_filesrv)) THEN DESTROY inv_filesrv
RETURN ls_libraries