WoodEngineer
2280 pts. | Sep 18 2008 3:45PM GMT
Here is a sample of code from an old RPG program we still use that accomplishes what you request. We call it from the CL. It returns the results to the CL program.
This section of code gives you an idea of how this can be done:
C *MDY0 TEST (D) DAT_C6 51 (*IN51 On if date test failed)
C IF NOT *IN51 (Date is in MMDDYY format)
C do something here
C GOTO @TAG01
C ENDIF
*
C *CYMD0 TEST (D) DAT_C7 51 (test for CYYMMDD format without separator)
C IF NOT *IN51 (Date is in CYYMMDD format)
C do something here
C GOTO @TAG01
C ENDIF
C *YMD0 TEST(D) DAT_C6 51 (test of YYMMDD format without separator)
C IF NOT *IN51 (Date is in YYMMDD format)
C do something here
C GOTO @TAG01
C ENDIF
This code makes a lot more sense when its rendered in fixed font. Notice how the various date formats are tested. If the test fails, it tests a different format looking for one that is valid. Just code a date test for every format you think the program will encounter. If all tests fail, its an invalid date.
I warned you . . . this is really old code but it works.
You can do the same thing in free form RPG and it looks a lot better.






