[Closed] Is Value of Field with format Mt via -READ as Expected?
I have a routine that calculates many generic dates (beginning of current month, beginning of current year, end of current month, and on and on.) I put the values into a HOLD file, and then convert them all to amper variables via -READFILE. One of these translates the date of the beginning of the current month to the three-character name of the month, via the format Mt. If the field goes to Excel format, is shows Oct for the current month. After the -READFILE the field with format Mt has a numeric value. I created an additional field with format A3 whose value is determined with FPRINT which solved that issue. I've been using the numeric value for another function, but today the value is 0 instead of the 10 that I expected. I found that computing another field with format I3, and setting it to the field with format Mt will give me the 10 I was looking for. My question: is this behaving as expected?
The code:
TABLE FILE F59YRDAY
PRINT
COMPUTE RPT_MTH_BEG/A8MDYY = '10012012' ;
COMPUTE RM_BOM_CY/MDYY = RPT_MTH_BEG;
COMPUTE CM_ABV_NAME1/Mt = RM_BOM_CY;
COMPUTE CM_ABV_NAME2/I3 = CM_ABV_NAME1 ;
COMPUTE CM_ABV_NAME/A3 = FPRINT(CM_ABV_NAME1, 'Mt', 'A3');
WEEK_DAY
WHERE DATE EQ '&MDYY';
ON TABLE NOTOTAL
ON TABLE HOLD AS HOLD01 FORMAT ALPHA
END
-RUN
-*********************************
-READFILE HOLD01
-*********************************
-TYPE RPT_MTH_BEG &RPT_MTH_BEG
-TYPE RM_BOM_CY &RM_BOM_CY
-TYPE CM_ABV_NAME1 &CM_ABV_NAME1
-TYPE CM_ABV_NAME2 &CM_ABV_NAME2
-TYPE CM_ABV_NAME &CM_ABV_NAME
-TYPE WEEK_DAY &WEEK_DAY
Clearly the value 10 in CM_ABV_NAME2 came from an internal value representing October in CM_ABV_NAME1. Looks like the COMPUTEs work correctly, but -READFILE has a bug when interpreting a format Mt column.
October 03, 2015, 11:52 AM
George Patton
I was using /Mt for years and then suddenly it broke in 7703. In a given year it would always miss February and give me two Decembers.
George - after the -READ the value of the field with format MONtr has leading zeroes. Of the two, I prefer the one with format I3, it's just cleaner for me. Thank you for your suggestion.
8009 Windows, HTML, AHTML, Excel In FOCUS since 1983