Thank you all for excellent leads. This is the solution I finally landed upon:
1. Create a list of currently loaded class libraries using the SYS(2001,"CLASSLIB") function. Parse the return string to an array.
2. Traverse the library array and use the AVCXCLASSES to build a list of class for each library. Then look to see if the target class is in each library recursively.
I have pasted in my code for this below.
Thank you again.
Larry Rix
*)Method ..........: qlClassAvailable
* Class ...........: rCustom
* Version .........: 1.0
* Author...........: Larry Rix
* Date ............: 07/26/2001 - 13:11:13
* Notice ..........: Copyright (c) 2001 Financial Times Energy, All Rights Reserved.
* Compiler ........: Visual FoxPro 06.00.8961.00 for Windows
*)Description .....: Tests for the availability of a class in all currently loaded
*) ................: class libraries. If found, returns TRUE, FALSE otherwise.
*) ................:
*) ................:
*) ................:
*)Parameters ......: tcClassName
*) ................:
*) ................:
*) ................:
* Calling Samples .: llClassExists = THIS.qlClassAvailable("rCustom")
* .................:
* .................:
* Return Value(s) .: TRUE or FALSE
* .................:
* .................:
*]Changes .........: None
*].................:
*].................:
lparameters tcClassName
******************************
*-- Preconditions
******************************
******************************
*-- Main Routine
******************************
local llClassFound, lnLibraryCount, lnLibrary, lnClassCount, lcLibraryName
local lnClass, lcClassName, lcTestClassName
*-- One column for the vcx path and file name,
*-- and second column for the alias name.
local array laLibraryList[1,2]
*-- A list of classes with a VCX library.
local array laClassList[1,1]
store .null. to laClassList
lnLibraryCount = 0
lnLibrary = 0
lnClassCount = 0
lcClassName = alltrim(upper(tcClassName))
lcTestClassName = space(0)
llClassFound = .f.
*-- Parse the sys(2001) results into an array
= THIS.qaParseLibraryList(@laLibraryList)
*-- Count how many libraries we currently have in memory
lnLibraryCount = alen(laLibraryList,1)
for lnLibrary = 1 to lnLibraryCount
lcLibraryName = laLibraryList[lnLibrary,2]
lnClassCount = avcxclasses(laClassList, lcLibraryName)
for lnClass = 1 to lnClassCount
*-- Only if we find the class name in our VCX class list
*-- do we change our return flag to TRUE
lcTestClassName = alltrim(upper(laClassList[lnClass,1]))
if (( lcTestClassName == lcClassName ))
llClassFound = .t.
endif
endfor
endfor
******************************
*-- Postconditions
******************************
return llClassFound
*)Method ..........: qaParseLibraryList
* Class ...........: rCustom
* Version .........: 1.0
* Author...........: Larry Rix
* Date ............: 07/26/2001 - 13:11:13
* Notice ..........: Copyright (c) 2001 Financial Times Energy, All Rights Reserved.
* Compiler ........: Visual FoxPro 06.00.8961.00 for Windows
*)Description .....: Parses the results of the sys(2001,"CLASSLIB") function
*) ................: and populates the arrayed list reference with the results.
*) ................:
*) ................:
*) ................:
*)Parameters ......: @taLibraryList
*) ................:
*) ................:
*) ................:
* Calling Samples .: local array laLibraryList[1,1]
* .................: = qaParseLibraryList(@laLibraryList)
* .................:
* Return Value(s) .: TRUE
* .................:
* .................:
*]Changes .........: none
*].................:
*].................:
lparameters taLibraryList
******************************
*-- Preconditions
******************************
******************************
*-- Main Routine
******************************
local lcLibraryString, lnItemCount, lnRow, lnSegmentSize
local lcSegmentString, lcVCXPath, lcAlias, lnAliasLength
*-- Obtain the list of libraries currently in memory
*-- (i.e., the result of SET CLASSLIB ... additive instruction).
*-- NOTE: We tack on a comma to the front of the list and then translate
*-- the string with the underscore character to make the list prep complete.
lcLibraryString = alltrim(sys(2001,"CLASSLIB")) + ","
lcLibraryString = strtran(lcLibraryString, ",", "_")
*-- Obtain the number of items in the delimited list (i.e. "_" count + 1)
lnItemCount = occurs("_", lcLibraryString)
*-- Re-DIM our arrayed list to the number of items. We need one column for
*-- the path and vcx name and then a second column for the alias name.
dimension taLibraryList[lnItemCount,2]
for lnRow = 1 to lnItemCount
lnSegmentSize = atc("_", lcLibraryString, 1) - 1
*-- Cull out the next entry (or first or last as the case might be)
*-- of our lcLibraryString so we can work with it.
*-- The string is in the form of "[Drive:Path\VCXFileName] AS [Alias]"
lcSegmentString = left(lcLibraryString,lnSegmentSize)
*-- Switch the spaces in the string (before and after the AS keyword)
*-- to "_" characters. This will mark the end of the drive path and alias.
lcSegmentString = strtran(lcSegmentString,"_",space(0))
lcSegmentString = strtran(lcSegmentString," ","_")
*-- Get our drive, path, and VCX file name from the segment string
lcVCXPath = left(lcSegmentString, (atc("_", lcSegmentString, 1) - 1) )
*-- Finally, get the alias name - Get the length first and then the string
lnAliasLength = len(lcSegmentString) - atc("_", lcSegmentString, 2)
lcAlias = right(lcSegmentString, lnAliasLength)
taLibraryList[lnRow,1] = lcVCXPath
taLibraryList[lnRow,2] = lcAlias
if (( lnRow < lnItemCount ))
lcLibraryString = right(lcLibraryString, (len(lcLibraryString) - lnSegmentSize - 2) )
endif
endfor
******************************
*-- Postconditions
******************************
return
Previous
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only