Wednesday, October 12, 2011

Call Subroutine (CALLSUBR)

pgm

Dcl Var(&Counter) Type(*Dec) Len(1 0)
Dcl Var(&CounterChr) Type(*Char) Len(1)
Dcl Var(&Exit) Type(*Int)

DoUntil Cond(&Exit *EQ 1)
CallSubr Subr(DoCalcs) RtnVal(&Exit)
EndDo
Return

Subr Subr(DoCalcs)
ChgVar Var(&Counter) Value(&Counter + 1)
CallSubr Subr(DspResults)
If Cond((&Counter / 2) *EQ 2) Then( +
RtnSubr RtnVal(1))
CallSubr Subr(DspResults)
EndSubr




Subr Subr(DspResults)
chgVar Var(&CounterChr) Value(&Counter)
SndUsrMsg Msg(&CounterChr) MsgType(*Info)
EndSubr

EndPgm

No comments:

Post a Comment