|
You can use of both but when you use one over the other depends upon what you're trying to do. Procedures, for example, can help make your code much easier to read and understand since you can see exactly what is being passed into and returned from a given routine. I tend to use subroutines mainly for high level control functions such as in the main code loop of my programs and if I need to get a large section of hard to read code (like writing a block of HTML in CGI programs) out of more complex logic to improve readability. As an example of this, let's say that you want to get a price for a widget for customer 123, if you use a subroutine, you end up with code like this: eval item='widget' eval custid=123 exsr getprice eval itemprice=price If you instead have a getprice procedure, your code now becomes: eval itemprice=getprice('widget',123) This not only improves readability but it encapsulates the function of getting a price and since something like that tends to be used very often, it could be moved into a service program which can be shared with other programs. Also, procedure names can be much longer than subroutine names so you can make the program more self-documenting. Also note that you can return data structures as the result of a procedure which is great for doing things like getting information about things like customers and products which may have fairly involved look-up logic. Again, these types of routines tend to be used by many programs so once you've written a procedure to do this, it can go in a service program to be used by other programs. Matt -----Original Message----- From: MURALI DHAR [mailto:nmuralidhar@rediffmail.com] Sent: Thursday, August 15, 2002 10:40 AM To: rpg400-l@midrange.com Subject: diff btw Procedures and Routines why do we use procedures only in modules in ILE programs?why nt subroutines?whats the diff ...plz kindly answer me Best regards Murali __________________________________________________________ Give your Company an email address like ravi @ ravi-exports.com. Sign up for Rediffmail Pro today! Know more. http://www.rediffmailpro.com/signup/ _______________________________________________ This is the RPG programming on the AS400 / iSeries (RPG400-L) mailing list To post a message email: RPG400-L@midrange.com To subscribe, unsubscribe, or change list options, visit: http://lists.midrange.com/cgi-bin/listinfo/rpg400-l or email: RPG400-L-request@midrange.com Before posting, please take a moment to review the archives at http://archive.midrange.com/rpg400-l.
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.