discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

Echo collapses multiple spaces to single

T
TLC123
Sat, Feb 16, 2019 11:09 AM

Echo collapses multiple spaces to one.
Is there a workaround?

echo("e      e  e");

ECHO: "e e e"

--
Sent from: http://forum.openscad.org/

Echo collapses multiple spaces to one. Is there a workaround? echo("e e e"); ECHO: "e e e" -- Sent from: http://forum.openscad.org/
NH
nop head
Sat, Feb 16, 2019 11:20 AM

Using   for a space seems to work. Perhaps that should be an automatic
substitution.

On Sat, 16 Feb 2019 at 11:13, TLC123 torleif.ceder@gmail.com wrote:

Echo collapses multiple spaces to one.
Is there a workaround?

echo("e      e  e");

ECHO: "e e e"

--
Sent from: http://forum.openscad.org/


OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

Using &nbsp; for a space seems to work. Perhaps that should be an automatic substitution. On Sat, 16 Feb 2019 at 11:13, TLC123 <torleif.ceder@gmail.com> wrote: > Echo collapses multiple spaces to one. > Is there a workaround? > > echo("e e e"); > > ECHO: "e e e" > > > > -- > Sent from: http://forum.openscad.org/ > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >
KN
Kristian Nielsen
Sat, Feb 16, 2019 11:27 AM

TLC123 torleif.ceder@gmail.com writes:

Echo collapses multiple spaces to one.
Is there a workaround?

The output is formattet as HTML. So you can do something like:

echo("e       e   e");
echo("<pre>e      e  e</pre>");

https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Other_Language_Features#Echo_Statements

Hope this helps,

  • Kristian.
TLC123 <torleif.ceder@gmail.com> writes: > Echo collapses multiple spaces to one. > Is there a workaround? The output is formattet as HTML. So you can do something like: echo("e&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;e&nbsp;&nbsp;&nbsp;e"); echo("<pre>e e e</pre>"); https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Other_Language_Features#Echo_Statements Hope this helps, - Kristian.
T
TLC123
Sat, Feb 16, 2019 11:28 AM

Nice but how can i print n number of spaces
If i want to indent by say recursion level

--
Sent from: http://forum.openscad.org/

Nice but how can i print n number of spaces If i want to indent by say recursion level -- Sent from: http://forum.openscad.org/
NH
nop head
Sat, Feb 16, 2019 11:41 AM

You would print n   instead.

On Sat, 16 Feb 2019 at 11:32, TLC123 torleif.ceder@gmail.com wrote:

Nice but how can i print n number of spaces
If i want to indent by say recursion level

--
Sent from: http://forum.openscad.org/


OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

You would print n &nbsp; instead. On Sat, 16 Feb 2019 at 11:32, TLC123 <torleif.ceder@gmail.com> wrote: > Nice but how can i print n number of spaces > If i want to indent by say recursion level > > > > -- > Sent from: http://forum.openscad.org/ > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >
T
TLC123
Sat, Feb 16, 2019 11:42 AM

I realized it was the HMTL parser does the collapsing so my workaround was
this

echo("<pre>w    w    w");

ECHO: "
"

Introduces a line break but i can live with that. Tanks.

--
Sent from: http://forum.openscad.org/

I realized it was the HMTL parser does the collapsing so my workaround was this echo("<pre>w w w"); ECHO: " " Introduces a line break but i can live with that. Tanks. -- Sent from: http://forum.openscad.org/
NH
nop head
Sat, Feb 16, 2019 11:46 AM

function spaces(n) = n <= 0 ? "" : str(" ", spaces(n -1));

echo(str(spaces(10), "hello"));

ECHO: "          hello"

On Sat, 16 Feb 2019 at 11:41, nop head nop.head@gmail.com wrote:

You would print n   instead.

On Sat, 16 Feb 2019 at 11:32, TLC123 torleif.ceder@gmail.com wrote:

Nice but how can i print n number of spaces
If i want to indent by say recursion level

--
Sent from: http://forum.openscad.org/


OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

function spaces(n) = n <= 0 ? "" : str("&nbsp;", spaces(n -1)); echo(str(spaces(10), "hello")); ECHO: " hello" On Sat, 16 Feb 2019 at 11:41, nop head <nop.head@gmail.com> wrote: > You would print n &nbsp; instead. > > On Sat, 16 Feb 2019 at 11:32, TLC123 <torleif.ceder@gmail.com> wrote: > >> Nice but how can i print n number of spaces >> If i want to indent by say recursion level >> >> >> >> -- >> Sent from: http://forum.openscad.org/ >> >> _______________________________________________ >> OpenSCAD mailing list >> Discuss@lists.openscad.org >> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >> >