Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Multiple procedures vs. one procedure - revisited
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9
OS:
Windows XP SP2
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01022173
Message ID:
01022268
Views:
13
I think I agree with Cetin.

I prefer to have classes, in one or more prgs, and then there is no need to ever use SET PROCEDURE TO, for example:
* MyClasses.PRG

define class StringFunctions as Custom && Or whatever, String related functions
  function myStringFunction1(myParametersList)
  endfunc

  function myStringFunction2(myParametersList)
  endfunc
enddefine

define class ArrayFunctions as Custom && Or whatever, Array related functions
  function myArrayFunction1(myParametersList)
  endfunc

  function myArrayFunction2(myParametersList)
  endfunc
enddefine

define class DataFunctions as Session && This are functions that will use tables, thus I use Session as baseclass
  function myDataFunction1(myParametersList)
  endfunc

  function myDataFunction2(myParametersList)
  endfunc
enddefine
Then in programs or forms or classes
loDataFunctions = newobject('DataFunctions', cSomeBasePath + 'MyClasses.PRG') && or
thisform.DataFn = newobject('DataFunctions', cSomeBasePath + 'MyClasses.PRG')
...
loDataFunctions.myDataFunction(someParameterList) && or
thisform.DataFn.myDataFunction(someParameterList)
This way you get rid of SET PROCEDURE altogether, and with that you get rid of some code, for example you do not need to store the current set("procedure") at the beginning of some processs and then restore it back at the end, something you should do, in particular if there are chances that the PRGs have some common named functions
"The five senses obstruct or deform the apprehension of reality."
Jorge L. Borges?

"Premature optimization is the root of all evil in programming."
Donald Knuth, repeating C. A. R. Hoare

"To die for a religion is easier than to live it absolutely"
Jorge L. Borges
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform