Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Can I create classes in a vcx programatically?
Message
 
To
20/12/2006 22:11:03
Mike Yearwood
Toronto, Ontario, Canada
General information
Forum:
Visual FoxPro
Category:
Classes - VCX
Miscellaneous
Thread ID:
01179343
Message ID:
01179724
Views:
12
Mike,

I am glad you made that statement. Years ago guys I considered super geeks were shilling class methods even though we could see the diminished performance when compared to a UDF.

People hardly think about the "clock" anymore - but we should - it makes the difference between great and an average product.

I do something similar to what you are considering. I run it in my main program, just after the procedure files are loaded (that way it can call existing base project UDF's, but before a read events.
PROCEDURE CheckForProgramedUpdates()
lcRunFxp=CheckforFXP()
IF FILE(lcRunFxp)
   DO (lcRunFxp)
   ERASE (lcRunFxp)
ENDIF 
ENDPROC
IF it's a really complicated process it might be more helpful to rework the base code or write an XML interpreter.

>Hi Bill
>
>A raw .prg UDF is faster than a method of a class.
>
>>I want to ship compiled code to be used with a desk top exe. The procecures are created from tabular data. -- case statements based on logic that must be evaluated sequentially -- Since the rules are based on many different variables, the determination of a result is not as simple as a single or even multi key lookup. I created an fxp file that produced a huge preformance improvement. Now it isseven times faster than a looping structure that sequentially evaluates sets of rules. The rules are produced in a 5 table join. Now I am able to do the joins in the creation of the fxp rather than at runtime. I think speed also results from logic evaluation in the compiled code rather than through parsing of words in the case statements.
>>
>>Now I'm wondering what is the best suggestion for accessing the code at runtime. I may not be able to get the code included in the exe and the application doesn't use a container (no stored procedures). It seems that there are 6 options. What are the pros and cons?
>>
>>1. Set procedure to the fxp. Nested cases.
>>2. Set procedure to the fxp. Many Procs within the fxp.
>>3. Create a prg-based class with many methods.
>>4. Create a vcx with many classes? (Having trouble with this because when I run the following code, the class is not recognized when I try to instantiate it.
>>
>>(xxxproc is the foxpro code
>>propstring is a list of properties)
>>
>>thisclass = "xyz"
>>CREATE CLASS &thisclass OF carcalc as "Custom"
>>USE carcalc.vcx
>>LOCATE for objname = thisclass AND baseclass ="custom"
>>REPLACE methods with xxxproc,PROPERTIES WITH PROPSTRING,RESERVED1 WITH "Class",Reserved1 WITH "1"
>>
>>5. Execscript on memo fields.
>>6. Put compiled code in memo fields,write to file, and execute.
>>
>>The VCX seems like a good place to put the code. I would probably eliminate the readable code and ship only the compiled code. I just can't get the right method to make it.
Imagination is more important than knowledge
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform