Page 1 of 1

new line '\n' replacement in #PRIM_TEXT or Field

Posted: Thu Jun 15, 2017 1:41 am
by gstenstrom
I'm using #PRIM_TEXT for entry of notes. When the user enters a carriage return, a '\n' in sent to the our iSeries.
We then read these notes and strings them together with HTML Code in the HTML Container which doesn't recognizing the carriage return.
My problem is replacing the '\n' with '<br/>' .

.ReplaceAll doesn't work against #PRM_TEXT

So I tried it with my field before I send it to our iSeries.
#OC18_EmailHTML.ReplaceAll( '\\n' '<br>' ) and #OC18_EmailHTML.ReplaceAll( '\n' '<br>' ) doesn't work.

Any suggestions.

Re: new line '\n' replacement in #PRIM_TEXT or Field

Posted: Thu Jun 15, 2017 6:25 am
by dannyoorburg
Intrinsic functions never change their input, they just produce a result. Are you assigning the result back into the field? As in:

#OC18_EmailHTML := #OC18_EmailHTML.ReplaceAll( '\n' '<br>' )

Danny

Re: new line '\n' replacement in #PRIM_TEXT or Field

Posted: Thu Jun 15, 2017 8:32 am
by MarkD
I am not sure if you mean "\n" literally, or as an escaped JavaScript representation of the newline character hex 0A?
In RDMLX the carriage return and line feed are often set up like this:

Define_Com Class(#prim_dc.UnicodeString) Name(#CarriageReturn)
Define_Com Class(#prim_dc.UnicodeString) Name(#LineFeed)

#CarriageReturn := (13).AsUnicodeString /* Hex 0D */
#LineFeed := (10).AsUnicodeString /* Hex 0A */

Re: new line '\n' replacement in #PRIM_TEXT or Field

Posted: Fri Jun 16, 2017 8:50 am
by MarkD
If the data is on an iSeries (IBM i) and has already converted to EBCDIC then the CR and LF are not the same characters.

eg: https://www.ibm.com/support/knowledgece ... 003899.htm
In ASCII, newline is X'0A'. In EBCDIC, newline is X'15'. Windows programs normally use a carriage return followed by a line feed character at the end of each line of a text file. In ASCII, carriage return/line feed is X'0D'/X'0A'. In EBCDIC, carriage return/line feed is X'0D'/X'15'.

Re: new line '\n' replacement in #PRIM_TEXT or Field

Posted: Sat Jun 17, 2017 2:18 am
by gstenstrom
Thanks for the help. This worked.

Code: Select all

Define Field(#sTemp) Reffld(#OC18_EmailHTML)
#CarriageReturn := (13).AsUnicodeString /* Hex 0D */
#LineFeed := (10).AsUnicodeString /* Hex 0A */

#sTemp := #ebNote
#OC18_EmailHTML := #sTemp.ReplaceAll( #LineFeed '<br>' )