Automic Workload Automation

Expand all | Collapse all

Printing variables containing multi-line text

  • 1.  Printing variables containing multi-line text

    Posted 03-29-2018 11:14 AM
    Since version 11, it has been possible to store multi-line text in object variables. If you’ve ever used the :PRINT statement to print multi-line text, you have probably seen something like this:
    2018-03-29 16:58:50 - U00020408 Multi-line variable: Line 1
    Line 2
    Line 3
    If you want the output to be aligned, here’s a little hack. Define an object variable called &NewLine# and insert a single linefeed into the value. Then do something like this:
    :SET &Header# = "&$LDATE_YYYY_MM_DD_d# &$TIME_HH_MM_SS# - U00020408: "
    :SET &String2# = STR_SUB(&
    String#,&NewLine#,"&NewLine#&Header#")
    :PRINT "
    Multi-line variable : &String2#"
    You should then see that the the lines line up.
    2018-03-29 16:58:50 - U00020408 Multi-line variable : Line 1
    2018-03-29 16:58:50 - U00020408                     : Line 2
    2018-03-29 16:58:50 - U00020408                     : Line 3
    If you need to use the original unaltered variable elsewhere, be sure to write the altered text to a new variable just for printing.


  • 2.  Re: Printing variables containing multi-line text

    Posted 09-26-2018 10:35 AM

    One more thing: the &NewLine# variable must be defined as an object variable.

    For some reason, the STR_SUB function does correctly identify newlines if &NewLine# is set using UC_CRLF.