miniscript
miniscript copied to clipboard
multiline string
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
OK, there's a couple things going on here:
- 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. - 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
).
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.