Newline in Constant string?

Greetings XOJO people. Still using 2019 R3.2. At the moment, it is only for internal use and I can work around most of the gotchas that effect my simple programs. But, this one has me stumped.

I would like to embed newlines in constant strings. The constant parser does not seem to recognize \n or any of the other escaped control characters and is very happy to create a string that looks like “blah blah \n blah blah”.

When I try to create a constant string by program using something like:

const var MyString as string = "Hello " + char(10) + “Good bye!” //just a basic example

I get a an error that constants cannot be modified.

Any ways around this?

Many thanks
Jim Wagner - Oregon Research Electronics

with a project open, choose the menu “insert” then “constant”
give it a name
then clic on the small pencil button beside, and edit the constant with all newlines or tab you need.




Const MyString = \"Hello \nGood bye!"

If you want to leave it inside your method, there are three ways to do it:

const k1 as string = "Hello" + &uA + "Good bye"

const k2 as string = \"Hello
Good bye!"

const k3 as string = \"Hello\nGood bye!"

See this conversation for information about those last two.

Thanks, everyone!

That should do it!