printfteraterm

How to generate string variable with crlf at ttl language


I'm trying to make string that contain crlf inside it at ttl language. For example, somthing such as:

MY_STRING = "hello\nworld"
send  MY_STRING

should result as

hello
world

I know I can get the same with:

send "hello" #13#10 "world"

but I need it as string because I want to 'send' this string to another 'function', for example:

MY_STRING = "hello\nworld"
include "printMyString.ttl"

I tried something like:

sprintf2 MY_STRING "%s\n%s" "hello" "world"
sprintf2 MY_STRING "%s%d%d%s" "hello" 13 10 "world"
sprintf2 MY_STRING "%s%d%d%s" "hello" #13 #10 "world"

but it didn't worked, is there is a way?


Solution

  • I found some way, maybe there is better:

    code2str CRLF $0d0a
    sprintf2 MY_STRING "%s%s%s" "hello" CRLF "world"
    send  MY_STRING
    

    EDIT It comes out that my first approach was good, just didn't understand that #13 is string:

    sprintf2 MY_STRING "%s%s%s%s" "hello" #13 #10 "world"
    send  MY_STRING