** This thread discusses the Content article: The API Corner: Still Using Compile-Time Arrays? **
Bruce,
To minimize changes, you could still keep the Txt array, but replace the text in there with the message identifier, and then the code would be:
...
when OrdSts = 'P';
RtvMsgTxt(Status :%size(Status) :Txt(1));
when OrdSts = 'O';
RtvMsgTxt(Status :%size(Status) :Txt(2));
when OrdSts = 'C';
RtvMsgTxt(Status :%size(Status) :Txt(3));
...
The benefit of that is that all the message ID's used are held in one place - a compile-time array at the bottom of the source member - rather than being hard-coded in the calc specs.
Of course, having the compile-time array being a combination of OrdSts AND MsgID would be even better:
PDSP0100
ODSP0101
CDSP0102
so you could do a simple lookup:
x = %lookup( OrdSts : OrdStsArr );
if x > 0;
RtvMsgTxt(Status :%size(Status) :OrdStsMsgID(x));
else;
Status = 'Unknown status';
endif;
but that's a bigger code change.
Bruce,
To minimize changes, you could still keep the Txt array, but replace the text in there with the message identifier, and then the code would be:
...
when OrdSts = 'P';
RtvMsgTxt(Status :%size(Status) :Txt(1));
when OrdSts = 'O';
RtvMsgTxt(Status :%size(Status) :Txt(2));
when OrdSts = 'C';
RtvMsgTxt(Status :%size(Status) :Txt(3));
...
The benefit of that is that all the message ID's used are held in one place - a compile-time array at the bottom of the source member - rather than being hard-coded in the calc specs.
Of course, having the compile-time array being a combination of OrdSts AND MsgID would be even better:
PDSP0100
ODSP0101
CDSP0102
so you could do a simple lookup:
x = %lookup( OrdSts : OrdStsArr );
if x > 0;
RtvMsgTxt(Status :%size(Status) :OrdStsMsgID(x));
else;
Status = 'Unknown status';
endif;
but that's a bigger code change.
Comment