miniscript icon indicating copy to clipboard operation
miniscript copied to clipboard

multiline string

Open qrhfz opened this issue 1 year ago • 2 comments

Run script below

print "line one
line two"

Result

line oneout:line two

Try It link: https://miniscript.org/tryit/9f2d3009

Why is it returning string with out: token instead of new line. How to add new line? Miniscript doesnt have \n

qrhfz avatar Jun 03 '23 05:06 qrhfz

OK, there's a couple things going on here:

  1. You can't embed a line break in a string literal. Your sample script should generate a compiler error (and the fact that it doesn't, is a bug). To force a line break in a string you'd have to do something like "line one" + char(10) + "line 2", but the exact behavior of that control character depends on the platform.
  2. The Try-It! page doesn't correctly handle line breaks in a string, or print lines whose line break has been suppressed (using the second parameter to print).

JoeStrout avatar Oct 31 '23 21:10 JoeStrout

Going to hold off on doing anything about point 1 above for now. I'm concerned there may be code out there relying on this bug. And maybe, if we can define a consistent behavior for it, it could be considered a feature. More thought is needed.

JoeStrout avatar Oct 31 '23 21:10 JoeStrout