× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



"Bartell, Aaron L. (TC)" wrote:
> ...
> I'll agree that it kinda works in RPG, but not necessarily a good job.  What
> if I want to have multiple instantiations of the same object in my program?

I had multiple instantiations of the same object in my sample.

>
> D addr1        s       TYPE(ADDRESS)
> D addr2        s       TYPE(ADDRESS)
>
> addr1.setCity("Denver")
> addr1.setState("CO")
> ...
> addr2.setCity("Chicago")
> addr2.setState("IL")
>
> and then let's say I want to pass that address into my tax calculation
> routine. . .
>
> tax = calcTax(35.12:addr1)
>
> Now calcTax will have my addr1 object and all of its functions (getCity,
> getState, etc).  You can emulate this with data structures, sort of, except
> you don't get the functions of the object.
>

setCity (addr1 : 'Denver')
setState (addr1 : 'CO')
setCity (addr2 : 'Chicago')
setState (addr2 : 'IL')
tax = calcTax (35.12 : addr1)

Now calcTax will have your addr1 object and all of its functions.  If
you want each "object" to have a different set of functions, your
ADDRESS module needs to have procedure pointers in the ADDRESS data
structure, and the setCity etc procedures would call through to the real
procedure.  Sure, it's a bit more work on the procedure-writing side
than using a true OO language, but it's just as easy on the user's side.

difference between your version and my version is only a small syntactic
difference, "obj.fn(parm)" vs "fn(obj:parm)".

Barbara




As an Amazon Associate we earn from qualifying purchases.

This thread ...


Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

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.