|
>> Does anyone have any ideas (Brad Stone, Joe Pulta, Hans >> Boldt) how to write >> RPG code in a way that simulates an Object Orientated approach? Well Alistair even though I am not listed in your list of luminaries I do have an idea for you... It is one that I am considering myself. Back in the good ole days of C++ before there were any C++ compilers there was a pre-processor called CFRONT. This would take the C++ code and then pre-process it and make C code. The same methodology could be applied to RPG... I too would love if some OO extensions were added to RPG mainly because I am often explicitly enjoined by my client that I will ONLY WRITE in RPG... No choices of which hammer to drive the screw with :-) So you may want to see if you can get ahold of the CFRONT source code and if you understand C and C++ that should give you some great and proven ideas on how to do what you want. Oh and if you decide to wait on me... Well I have about a zillion projects that have nearly the same priority and fun factor so I do not know if or when I will get around to looking at this closer. :-) One of the big things about OO for me is encapsulation, C++ does this by having an implicit *this pointer contained in every object and every object method takes *this as a parameter so that it knows which instance of the object to work on. This could be simulated manually without too much trouble by adding a pointer as the first parameter of your object methods. For example, make a service program that contains a few methods... New which returns a pointer to the storage on the heap for a newly created instance of an object. Free which takes as it's only argument the pointer to an object instance that you want to release from memory. Then perhaps some functions like IsNull which would take one pointer and return a boolean (indicator). Oh and Hans, would it be hard to make a synonym for *On as a symbolic constant... *True? I know I know I can add True as a constant (which is what I do) but it would be more clear for me if *True were used rather than *On (Both meaning the same thing of course). *False = *Off naturally being in the same request. Then you could make some functions that take 2 pointers as input for boolean and assignment operations... IsEqual, IsGreater, IsLesser, Assign... Last after you have all your "object" functions determined count up the pointer parameters (of which basically all your parameters will have to be defined so that you can override what in the world they are). and create a dispatch function.... Until we can qualify what service program procedure we want to invoke ServicePgm.Method you will have to lose type checking so that you can do what you want... Either that or Wart everything with the object name as a prefix/suffix... Both being quite ugly :-) With the dispatch function you would name it by the object name... CallP Customer('New' : NewCustPtr) for example... Hope that helps Eric ---------------------------------- Eric N. Wilson President Doulos Software and Computer Services +--- | This is the RPG/400 Mailing List! | To submit a new message, send your mail to RPG400-L@midrange.com. | To subscribe to this list send email to RPG400-L-SUB@midrange.com. | To unsubscribe from this list send email to RPG400-L-UNSUB@midrange.com. | Questions should be directed to the list owner/operator: david@midrange.com +---
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.