In order to check if a classlib is open, one can do this...
IF "\MyLib"$SET("CLASSLIB")
Oops. Better remember to UPPER MyLib. Grr. Have to remember to include the .VCX. Oh! AT() is supposed to be faster than $! That's especially true in VFP8+ and even more so the longer the string being searched. Check this supporting evidence:
Now the line becomes IF AT("\MYLIB.VCX",SET("CLASSLIB"))#0. That's a lot to type. What if I have other code where I used $ instead of AT()? If I had made and used a UDF, all those places would be updated from $ to AT() in a flash! That line of code is not readily understood. It would be much nicer if I could write IF IsVCXOpen("MyLib").
*
* IsVCXOpen.PRG
* RETURNs a logical value indicating whether the
* specified class library is already open
* by checking if it is listed in SET("CLASSLIB").
*
* Copyright (c) 2004-2005 Fox Ridge Software
* All Rights Reserved
* 120 Parsell Square
* Scarborough, ON M1B 2A6
* 416-282-3942
* http://www.foxridgesoftware.com
* Author: Mike Yearwood
*
* USAGE
* =====================================
* IF IsVCXOpen("MyLib")
* ...
* ENDIF
*
* lParameters
* tcClassLib (R) Name of classlib to look for.
*
LPARAMETERS m.tcClasslib
IF VARTYPE(m.tcClassLib)#"C" ;
OR EMPTY(m.tcClassLib)
ERROR 11
ENDIF
m.tcClassLib = UPPER(m.tcClassLib)
IF RIGHT(m.tcClassLib,4)==".VCX"
ELSE
m.tcClassLib = m.tcClassLib + ".VCX"
ENDIF
RETURN AT("\" + m.tcClassLib,SET("CLASSLIB"))#0