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: Juergen Sauermann
Subject: Re: [Bug-apl] Calling Value::print() with different ⎕PW
Date: Thu, 22 May 2014 16:14:42 +0200
User-agent: Mozilla/5.0 (X11; Linux i686; rv:17.0) Gecko/20130330 Thunderbird/17.0.5

Hi Elias,

so do_CR returns the internal character representation which contains "blanks" inserted
by the APL formatting (which is somewhat non-trivial). The different symbols tell why a blank
was inserted and the final action is to (1) replace the blanks and to (2) ⎕PW-wrap the output.
You want the first but no the second. My proposal would be this then:

Maybe (needed ?) check the rank of Z with Z->get_rank() and

   loop(z, Z->element_count())
      {
         Unicode uni =
Z->get_ravel(z).get_char_value();
         if (is_iPAD_char(uni))   uni = UNI_ASCII_SPACE;
         out << uni;
         if (z && !(z%Z->get_last_shape_item())   out << endl;
       }


If you change the first parameter (a) of do_CR then you get the other style which
mostly differ by the line characters used (ASCII, thin lines, thick lines etc). You
can change combinations of inner and outer line styles that way; the result
is most likely bad. Some values for a ignore the line style.

/// 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]