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



Kurt,

A couple of options:

1. I have a routine which uses the 3-character MSGID prefix to determine the
name of the undelrying message file from which it comes. My DS definition
looks like the following:

D MsgPfxArrStr S 483A Inz('CB QCBLMSG *LIBL +
D CEEQCEEMSG *LIBL +
D CP QCPFMSG *LIBL +
D DNSQTOBMSGF QDNS +
D ED QEDTMSG QPDA +
D GL QGLDMSG QDIRSRV +
D HTPQHTTPMSG QHTTPSVR +
D ID QIDUMSG QIDU +
D IW QIWSMSG QIWS +
D JVAQJVAMSGF QJAVA +
D LN QLNCMSG QCBLLE +
D MCHQCPFMSG *LIBL +
D PL QPLIMSG QPLI +
D QRGQRPGMSG QRPG +
D QSHQZSHMSGF QSHELL +
D RN QRPGLEMSG QRPGLE +
D RX KTIMSGF *LIBL +
D SQLQSQLMSG QSYS +
D TCPQTCPMSGF QTCP +
D TX QIDUMSG QIDU +
D USRQUSRMSG *LIBL ')
*
D MsgPfxArrStr@ S * Inz(%addr(MsgPfxArrStr))
D MsgPfxArr DS Based(MsgPfxArrStr@) Qualified
D MsgPfxElm Dim(20)
D MsgIdPfx1 1A Overlay(MsgPfxElm)
D MsgIdPfx2 2A Overlay(MsgPfxElm)
D MsgIdPfx3 3A Overlay(MsgPfxElm)
D qMsgf 20A Overlay(MsgPfxElm:*Next)

2. What's wrong with defining DS arrays over a CTDATA:

D JobTypeDS DS
D JobTypeNbr 10I 0
D JobTypeArr Dim(14) CTDATA
D JobTypeInt 2A Overlay(JobTypeArr)
D JobTypeExt 8A Overlay(JobTypeArr:*Next)
...
** CTDATA
A AUTO
B BATCH
BECMNEVK
BFM36
BDBCI
BJPJ
BPPDJ
BTMRT
I INTER
M SBSMON
R RDR
S SYS
W WTR
X SCPF

I don't know if my examples have helped at all (I've probably missed the
point totally), but what I'd say is that short of specifying separate
constants, there's not a lot you can do to *stop* programmers from changing
a DS. Except the threat of what will happen if they do...

Rory

On Thu, Apr 9, 2009 at 7:40 AM, Kurt Anderson
<kurt.anderson@xxxxxxxxxxxxxx>wrote:

I have a data structure and I'd like for its contents to never be changed,
enforced by the compiler. How do I do this?

One situation I've run into is where I want to initialize an output data
structure parameter. I can't reset it. I can't cheat and base another DS
on it and reset that DS. I can clear the fields individually, but that
sucks, right? This will also be called a ton of times, so I want to pass
the data by reference (so not using a return value). What I ended up doing
is creating a static DS to house all the default values so I can initialize
the output parameter with it. However it does leave the initialization DS
open to being modified.

Another situation is I tend to create data structure arrays, which long ago
would have been compile time tables. Each subfield is an element in an
array (so each element has a given name if I ever need to reference one
specific value). However, these values could be changed, and I have to rely
programmers not changing it (vs the compiler not letting them).

Thoughts on creating a data structure constant?

I'm on v5r4.

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.