#23 suppressing output in interactive mode

closed
nobody
None
5
2007-09-05
2007-08-26
fedja30
No

If you have a function that returns a value and call it in the interactive mode without assigning this value to some variable, this value is displayed in the interactive window right after the call line. It makes perfect sense, of course, and sometimes is useful but sometimes it becomes just irritating (especially when the value is a path or a long array). It would be nice to have some command that suppresses this particular type of output (like echo on/echo off in batch files). Perhaps, such a command exists already but I couldn't find it in the manual...

Discussion

  • Logged In: YES
    user_id=1144470
    Originator: NO

    For a line-by-line basis, this can be done by adding {} around the statement:

    Welcome to Asymptote version 1.34svn (to view the manual, type help)
    > sequence(5);
    0: 0
    1: 1
    2: 2
    3: 3
    4: 4
    > { sequence(5); }
    >

    Was this what you were thinking, or did you want to turn it off altogether? It would be a one-liner to add such a setting, though I'm leery of going overboard on settings.

    The interactive write feature basically tests if write(...) can be wrapped around the expression successfully, and if it can, the wrapped code is run instead. When we implemented it, we considered wrapping interactiveWrite(...) around the expression instead, but decided against it at the start, since there wasn't much advantage. Perhaps we should implement it, and have interactiveWrite limit the number of lines it prints for arrays.

    Can you describe in more detail the context in which interactive writing became so annoying? It may help us decide what to do.

     
  • fedja30
    fedja30
    2007-09-05

    Logged In: YES
    user_id=1872477
    Originator: YES

    Here is one example. I found it convenient to make the drawing command to return the objects it draws. Also, I like my pictures in color. So, I defined

    path D(path P,pen p=blue)
    {
    draw(P,p);
    return P;
    }

    and similarly for dotting pairs (only I dot them in red). This allows me to write

    D(IP(D(P),D(Q)));

    (IP is just my abbreviation for intersectionpoint, of course) instead of

    draw(P,blue);
    draw(Q,blue);
    dot(intersectionpoint(P,Q),red);

    which I find quite nice (it is a matter of taste, of course, but, since my typing is rather slow, it saves me some time). But the problem is that when I want just to draw the path P using the same D(), it outputs all the path controls and if P is a Circle, say, it takes a lot of space. So I thought that, maybe, this kind of output could be turned off. Putting {} around the commands is not too hard but one command in the beginning would be even better.

     
    • status: open --> closed
     
  • Logged In: YES
    user_id=1144470
    Originator: NO

    I've added a boolean "interactiveWrite" setting that defaults to true. You can turn off interactive output by setting this to false:

    Welcome to Asymptote version 1.34svn (to view the manual, type help)
    > 2+3
    5
    > settings.interactiveWrite
    true
    > settings.interactiveWrite=false
    > settings.interactiveWrite
    > 2+3
    >

    Like most settings, it can also be specified on the command line:

    asy -nointeractiveWrite

    and in config.asy. John also suggested looking at settings.scroll, which can be set to -1 to page through long arrays.