Why does echo print the entire line?

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

Why does echo print the entire line?

Troberg
When I use echo to print output (useful for printing part lists in parametric
designs) to the output window, it prints not only the argument, it prints
the entire line.

Example:

echo("Hello world!");

results in:

echo("Hello world!");

I would expect it to print:

Hello World!

Sure, it's readable, and it's trivial to make a program to trim the output
if needed, but is there any upside to this behaviour which motivates it's
existence? It just feels "un-neat".



--
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: Why does echo print the entire line?

nophead
It should result in:

ECHO: "Hello world!"

I presume the prefix is to distinguish it from other messages. If you are getting the whole source line printed then it is a bug.

On 14 September 2017 at 08:20, Troberg <[hidden email]> wrote:
When I use echo to print output (useful for printing part lists in parametric
designs) to the output window, it prints not only the argument, it prints
the entire line.

Example:

echo("Hello world!");

results in:

echo("Hello world!");

I would expect it to print:

Hello World!

Sure, it's readable, and it's trivial to make a program to trim the output
if needed, but is there any upside to this behaviour which motivates it's
existence? It just feels "un-neat".



--
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: Why does echo print the entire line?

Troberg
True, I was in a bit of hurry and didn't check the details.

Still, I think, at least for my use, that the downsides by far outweigh the
upsides, and it's pretty much the opposite of how other dev environments do
it (at least the ones I've used).

If you just want enhanced visibility, I'd consider using an alternative
color.



--
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: Why does echo print the entire line?

nophead
If it was just a different colour then I wouldn't be able to filter it with a script.

I think it is far too late to change now as people like me have scripts built around it for making BOMs for many years.


On 14 September 2017 at 11:08, Troberg <[hidden email]> wrote:
True, I was in a bit of hurry and didn't check the details.

Still, I think, at least for my use, that the downsides by far outweigh the
upsides, and it's pretty much the opposite of how other dev environments do
it (at least the ones I've used).

If you just want enhanced visibility, I'd consider using an alternative
color.



--
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: Why does echo print the entire line?

Gadgetmind
In reply to this post by Troberg
On 2017-09-14 11:08, Troberg wrote:
> Still, I think, at least for my use, that the downsides by far outweigh the
> upsides, and it's pretty much the opposite of how other dev environments do
> it (at least the ones I've used).

Perhaps this should be an enhancement request for echo() to take an
argument to make it less verbose? If this also allowed it to be made
more verbose to also include such luxuries as the file/line, then even
better!


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

Re: Why does echo print the entire line?

Troberg
That would be a nice solution.

Or, possibly, to be able to divert it to a separate window (and, even
better, optionally a file), so it won't get intermingled with other output.



--
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: Why does echo print the entire line?

Troberg
In reply to this post by nophead
nophead wrote
> I think it is far too late to change now as people like me have scripts
> built around it for making BOMs for many years.

I can see that problem, it's not fun going back and rebuild old scripts...



--
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: Why does echo print the entire line?

JordanBrown
On 9/14/2017 4:28 AM, Troberg wrote:
nophead wrote
I think it is far too late to change now as people like me have scripts
built around it for making BOMs for many years.
I can see that problem, it's not fun going back and rebuild old scripts...

Not that it wouldn't be a nuisance, but the straightforward thing to do would be to change the .scad files to emit the "ECHO:" so that the post-processing scripts wouldn't need to change.


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

Re: Why does echo print the entire line?

Gadgetmind
On 2017-09-14 15:59, Jordan Brown wrote:
> Not that it wouldn't be a nuisance, but the straightforward thing to
> do would be to change the .scad files to emit the "ECHO:" so that the
> post-processing scripts wouldn't need to change.

Maybe ...

$echo_verbose = "quiet";

echo ("This won't print the ECHO: prefix.");

echo ("This will", $echo_verbose="normal");

echo ("This will also give file and line number", $echo_verbose="high");

or something.

As long as default matches current behaviour, I can't see anyone
objecting and it's like $fa and $fn now.


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

Re: Why does echo print the entire line?

nophead
>As long as default matches current behaviour, I can't see anyone objecting and it's like $fa and $fn now.

Ha, you wouldn't believe the amount of opposition I got to adding $preview and I was doing the change myself, not asking others to do it.

On 14 September 2017 at 16:07, Gadgetmind <[hidden email]> wrote:
On 2017-09-14 15:59, Jordan Brown wrote:
Not that it wouldn't be a nuisance, but the straightforward thing to do would be to change the .scad files to emit the "ECHO:" so that the post-processing scripts wouldn't need to change.

Maybe ...

$echo_verbose = "quiet";

echo ("This won't print the ECHO: prefix.");

echo ("This will", $echo_verbose="normal");

echo ("This will also give file and line number", $echo_verbose="high");

or something.

As long as default matches current behaviour, I can't see anyone objecting and it's like $fa and $fn now.


_______________________________________________
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: Why does echo print the entire line?

Gadgetmind
On 2017-09-14 16:13, nop head wrote:
> Ha, you wouldn't believe the amount of opposition I got to adding
> $preview and I was doing the change myself, not asking others to do it.

Wow, I hadn't spotted $preview and am using a far less elegant way to
disable debug during renders from my makefile. I'll get fixing my code!


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

Re: Why does echo print the entire line?

Parkinbot
In reply to this post by nophead
The inevitability of "ECHO:" has also annoyed me, since I started programming
with OpenSCAD. A "cheap" way to implement such a switch would be to add it
in "preferences".



--
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: Why does echo print the entire line?

cube
In reply to this post by JordanBrown
From my POV the best option would be to add a MoreSane(tm) solution
controlled by a commandline option, preferences or a runtime call,
then after a year or two switch it to default and deprecate "ECHO:" and
after another year or two remove "ECHO:" completely.

The new solution could be echos going to stdout without any
additional text and everything else to stderr.

> On 9/14/2017 4:28 AM, Troberg wrote:
> > nophead wrote  
> >> I think it is far too late to change now as people like me have
> >> scripts built around it for making BOMs for many years.  
> > I can see that problem, it's not fun going back and rebuild old
> > scripts...  
>
> Not that it wouldn't be a nuisance, but the straightforward thing to
> do would be to change the .scad files to emit the "ECHO:" so that the
> post-processing scripts wouldn't need to change.
>

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

Re: Why does echo print the entire line?

Shaporev, Timur

Sigh.

Why stick on "echo"?

Why not add new primitive name like print, show, type...

No real need to change existing behaviour.


From: Discuss <[hidden email]> on behalf of Kuba Marek <[hidden email]>
Sent: 15 September 2017 09:03:05
To: [hidden email]
Subject: Re: [OpenSCAD] Why does echo print the entire line?
 
From my POV the best option would be to add a MoreSane(tm) solution
controlled by a commandline option, preferences or a runtime call,
then after a year or two switch it to default and deprecate "ECHO:" and
after another year or two remove "ECHO:" completely.

The new solution could be echos going to stdout without any
additional text and everything else to stderr.

> On 9/14/2017 4:28 AM, Troberg wrote:
> > nophead wrote 
> >> I think it is far too late to change now as people like me have
> >> scripts built around it for making BOMs for many years. 
> > I can see that problem, it's not fun going back and rebuild old
> > scripts... 
>
> Not that it wouldn't be a nuisance, but the straightforward thing to
> do would be to change the .scad files to emit the "ECHO:" so that the
> post-processing scripts wouldn't need to change.
>

_______________________________________________
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: Why does echo print the entire line?

jdawgaz
I like Tim's suggestion. In fact, why not a up the stakes to a modified printf kind of behavior?

That way scripts who have been based on the old ECHO behavior don't break, but new way of printing output is added for those who want something different.



--
Extra Ham Operator: K7AZJ
Registered Linux User: 275424
Raspberry Pi and Openscad developer

The most exciting phrase to hear in science - the one that heralds new discoveries - is not "Eureka!" but "That's funny...".
- Isaac. Asimov


On Fri, Sep 15, 2017 at 12:17 AM, Shaporev, Timur <[hidden email]> wrote:

Sigh.

Why stick on "echo"?

Why not add new primitive name like print, show, type...

No real need to change existing behaviour.


From: Discuss <[hidden email]> on behalf of Kuba Marek <[hidden email]>
Sent: 15 September 2017 09:03:05
To: [hidden email]
Subject: Re: [OpenSCAD] Why does echo print the entire line?
 
From my POV the best option would be to add a MoreSane(tm) solution
controlled by a commandline option, preferences or a runtime call,
then after a year or two switch it to default and deprecate "ECHO:" and
after another year or two remove "ECHO:" completely.

The new solution could be echos going to stdout without any
additional text and everything else to stderr.

> On 9/14/2017 4:28 AM, Troberg wrote:
> > nophead wrote 
> >> I think it is far too late to change now as people like me have
> >> scripts built around it for making BOMs for many years. 
> > I can see that problem, it's not fun going back and rebuild old
> > scripts... 
>
> Not that it wouldn't be a nuisance, but the straightforward thing to
> do would be to change the .scad files to emit the "ECHO:" so that the
> post-processing scripts wouldn't need to change.
>

_______________________________________________
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



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

Re: Why does echo print the entire line?

codifies
I like that idea I once coded an opengl version of printf and using stdarg.h to access va_lists
(variable number of parameters...) its super easy....

On 15/09/17 12:57, Jerry Davis wrote:
I like Tim's suggestion. In fact, why not a up the stakes to a modified printf kind of behavior?

That way scripts who have been based on the old ECHO behavior don't break, but new way of printing output is added for those who want something different.



--
Extra Ham Operator: K7AZJ
Registered Linux User: 275424
Raspberry Pi and Openscad developer

The most exciting phrase to hear in science - the one that heralds new discoveries - is not "Eureka!" but "That's funny...".
- Isaac. Asimov


On Fri, Sep 15, 2017 at 12:17 AM, Shaporev, Timur <[hidden email]> wrote:

Sigh.

Why stick on "echo"?

Why not add new primitive name like print, show, type...

No real need to change existing behaviour.


From: Discuss <[hidden email]> on behalf of Kuba Marek <[hidden email]>
Sent: 15 September 2017 09:03:05
To: [hidden email]
Subject: Re: [OpenSCAD] Why does echo print the entire line?
 
From my POV the best option would be to add a MoreSane(tm) solution
controlled by a commandline option, preferences or a runtime call,
then after a year or two switch it to default and deprecate "ECHO:" and
after another year or two remove "ECHO:" completely.

The new solution could be echos going to stdout without any
additional text and everything else to stderr.

> On 9/14/2017 4:28 AM, Troberg wrote:
> > nophead wrote 
> >> I think it is far too late to change now as people like me have
> >> scripts built around it for making BOMs for many years. 
> > I can see that problem, it's not fun going back and rebuild old
> > scripts... 
>
> Not that it wouldn't be a nuisance, but the straightforward thing to
> do would be to change the .scad files to emit the "ECHO:" so that the
> post-processing scripts wouldn't need to change.
>

_______________________________________________
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




_______________________________________________
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: Why does echo print the entire line?

memsfactory
This post was updated on .
Great ideas....but please make it so that we can write output to a file.
Here is an example of a recent issue. I coded up a special design with 100K+
of objects (yes, really!) and I output them to dxf for import into a chip
design software. However, the chip design crashes when I need to increase these to millions of objects so now I need a way for the same openscad code to output all the object coordinates in a data file,
but I can't.  A printf to file would be great!!!!





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

_______________________________________________
OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: Why does echo print the entire line?

MichaelAtOz
Administrator
Wiki
<https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Using_OpenSCAD_in_a_command_line_environment#Export_options>  

> For at least 2015.03-2+, specifying the extension .echo causes openscad to
> produce a text file containing error messages and the output of all echo()
> calls in filename as they would appear in the console window visible in
> the GUI. Multiple output files are not supported, so using this option you
> cannot also obtain the model that would have normally been generated.

> Multiple output files are not supported

It would be a good next step to support .echo in addition to normal
output...



-----
Admin - PM me if you need anything, or if I've done something stupid...

Unless specifically shown otherwise above, my contribution is in the Public Domain; to the extent possible under law, I have waived all copyright and related or neighbouring rights to this work. Obviously inclusion of works of previous authors is not included in the above.

The TPP is no simple “trade agreement.”   Fight it! http://www.ourfairdeal.org/   time is running out!
--
Sent from: http://forum.openscad.org/

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Admin - PM me if you need anything,
or if I've done something stupid...

Unless specifically shown otherwise above, my contribution is in the Public Domain; to the extent possible under law, I have waived all copyright and related or neighbouring rights to this work.
Obviously inclusion of works of previous authors is not included in the above.


The TPP is no simple “trade agreement.” Fight it! http://www.ourfairdeal.org/ time is running out!
Reply | Threaded
Open this post in threaded view
|

Re: Why does echo print the entire line?

Gadgetmind
On 15/09/17 23:12, MichaelAtOz wrote:
> It would be a good next step to support .echo in addition to normal
> output...

Hmmm, thanks, this is actually useful to me now and I hadn't spotted it.
I *must* read the docs from start to end!

I have an aeroplane fuselage held as a multi D vector and need to
"probe" this to get locations and angles of all of the windows. Doing
this at "run time" every time would be slow, so running it as a separate
pass only when this geometry changes, outputting the data from probing
to a file with .echo, cleaning it up with some Python, and then
importing the resulting structure/data for when I need to create the
windows, makes a lot of sense.

I'd still be minded to abuse echo() with extra variables (special, not,
dunno) to set verbosity and maybe even output file (keep a list of ones
already opened, close them at the end, etc.) but maybe that's my
assembly hacked roots!


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

Re: Why does echo print the entire line?

jdawgaz
as for going to a file, I don't believe that is necessary.
I do this for some of my scripts:

example:

centerpiece4_build.sh > out.txt 2>&1

the output (all of it) goes to out.txt and you can do with it what you want.



--
Extra Ham Operator: K7AZJ
Registered Linux User: 275424
Raspberry Pi and Openscad developer

The most exciting phrase to hear in science - the one that heralds new discoveries - is not "Eureka!" but "That's funny...".
- Isaac. Asimov


On Sat, Sep 16, 2017 at 3:38 AM, Gadgetmind <[hidden email]> wrote:
On 15/09/17 23:12, MichaelAtOz wrote:
It would be a good next step to support .echo in addition to normal
output...

Hmmm, thanks, this is actually useful to me now and I hadn't spotted it. I *must* read the docs from start to end!

I have an aeroplane fuselage held as a multi D vector and need to "probe" this to get locations and angles of all of the windows. Doing this at "run time" every time would be slow, so running it as a separate pass only when this geometry changes, outputting the data from probing to a file with .echo, cleaning it up with some Python, and then importing the resulting structure/data for when I need to create the windows, makes a lot of sense.

I'd still be minded to abuse echo() with extra variables (special, not, dunno) to set verbosity and maybe even output file (keep a list of ones already opened, close them at the end, etc.) but maybe that's my assembly hacked roots!



_______________________________________________
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
12