Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Anyone still use 'Set Procedure To'?
Message
De
10/08/2007 10:11:59
Dragan Nedeljkovich (En ligne)
Now officially retired
Zrenjanin, Serbia
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 8 SP1
OS:
Windows XP SP2
Database:
Visual FoxPro
Divers
Thread ID:
01247248
Message ID:
01247362
Vues:
33
>>it's faster to instantiate them
>
>Hi Christof,
>
>Ain't that the truth! It's one of the reasons that Bo Durban is working on converting the GDIPlusX library to a set of PRGs instead of VCXs. Not only is the instantiation an order of magnitude faster the size of the application is much smaller when compiled with a PRG. Also, PRG's allow a developer to optionally exclude certain portions (classes, procedures,etc.) of the PRG using compiler directives, whereas with a VCX you can't even exclude certain classes from the build... it's either build the entire VCX in or nothing. This might not seem like much, but with huge library or procedural files where only a portion of the code is needed it can significantly reduce the app's footprint.

I've seen the size of an exe drop from 8 megs to less than 4 when everything was converted to prg classes (yes, someone did that), and it actually flies.

The difference, though, is more of taste than practical - with Document View, you can easily flip between procedures in a file, be they in a .prg or in a .vcx. The main reason to have a Set Procedure statement is that in code you can instantiate a class with CreateObject() or .addObject(), so if a class is moved to another vcx or prg or even from a vcx to a prg (or vice versa), you don't have to change the code.

Here's what I use - it only requires that all the vcxes and prgs are in the project, including SetProc.prg, which then only has to be run during startup:
***
***	gen_setproc.prg
***

* 	13.05.04 11:27:59
***
#DEFINE hLF CHR(10)
#DEFINE hCR CHR(13)
#DEFINE hCRLF CHR(13)+CHR(10)
#DEFINE hTab	CHR(9)

LOCAL a[1], i, lcComma, lctext

TEXT TO lctext NOSHOW TEXTMERGE

***
***	setproc.prg
***

* 	<<datetime()>>
* 	<<version()>>
* Generated by <<program()>>

***
*** ----------------------------------
***

	Set Procedure To
	Set Classlib To
ENDTEXT
cTab=hTab
lcSemi=";"
SELECT NAME FROM {your project name here}.pjx INTO ARRAY a WHERE TYPE="P" AND NOT exclude
ASORT(a)
lctext = lctext + hCR+"Set Procedure To	"
lcComma=""

FOR i=1 TO ALEN(a)
	lcName=CHRTRAN(a[i], CHR(0), "")
	IF NOT FILE(lcName)
		LOOP
	ENDIF
	IF " "$lcName
		lcName=CHR(34)+lcName+CHR(34)
	ENDIF
	lctext = lctext + lcComma+lcSemi+hCRLF+cTab+lcName
	lcComma=","
ENDFOR
lctext = lctext + hCR + hCR+"Set Classlib To	"
SELECT NAME FROM ids.pjx INTO ARRAY a ;
	WHERE TYPE="V" AND NOT exclude
ASORT(a)
lcComma=""
FOR i=1 TO ALEN(a)
	lcName=CHRTRAN(a[i], CHR(0), "")
	IF NOT FILE(lcName)
		LOOP
	ENDIF
	IF " "$lcName
		lcName=CHR(34)+lcName+CHR(34)
	ENDIF
	lctext = lctext + lcComma+lcSemi+hCRLF+cTab+lcName
	lcComma=","
ENDFOR
USE IN ids
lctext = lctext + hCR+ hCR
STRTOFILE(lctext, "{path to your prgs here}\setproc.prg")

back to same old

the first online autobiography, unfinished by design
What, me reckless? I'm full of recks!
Balkans, eh? Count them.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform