Echo collapses multiple spaces to single

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Echo collapses multiple spaces to single

TLC123
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
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: Echo collapses multiple spaces to single

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

On Sat, 16 Feb 2019 at 11:13, TLC123 <[hidden email]> 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
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: Echo collapses multiple spaces to single

knielsen
In reply to this post by TLC123
TLC123 <[hidden email]> 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.

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: Echo collapses multiple spaces to single

TLC123
In reply to this post by nophead
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
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: Echo collapses multiple spaces to single

nophead
You would print n &nbsp; instead.

On Sat, 16 Feb 2019 at 11:32, TLC123 <[hidden email]> 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
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: Echo collapses multiple spaces to single

TLC123
In reply to this post by TLC123
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/

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: Echo collapses multiple spaces to single

nophead
In reply to this post by nophead
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 <[hidden email]> wrote:
You would print n &nbsp; instead.

On Sat, 16 Feb 2019 at 11:32, TLC123 <[hidden email]> 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
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org