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



Hi Vern,

We have quite a strict standard for defining variables.

The whole data dictionary is defined as a template DS.

Client name would be defined as

D gCltNm S LIKE ( data dictionary name )

Or

D wCltNm S LIKE ( data dictionary name )

The first declaration is intended to be global, the second for a sub procedure.
Yes, I realise we need to evolve to longer variable names, but for client name its very simple.

Anyway I stumbled upon a program with this kind of structure :

D Main PR
D P1 etc

* Global variables.
D gVar

D Main PI
D P1 etc

* Local variables.
D wVar



The programmer did not seem to realise that wVar is global.

Then I found another program like that, and another,....

I'm not sure where or if that could be a problem, confounding local and global variables, but the authors need to be informed. I wanted to rapidly find all the offending modules if possible.







-----Message d'origine-----
De : rpg400-l-bounces@xxxxxxxxxxxx
[mailto:rpg400-l-bounces@xxxxxxxxxxxx] De la part de Vern Hamberg
Envoyé : mardi 4 août 2009 13:32
À : RPG programming on the IBM i / System i
Objet : Re: Global variable search

David

You do really need a change management system! Or a
cross-reference tool!

OK - I said it!

But since you don't, think about how things are defined in
RPG IV source. You will have to use a program to read through
each record of the source member. You know how to specify
different members to be processed, I know.

First, a prototyped main is going to have PR in a certain
position of D specs. So you have a test for a prototype. Then
the name will be the same as the program - it will be 10
characters and somewhere near the beginning of the D spec
with PR in the right place.

As to global variables, well, they are in D specs outside of
any subprocedures. As soon as you hit a P spec, you are done
working with global variables.

This is a quick think on the process - there are probably
other issues.
You might want to find any program-defined variables, if any
are still in use. Don't assume anything. Those defined in the
main procedure are global, I think. I don't remember whether
one can have program-defined variables in subprocedures -
haven't used such a variable in maybe a decade, at least.

HTH
Vern

David FOXWELL wrote:
Hi,

Would anyone know of a way to extract a list of programs
having prototyped main procedures and then extract the global
variables from that program?

We have a nightly updated file which is the product of
DSPMOD. I can get the programs I want from that, if the
procedure name matches the module name and the programmer has
named the prototype that way. To see the global variables I'm
recompiling the source and reading the compiler listing.

Thanks.

--
This is the RPG programming on the IBM i / System i
(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 ...

Replies:

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.