June 21, 2016, 09:51 AM
Pak Protector[OPEN] How To Force End Of Line at Specific Position
Hi Focal Point
We are trying to generate a flat text file with every record ending at a specific position. The problem is the end of line is being truncated because the last 3 fields are blank. We cannot alter the data. I tried inserting blank spaces but they are ignored. What can we do?
June 21, 2016, 06:45 PM
WazHow are you creating the text file ?
Whats the code ?
June 22, 2016, 03:25 PM
SquatchNot much to go on, so I'll just throw something out there as a starting point.
I used the CAR file and tried to simulate missing car model information for the country of Japan using a DEFINE field. Then a second DEFINE field tests the first one to see if the model is missing. If it is, then it uses spaces for the model; otherwise, it just uses whatever model information is there.
Of course, the actual data source needs to flag empty fields as MISSING before something like this could work.
DEFINE FILE CAR ADD
THE_MODEL/A24 MISSING ON NEEDS SOME DATA=IF CAR.ORIGIN.COUNTRY EQ 'JAPAN' THEN MISSING ELSE CAR.CARREC.MODEL;
BLANK_MODEL/A24=IF THE_MODEL IS MISSING THEN ' ' ELSE THE_MODEL;
END
TABLE FILE CAR
PRINT
CAR.ORIGIN.COUNTRY
CAR.COMP.CAR
CAR.CARREC.BLANK_MODEL
ON TABLE SET PAGE-NUM NOLEAD
ON TABLE SET ASNAMES ON
ON TABLE NOTOTAL
ON TABLE PCHOLD FORMAT ALPHA
ON TABLE SET HTMLCSS ON
END
June 22, 2016, 03:48 PM
John_EdwardsI just had to deal with this. I needed a blank character at the end and it refused to leave it there for me. Here's the solution I eventually came up with. Note -- I'm printing the entire line of data in fixed columns (with commas between for some reason) via a single field that concatenates everything.
DEFINE FILE NIC_DATA
FULL_DATA_LINE/A100 = PARKING_STREET_A30 | ',' | PARKING_CITY_A20 | ',' | PARKING_COUNTY_A3 | ',' | PARKING_ZIP_A5 | ',' | PARKING_ZIP_4_A4 | ',' | MAKE_NAME_A4 | ',' | MODEL_YEAR_A4 | ',' | TX_VIN_A19 | ',' | FUEL_CATEGORY_A2;
EMPTY_SPACE/A1 MISSING ON = MISSING;
END
TABLE FILE NIC_DATA
BY PARKING_ZIP NOPRINT
BY FULL_DATA_LINE
BY EMPTY_SPACE
(blah blah blah)
ON TABLE HOLD AS XYZ FORMAT DFIX DELIMITER ' ' HEADER NO
END
Be sure to note the delimiter value of ' ' in the hold line at the end -- that's my blank space -- that blank space is placed between the FULL_DATA_LINE field and the EMPTY_SPACE field. That's my single blank character that I didn't want to lose. The FULL_DATA_LINE field produces the entire line of actual data, the delimiter creates the single blank space that my spec called for at the end, the EMPTY_SPACE field makes sure the blank space isn't lost. Without the EMPTY SPACE field the report did me the (ahem) "courtesy" of removing the blank space I explicitly included in my data string. Just wouldn't leave it alone.
I would presume you'd want a delimiter three spaces long.
June 27, 2016, 12:12 PM
Kevin WSeems to me I did this once and added a CR/LF in hex at the end of the line after the space. However, I have no proof or code to give you.
June 27, 2016, 06:02 PM
WazAnother way you can do this, if you are creating your own formatting, is to use PUTDDREC.
See
http://forums.informationbuild...=830106344#830106344June 28, 2016, 02:24 PM
susannahalso,we know that HEXBYT(32,'A1') is a blank space, but it seems to get ignored in many situations as you said, Pak.
However there is one that doesn't get ignored, in the extended ascii character set, HEXBYT(255,'A1');
for example,
in an xml dropdown list, we use these HEXBYT characters to indent some of the display entries.
works great.
whereas using nbsp or HEXBYT(32 doesn't work at all.