× 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.



As I have said before, due to the fact that basically the only way to
access file fields from a subprocedure is for the subprocedure to access
the global field variables, it is  "ok" to do so. While in some cases
you could pass the values in to the subprocedure, and now that you can
easily pass datastructures it is probably a good idea to do so, when you
can. There are many instances where you must access the global field
variables, for instance any time you do a file I/O operation in the
subprocedure you have no choice but to access the global field
variables. However when you have a situation like this you should
minimize the use of the global field variables, ideally you would either
only use the file within the subprocedure, thereby pretending that the
file was local to the subprocedure, or only use the file's fields as the
source/destination for the values of local work variables. 

The point is that all code should respect the scope of the variables
that are used within it. Until we can have F-specs within a subprocedure
there is no option but to use global variables to access files, but that
is the only time I can think of when global variables should be used
from within a subprocedure, obviously there are exceptions to every rule
and you may be able to come up with some but they should be few and far
between.

Also, I am not saying it is impossible to write code that works well,
that contains subprocedures that use global variables. What I am saying
is that over the long term code where subprocedures don't access global
variables will be far more bug free and maintainable than code where
subprocedures do access global variables. 

Joe Lee

>>> Lim.Hock-Chai@xxxxxxxx 08/24/2004 06:52:50 >>>
Joe P and Bob C:
It is true that using you save some typing time when using sub-routine.
 However, the problem comes when sometime in the future you happen to
have to create a sub-proc and it really need to execute one the of
sub-routine that was created because of you want to save some tying
time.

Joe L:  
For some reasons you seems to think that it is reaaaally bad to
access/update global variables from sub-proc.  I don't know about your
shop, but if I apply such a rule in my shop, I don't think I will be
using sub-proc very often at all.  All fields from F spec are global. 
In most case, I need to use them in most of my sub-proc.  If would be
quite a pain if I've to pass them in every time I need them.
I'm not saying that it is good to access/update them in sub-proc, but
if you design it correctly, it should be fine.

--
This is the RPG programming on the AS400 / iSeries (RPG400-L) mailing
list
To post a message email: RPG400-L@xxxxxxxxxxxx 
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l 
or email: RPG400-L-request@xxxxxxxxxxxx 
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 thread ...

Follow-Ups:

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.