bug-apl
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Bug-apl] Calling Value::print() with different ⎕PW


From: Elias Mårtenson
Subject: Re: [Bug-apl] Calling Value::print() with different ⎕PW
Date: Fri, 23 May 2014 10:47:29 +0800

Thanks! It works now.

Could you check out the latest version from git branch "master" and copy the content of the directory "native" it to the GNU APL distribution? I've updated everything and included the Makefile.am file so that it should need to changes.

This will ensure that the native module is up-to-date in the distribution.

Regards,
Elias


On 23 May 2014 02:00, Juergen Sauermann <address@hidden> wrote:
Hi Elias,

I have added Value::print1(ostream & out, PrintContext pctx).

I have used PrintContext instead of print width because you probably
want to set the print precision and maybe style as well.

Use like:

PrintContext pctx( /* satyle */ PST_NONE, /* precision */ 16, /* width */ 2000);
   value->print1(out, pctx);

As I said earlier, it could be that the print width of the workspace slips in somewhere.
If so then we have to troubleshoot that. SVN 285.


/// Jürgen


On 05/22/2014 04:42 PM, Elias Mårtenson wrote:
The value argument could be anything. Basically, all I want to do is the following:
  • Given any Value_P, get the textual representation of that value as if it had been displayed in the interpreter, without any wrapping. Or...
  • Given any Value_P, get the textual representation of that value as if it had been displayed using ⎕CR with a numeric left argument being the values 1 to 9. Again, without any line wrapping.
That's really all I'm trying to do.

Regards,
Elias


On 22 May 2014 22:38, Juergen Sauermann <address@hidden> wrote:
Hi again,

it is actually somewhat difficult to see what happens.
The private use characters are not displayed in the same way on all machines.
Also I can't see how your do_CR() value argument  looks like (could be ⍳ something).
Maybe it is easier to start with an a that does not involve print styles
(such as 5 ⎕CR 'hello').

/// Jürgen


On 05/22/2014 03:51 PM, Elias Mårtenson wrote:
Well, I tried with 1 as well, and got the same result. How do you recommend I deal with it?

Also, how can I use do_CR to render with the default (non-CR) output style?

Regards,
Elias


On 22 May 2014 21:47, Juergen Sauermann <address@hidden> wrote:
Hi Elias,

I see, the private use symbols can be made visible with ./configure  VISIBLE_MARKERS_WANTED-yes
in case you are interested in the details of APL output formatting. They can be removed (visible or not)
with UCS_string::remove_pad() (which returns another UCS_string
with these characters replaced with spaces).

Apart from that everything looks really fine :-) .

You probably want to go for 1. anyhow.

/// Jürgen



On 05/22/2014 03:35 PM, Elias Mårtenson wrote:
Thanks. I tried the second solution, and got the below result. Very strange. Here's the code:

        const PrintContext pctx( PST_NONE, Workspace::get_PP(), 100000 );
        Value_P cr_formatted = Quad_CR::do_CR( cr_level, *value, pctx );

        const PrintContext pctx2( PST_NONE, Workspace::get_PP(), 100000 );
        PrintBuffer buffer( *cr_formatted, pctx2 );
        out << buffer;

Then, this renders as a lot of private use symbols (U+EEEE). I've attached a screenshot of what it looks like.

Regards,
Elias


On 22 May 2014 21:10, Juergen Sauermann <address@hidden> wrote:
Hi Elias,

if the values was a matrix then you may have another problem that
the matrix has no \n at the end of each row (not sure how your output is
supposed to look like).

Let say do_CR returns Value_P Z (which can be a scalar, a vector, or
a matrix depending on the value ⎕CRed and the first arg of do_CR().
Then there are two options:

1. Check the rank of Z with Z->get_rank() and

   loop(z, Z->element_count())
      {
         out << Z->get_ravel(z).get_char_value();
         // insert \n as needed, i.e. z%Z->get_last_shape_item();
       }

2.Construct a PrintBuffer object from Z (with ⎕PW as needed) and

   out << PrintBuffer object;

I haven't tested this; 1. seems more reliable (and definitely faster) while 2. looks more elegant.


/// Jürgen



On 05/22/2014 02:46 PM, Elias Mårtenson wrote:
Thank you. But I don't see how I can solve my problem then?

Regards,
Elias


On 22 May 2014 20:44, Juergen Sauermann <address@hidden> wrote:
Hi Elias,

yes, sorry. Forgot to mention that the APL values used in the constructor of UCS_string
must have rank ≤ 1 while do_CR() might produce matrices for some left arguments of ⎕CR.

/// Jürgen













reply via email to

[Prev in Thread] Current Thread [Next in Thread]