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




"Now we may all agree that using global variables is evil, but up to
V5R4 (just a few months, just a few months, ...) files had to be global.
That means that all programs written before 6.1 that use files (that
might be quite a few) have a lot of global variables."

Just because the files needed to be global doesn't mean the global
fields needed to be used.

On v5r4 Any sub-procedure could locally define a external qualified data
structure for input or output and then use that on all file input and
output.

D InputDS E DS EXTNAME(filename:*INPUT) qualified
READ Filename InputDS;

Using that type of data structure the sub-procedure could "protect" its
access to the data and not affect the globally defined fields.

Just because the global field is there doesn't mean it's a good idea to
use it.
Which means it's up to the programmer to choose to use the global fields
or define the field locally to the procedure.


Chris Hiebert
Programmer/Analyst
Disclaimer: Any views or opinions presented are solely those of the
author and do not necessarily represent those of the company.

-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx
[mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of Joep Beckeringh
Sent: Monday, April 29, 2013 5:53 PM
To: RPG programming on the IBM i (AS/400 and iSeries)
Subject: Re: Procedure PR/PI question

I think the point 'what sson' was trying to make, was that passing a
global variable as a CONST parameter to a local subprocedure can get you
in trouble, as the procedure changes the global variable. Now we may all
agree that using global variables is evil, but up to V5R4 (just a few
months, just a few months, ...) files had to be global. That means that
all programs written before 6.1 that use files (that might be quite a
few) have a lot of global variables.

If you use an input field as a CONST parameter to a local procedure and
that procedure (or another local procedure that is called by this
procedure) reads another record in the same file, your CONST parameter
suddenly changed. So I can understand what sson's feelings about using
VALUE for local procedures.

Joep Beckeringh


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.