Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SET PROCEDURE and SET CLASSLIB
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
01292307
Message ID:
01292340
Views:
21
>You can do that or you can add 'Classes' and 'Programs' subfolders to VFP search path in development and use SET CLASSLIB and SET PROCEDURE w/o path.
>
>
>>
>>That's what I thought. The problem is that my code does an ADIR() for each file, then loops thru the array
>>and SET's CLASSLIB to each VCX. Since the file are not there on the client, the SET CLASSLIB never happens.
>>
>>So, since the path is ignored in runtime, I can hardcode in the development path?


Ok, I chose to add the development path to the SET PROCEDURE and SET CLASSLIB commands and
I'm still having trouble. Here's what I have:
** Loads all VCX's in the Classes folder into an array
HIDDEN PROCEDURE _GetClasslibs()

** Define variables
LOCAL aFiles[1] AS String
LOCAL iFile AS Integer
LOCAL iTotFiles AS Integer
LOCAL sClassLibrary AS String

WITH This

	** Populate an array with the names of all the class libraries
	** in the Classes subfolder
	iTotFiles = ADIR(aFiles, ADDBS(._sDevLoc) + "classes\*.vcx")

	** Size the array property enough to hold all the library names
	DIMENSION ._aClassLibraries[iTotFiles]

	** Loop once for each class library
	FOR iFile = 1 TO iTotFiles
	
		** Form the path and name of the class library
		sClassLibrary = LOWER(ADDBS(._sDevLoc)+ "classes\" + aFiles[iFile, 1])
		
		** Add the class library to the array of class libraries
		._aClassLibraries[iFile] = sClassLibrary
		
	ENDFOR

ENDWITH


ENDPROC	
Then I do this to SET CLASSLIB:
** Loads all VCX's in the Classes folder into an array
PROCEDURE LoadClassLibraries()
** Define variables
LOCAL iLibrary AS Integer
LOCAL sLibrary AS String

WITH This

	** Close all open libraries
	SET CLASSLIB TO 

	** If the class library array has not been loaded...
	IF TYPE("._aClassLibraries[1]") = "L"

		** Call the method to load the class library array
		._GetClasslibs()
		
	ENDIF


	** Loop once for each library
	FOR iLibrary = 1 TO ALEN(._aClassLibraries, 1)
	
		** Extract the library name from the array
		sLibrary = ._aClassLibraries[iLibrary]
	
		** Open the class library
		SET CLASSLIB TO (sLibrary) ADDITIVE

	ENDFOR

ENDWITH
ENDPROC
In runtime, I get "Invalid subscript reference" because there are no classlibs to load in the client location.

I would prefer to laod the VCX's automaticall this way, because then as I create new VCX's,
I won't have to worry about about coding SET CLASSLIB all over the place. This way seems
more generic.

Any way to automate this?
Everything makes sense in someone's mind
public class SystemCrasher :ICrashable
In addition, an integer field is not for irrational people
Previous
Reply
Map
View

Click here to load this message in the networking platform