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



On Tue, Mar 6, 2018 at 12:47 PM, <dlclark@xxxxxxxxxxxxxxxx> wrote:
"MIDRANGE-L" <midrange-l-bounces@xxxxxxxxxxxx> wrote on 03/06/2018
12:13:38 PM:
For fixed-length data with a fixed format I would not bother with
REGEX. I would also avoid %SST, though, by using the new ability to
redefine CL variables -- which basically means creating a data structure
format with subfields for the different parts of your string. For
example:

DCL VAR(&FILENAME) TYPE(*CHAR) LEN(40)
DCL VAR(&F_PREFIX) TYPE(*CHAR) LEN(19) STG(*DEFINED) DEFVAR(&FILENAME 1)
DCL VAR(&F_MO) TYPE(*CHAR) LEN( 2) STG(*DEFINED) DEFVAR(&FILENAME 20)
DCL VAR(&F_MO_DOT) TYPE(*CHAR) LEN( 1) STG(*DEFINED) DEFVAR(&FILENAME 22)
DCL VAR(&F_DD) TYPE(*CHAR) LEN( 2) STG(*DEFINED) DEFVAR(&FILENAME 23)
DCL VAR(&F_DD_DOT) TYPE(*CHAR) LEN( 1) STG(*DEFINED) DEFVAR(&FILENAME 25)
DCL VAR(&F_YY) TYPE(*CHAR) LEN( 2) STG(*DEFINED) DEFVAR(&FILENAME 26)
DCL VAR(&F_YY_ULN) TYPE(*CHAR) LEN( 1) STG(*DEFINED) DEFVAR(&FILENAME 28)
DCL VAR(&F_HH) TYPE(*CHAR) LEN( 2) STG(*DEFINED) DEFVAR(&FILENAME 29)
DCL VAR(&F_MM) TYPE(*CHAR) LEN( 2) STG(*DEFINED) DEFVAR(&FILENAME 31)
DCL VAR(&F_SUFFIX) TYPE(*CHAR) LEN( 4) STG(*DEFINED) DEFVAR(&FILENAME 33)
DCL VAR(&F_EXTRA) TYPE(*CHAR) LEN( 4) STG(*DEFINED) DEFVAR(&FILENAME 37)

Wow. Wall o' code.

I appreciate that CL has grown in capability. But it's... not the most
beautiful language to code in.

I actually *would* use %SST, because that's less verbose than what
you've shown here! Especially since some of the "subfields" only exist
to test against a constant. Besides reducing verbosity and line count,
I also like to reduce the number of variables.

Of course, my preference would still be a simple RPG helper program.
With its date/time BIFs, you can do more precise validation. (Or did
CL grow date/time BIFs as well?) In fact, it's better validation than
regex alone (typically, those just check whether certain characters
are digits, not whether they form valid dates).

John Y.

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.