Friday, July 25, 2008  | 
 
Login
 


Forgot Password ?
     
 
List
 
     

Host for the Toronto Ontario FoxPro User's Group

Fox Ridge Software Inc. - The best in custom business software.
 
Is VCX Open?
 
Location: BlogsFoxPro / Visual FoxPro tips, tricks and traps.    
Posted by: myearwood 12/20/2005

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

Copyright ©2005 Mike Yearwood
Permalink |  Trackback
     
Copyright 2005-2009 by Fox Ridge Software, Inc. Privacy StatementTerms Of Use