matrix pretty printing (and why does str() eliminate spaces?)

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

matrix pretty printing (and why does str() eliminate spaces?)

adrianv
I would like to print out matrices sometimes in an orderly rectangular
array---it's much easier to read that way.  

There appear to be to difficulties in achieving this goal.  One is that with
the loss of HTML and the fact that the output font is proportionally spaced,
there is no way to line anything up from one line to the next.  In
particular, the hyphens are very short and throw off the alignment, but even
narrower digits have an effect. Have I missed some possibility?  Do tabs
still work?  They help a bit.  

The other problem I have is that it appears to be impossible to create a
string containing N spaces.  If I run str(" "," ") or any similar command,
it collapses the multiple spaces into a single space.  Is there a way I can
produce a string of N spaces?   I tried a unicode non-breaking space and I
can produce the desired string, but if I recall correctly, it didn't display
correctly under Windows.  I had to resort to using the underscore instead of
the space.   Without the ability to produce N spaces, I can't pad the
numbers to line them up with each other.  







--
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: matrix pretty printing (and why does str() eliminate spaces?)

frankv
Maybe output tab or comma delimited text and import it into a spreadsheet?

To cut down on clicks, in Excel I have a "master" spreadsheet that has the "data" CSV file as an included table. Refreshing the master picks up the latest version of the data.

On Mon, 2 Mar 2020, 06:46 adrianv, <[hidden email]> wrote:
I would like to print out matrices sometimes in an orderly rectangular
array---it's much easier to read that way. 

There appear to be to difficulties in achieving this goal.  One is that with
the loss of HTML and the fact that the output font is proportionally spaced,
there is no way to line anything up from one line to the next.  In
particular, the hyphens are very short and throw off the alignment, but even
narrower digits have an effect. Have I missed some possibility?  Do tabs
still work?  They help a bit. 

The other problem I have is that it appears to be impossible to create a
string containing N spaces.  If I run str(" "," ") or any similar command,
it collapses the multiple spaces into a single space.  Is there a way I can
produce a string of N spaces?   I tried a unicode non-breaking space and I
can produce the desired string, but if I recall correctly, it didn't display
correctly under Windows.  I had to resort to using the underscore instead of
the space.   Without the ability to produce N spaces, I can't pad the
numbers to line them up with each other. 







--
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: matrix pretty printing (and why does str() eliminate spaces?)

doug.moen
In reply to this post by adrianv
The str() function does not eliminate spaces. Try echo(len("     ")); and it should print '5'.

What seems to be happening is that multiple adjacent spaces are being suppressed when printing to the GUI console. This is a regression from a 2017 version of OpenSCAD that I also tested.

Doug Moen.

On Sun, Mar 1, 2020, at 12:45 PM, adrianv wrote:

> I would like to print out matrices sometimes in an orderly rectangular
> array---it's much easier to read that way.  
>
> There appear to be to difficulties in achieving this goal.  One is that with
> the loss of HTML and the fact that the output font is proportionally spaced,
> there is no way to line anything up from one line to the next.  In
> particular, the hyphens are very short and throw off the alignment, but even
> narrower digits have an effect. Have I missed some possibility?  Do tabs
> still work?  They help a bit.  
>
> The other problem I have is that it appears to be impossible to create a
> string containing N spaces.  If I run str(" "," ") or any similar command,
> it collapses the multiple spaces into a single space.  Is there a way I can
> produce a string of N spaces?   I tried a unicode non-breaking space and I
> can produce the desired string, but if I recall correctly, it didn't display
> correctly under Windows.  I had to resort to using the underscore instead of
> the space.   Without the ability to produce N spaces, I can't pad the
> numbers to line them up with each other.  
>
>
>
>
>
>
>
> --
> 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: matrix pretty printing (and why does str() eliminate spaces?)

Ronaldo
In reply to this post by adrianv
I could not find any way to echo() more than one space in a row on Windows. I have tried all ASCII control codes in str() and just two are useful: a line feed (chr(10) and a tab (char(9)). However the tab is very long.

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

Re: matrix pretty printing (and why does str() eliminate spaces?)

nophead
In reply to this post by doug.moen
Yes I think it is perhaps left over HTML behaviour because the console window is still HTML based but the text is escaped so <, etc no longer work. 

I think it was a big mistake to remove the HTML behaviour that people have been using for years without providing any replacement to get formatted output, although I don't use it myself.

On Sun, 1 Mar 2020 at 19:54, Doug Moen <[hidden email]> wrote:
The str() function does not eliminate spaces. Try echo(len("     ")); and it should print '5'.

What seems to be happening is that multiple adjacent spaces are being suppressed when printing to the GUI console. This is a regression from a 2017 version of OpenSCAD that I also tested.

Doug Moen.

On Sun, Mar 1, 2020, at 12:45 PM, adrianv wrote:
> I would like to print out matrices sometimes in an orderly rectangular
> array---it's much easier to read that way. 
>
> There appear to be to difficulties in achieving this goal.  One is that with
> the loss of HTML and the fact that the output font is proportionally spaced,
> there is no way to line anything up from one line to the next.  In
> particular, the hyphens are very short and throw off the alignment, but even
> narrower digits have an effect. Have I missed some possibility?  Do tabs
> still work?  They help a bit. 
>
> The other problem I have is that it appears to be impossible to create a
> string containing N spaces.  If I run str(" "," ") or any similar command,
> it collapses the multiple spaces into a single space.  Is there a way I can
> produce a string of N spaces?   I tried a unicode non-breaking space and I
> can produce the desired string, but if I recall correctly, it didn't display
> correctly under Windows.  I had to resort to using the underscore instead of
> the space.   Without the ability to produce N spaces, I can't pad the
> numbers to line them up with each other. 
>
>
>
>
>
>
>
> --
> 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

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

Re: matrix pretty printing (and why does str() eliminate spaces?)

adrianv
In reply to this post by doug.moen
Indeed.  I wonder if this has to do with the HTML processing.  After all, in
HTML multiple spaces will disappear.  I tried a string of many "&nbsp;" and
(in the stable version) it displays as many spaces, so this supports that
idea.  So I downloaded the latest development snapshot, where HTML no longer
works, and indeed, the spaces print out in full.  (I've been avoiding the
dev versions because I've been writing library code and don't want to use
new features.)  

Regarding copying stuff into excel.  That's a huge nuisance.  I'm not
writing reports.  I'm debugging code and just want to immediately see what
the matrix looks like---does it match the one I computed in another
language, for example.  

So what about the alignment problem?  Is there any way to line up a set of
right justified text strings?   It does seem rather surprising, given the
generally conservative approach to change the developers have, that they
decided to eliminate this feature, which breaks a bunch of people's code.  


doug.moen wrote

> The str() function does not eliminate spaces. Try echo(len("     ")); and
> it should print '5'.
>
> What seems to be happening is that multiple adjacent spaces are being
> suppressed when printing to the GUI console. This is a regression from a
> 2017 version of OpenSCAD that I also tested.
>
> Doug Moen.
>
> On Sun, Mar 1, 2020, at 12:45 PM, adrianv wrote:
>> I would like to print out matrices sometimes in an orderly rectangular
>> array---it's much easier to read that way.  
>>
>> There appear to be to difficulties in achieving this goal.  One is that
>> with
>> the loss of HTML and the fact that the output font is proportionally
>> spaced,
>> there is no way to line anything up from one line to the next.  In
>> particular, the hyphens are very short and throw off the alignment, but
>> even
>> narrower digits have an effect. Have I missed some possibility?  Do tabs
>> still work?  They help a bit.  
>>
>> The other problem I have is that it appears to be impossible to create a
>> string containing N spaces.  If I run str(" "," ") or any similar
>> command,
>> it collapses the multiple spaces into a single space.  Is there a way I
>> can
>> produce a string of N spaces?   I tried a unicode non-breaking space and
>> I
>> can produce the desired string, but if I recall correctly, it didn't
>> display
>> correctly under Windows.  I had to resort to using the underscore instead
>> of
>> the space.   Without the ability to produce N spaces, I can't pad the
>> numbers to line them up with each other.  
>>
>>
>>
>>
>>
>>
>>
>> --
>> Sent from: http://forum.openscad.org/
>>
>> _______________________________________________
>> OpenSCAD mailing list
>>

> Discuss@.openscad

>> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
>>
>
> _______________________________________________
> OpenSCAD mailing list

> Discuss@.openscad

> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org





--
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: matrix pretty printing (and why does str() eliminate spaces?)

MichaelAtOz
Administrator
On a tangent, you could use text(), a monospaced font and OpenSCAD translate
etc, if you just want to eyeball it...



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

* click on my MichaelAtOz label, there is a link to email me.

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.

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

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Admin - email* me if you need anything, or if I've done something stupid...
* click on my MichaelAtOz label, there is a link to email me.

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.