>I think this won't work, but I want to have a method in my form that calls a method and in that method classes are defined... or something like that. Can I mix forms with text-based classes? Do I have to put them into the Main program that calls the form? Thanks!
Several strategies to choose from. First, where to put the classes:
- Stuff all your prg-based classes in one big prg and rely on CodeRef and Document View to find them
- group them in several smaller prgs (same remark)
- one class per prg, where prg and class have the same name, or where you can derive one from the other
How to instantiate them:
- have a long Set Procedure statement (I wrote a generator for that one, if you want, works fine and fast with more than a hundred prgs) and use just CreateObject() to instantiate. Pro: you don't need to know where your class is defined. Con: you don't really know where your class is defined.
- use newobject() or .newobject(). Pro: you don't need a Set Procedure statement for all those prgs, and you are forced to have a good naming convention so you can find your classes. Con: You need to know the names of the prgs, and you are forced to have a good naming convention so you can find your classes.
- in some cases (page, column) you can just set the class and classlib for member objects to your class and the prg (though it didn't work when I tried, but then I wasn't too stubborn to make it work, having found a workaround in two minutes).
In the first two cases, you can instantiate such an object pretty much anywhere where you can write code - in a prg, vcx code snippet, menu code snippet, report DE events, code in ExecScript() etc etc.