is it possible to split a string by newline?
I have tried passing \n and UC_CRLF() but it does not work.
Thanks in advance,
possibly Michael Lowrys solution can help you:
I just tested my approach of setting &Newline# in an object variable, and it works fine as a separator for STR_SPLIT. See the attached SCRI for a demonstration.
If you want to find newline characters in multi-line strings, you must first set a variable to the character for which you are searching. There are two straightforward ways to do this:
:SET &CRLF# = UC_CRLF()
In my experience, these approaches do not work consistently. I did a quick test to compare the characters being written to these variables.
:SET &CRLF_POS_IN_NL# = STR_FIND(&NEWLINE#,&CRLF#):PRINT &&CRLF_POS_IN_NL#: &CRLF_POS_IN_NL#:SET &NL_POS_IN_CRLF# = STR_FIND(&CRLF#,&NEWLINE#):PRINT &&NL_POS_IN_CRLF#: &NL_POS_IN_CRLF#
U00020408 &CRLF_POS_IN_NL#: 0000000000000000U00020408 &NL_POS_IN_CRLF#: 0000000000000002
From this, I conclude:
I also found that when the AE writes a string to a file via an OS agent, it automatically converts newline characters to the style specific to that OS. See the attached JOBS object for an example.
* The newline character used internally by the AE might depend on the OS or database of the AE server.
The AE script function UC_CRLF() returns an MS-DOS-style newline: a carriage return and a line feed (CR LF or \r \n).In multi-line object variables and other multi-line fields in the Automation Engine, the newline character is a UNIX-style newline: just the line feed character (LF or \n)*.
I just confirmed this using the HEX() script function.
:SET &CRLF_HEX# = HEX(&CRLF#):PRINT &&CRLF_HEX#: &CRLF_HEX#:SET &NEWLINE_HEX# = HEX(&NEWLINE#):PRINT &&NEWLINE_HEX#: &NEWLINE_HEX#
U00020408 &CRLF_HEX#: 0D0AU00020408 &NEWLINE_HEX#: 0A
In ASCII, hex 0A (decimal 10) is the linefeed character, and hex 0D (decimal 13) is the carriage return character.
Retrieving data ...