|
What would you propose the structure to be?
The fact that they wrote in RPG IV and used subroutines makes me barf.
Good structured design would say that you have procedures that make decisions
and control and procedures that perform actions.
Generally speaking, you would have a mainline that drives(Makes decisions and
controls) and then calls lower level procedures to perform actions. This sounds
a bit like what they were trying to do here but using subroutines can make the
whole thing an exercise in frustration. Subroutines are nothing but computed
goto's.
"A procedure does one thing and only one thing and can be described with the
use of a conjunctive verb (AND OR)."
All this works very well if you are using procedure and using them correctly
since a procedure is basically a black box. It has a known set of inputs and a
known set of outputs and its own local variables. If you see a procedure that
says BuildOpenString, do you really need to know how it works as long as it
works? If you are getting back what you want, who cares? But try to implement
with a Subroutine. If you are debugging you have no choice except go down into
the code and walk through it all and because everything is global, you have to
consider everything in the program because the subroutine could have changed
anything.
So if you are planning to rewrite it a using a good structure and using
procedures correctly, I would say, go for it. If you just want to put
everything inline, then I would leave it alone.
This is a recent example of a green screen. The top level just makes the
decision and controls. If I maintaining this program and I want to add for
error checking, I can just go to the ValidInput(). Is this what they were
doing?
If Not ScreenOpen;
ScreenOpen = cTrue;
Open TG0002_D01;
EndIf;
LoadScreenFields();
MSGF_ClearProgramMessageQueue(cMainProcedureName :
SystemDataStructure.ModuleName:
ProgramName );
DoU 0 = 1;
// Display subfile message.
DisplaySubfileEndOnSubfileMessageQueue = cTrue;
SFM_C_PGMQ = '*';
Write SFMSG_CTL;
ExFmt RD01_01;
MSGF_ClearProgramMessageQueue(cMainProcedureName :
SystemDataStructure.ModuleName:
ProgramName );
MSGF_ClearErrorIndicators(*IN :
cStartErrorIndicators:
cEndErrorIndicators );
Select;
When FI01.KeyPressed = F3 or
FI01.KeyPressed = F12;
Return FI01.KeyPressed;
Other;
If Not ValidInput();
Iter;
EndIf;
Select;
When B_OPTION = cMaintainTriggerControl;
KeyPressed = ProcessScreen02();
When B_OPTION = cMaintainTriggerDetail;
KeyPressed = ProcessScreen03();
EndSl;
If KeyPressed = F3;
Return KeyPressed;
EndIf;
LoadScreenFields();
Iter;
EndSl;
EndDo;
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2025 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.