CRLF Line terminator equivalent in Progress 4GL

sreekuax

Member
Hello All,

I am trying to generate a data file with "CRLF Line terminator" which is windows format I guess..
Can anybody help me identifying the progress equivalent code ? Normally in progress we use a "SKIP. " so if CRLF Line terminator means what need to be used ?
 

rstanciu

Member
no ... each is an example:
MESSAGE "ABCD~nAZERT" VIEW-AS ALERT-BOX.
MESSAGE "ABCD" + CHR(13) + "AZERT" VIEW-AS ALERT-BOX.
MESSAGE "ABCD" SKIP "AZERT" VIEW-AS ALERT-BOX.
 

sreekuax

Member
no ... each is an example:
MESSAGE "ABCD~nAZERT" VIEW-AS ALERT-BOX.
MESSAGE "ABCD" + CHR(13) + "AZERT" VIEW-AS ALERT-BOX.
MESSAGE "ABCD" SKIP "AZERT" VIEW-AS ALERT-BOX.

ooops tell me how you replace the below SKIP ... in the sample code with CRLF line terminator:


PUT STREAM xcim-stream UNFORMATTED
'"' "User ID" '"' "|"
'"' "User Name" '"' "|"
'"' "User Groups" '"' "|"
'"' "Active Y/N" '"' "|"
'"' "Active Date" '"'
SKIP.
 

rstanciu

Member
normaly, SKIP is a portable CRLF but you can use a alternative

PUT STREAM xcim-stream UNFORMATTED
'"' + "User ID" + '"' + "|" +
'"' + "User Name" + '"' + "|" + "~n".

or

PUT STREAM xcim-stream UNFORMATTED
'"' + "User ID" + '"' + "|" +
'"' + "User Name" + '"' + "|" + CHR(13).
 

sreekuax

Member
normaly, SKIP is a portable CRLF but you can use a alternative

PUT STREAM xcim-stream UNFORMATTED
'"' + "User ID" + '"' + "|" +
'"' + "User Name" + '"' + "|" + "~n".

or

PUT STREAM xcim-stream UNFORMATTED
'"' + "User ID" + '"' + "|" +
'"' + "User Name" + '"' + "|" + CHR(13).

That works though... but bro can you tell me why + is used (+ "User Id" + ) what it will do exactly ?
 

D.Cook

Member
"~n" SKIP SKIP(1) or CHR(13)
Note that "~n" evaluates to just a linefeed character; carriage return is "~r"
Also CHR(13) evaluates to just a carriage return; linefeed is CHR(10).
(http://www.asciitable.com/)

SKIP is OS-dependant so on Windows will output CRLF and on Unix just LF.

So CRLF, as the question was posed, is either:
Code:
"~r~n"
or
Code:
CHR(13) + CHR(10)
Although generally you can get away just LF anyway.
 

MattKnowles

New Member
What if I need a file with line delimiters of only LineFeed?

As stated above CR is chr(13) or ~r and LF is chr(10) or ~n. These can be used together or independently as your need requires.

Therefore if you need a file with the line delimiters of only LF then only use chr(10) or ~n.
 

dchalom

New Member
Yes but when I try to use CHR(10) the eport file is still line delimited with CR and LF in that order....
I tried "~n" and got the same results...
When I try CHR(13) I get CR only...
With SKIP I get CR LF...
 

RealHeavyDude

Well-Known Member
SKIP is treated according to the platform you are running the command. On Windows it will produce CF + LF whereas on *nix it will only produce LF. These are non-printable characters and depending on the editor you are using you will see the CR or not. On most Unix flavors I know you can use dos2unix to convert the file (unix2dos in the other direction).

Heavy Regards, RealHeavyDude.
 

dchalom

New Member
Nope I thought I had it solved but it is still putting a CR LF at the end of each line even though I am doing a PUT STREAM oStreamInp unformatted....Chr(10).
 

Stefan

Well-Known Member
I can confirm the same behavior with 10.2B06 (Vista x64 GUI / ChUI), if you use the BINARY option on the OUTPUT statement you only get the line feed:

Code:
DEF VAR lcc AS LONGCHAR.
DEF VAR cc AS CHAR.


OUTPUT TO "lf.txt" BINARY.


PUT UNFORMATTED "a~nb".


OUTPUT CLOSE.


COPY-LOB FROM FILE "lf.txt" TO lcc.
cc = lcc.


MESSAGE 
   ASC( SUBSTRING( cc, 1, 1 ) ) SKIP
   ASC( SUBSTRING( cc, 2, 1 ) ) SKIP
   ASC( SUBSTRING( cc, 3, 1 ) ) SKIP
   ASC( SUBSTRING( cc, 4, 1 ) ) SKIP
   ASC( SUBSTRING( cc, 5, 1 ) ) SKIP
VIEW-AS ALERT-BOX.
 

dchalom

New Member
Here is the code that finally worked...

cFilePathOut = {&XFerDir} + "\Equifax_UDM\output\UDM_INP_" + STRING(YEAR(TODAY), "9999") + STRING(MONTH(TODAY), "99") + STRING(DAY(TODAY), "99") + ".Dat". /* UDM_INP_20111209.dat */
OUTPUT STREAM ostreamInp to VALUE(cFilePathOut) BINARY NO-CONVERT.


PUT STREAM oStreamInp UNFORMATTED
 

Stefan

Well-Known Member
cFilePathOut = {&XFerDir} + "\Equifax_UDM\output\UDM_INP_" + STRING(YEAR(TODAY), "9999") + STRING(MONTH(TODAY), "99") + STRING(DAY(TODAY), "99") + ".Dat". /* UDM_INP_20111209.dat *

You don't mention which version you're on, but ISO-DATE has been around for quite some time and makes the inbetween part so much cleaner:

Code:
REPLACE( ISO-DATE( TODAY ), "-", "" )
 
Top