Menu

car. returns added to my written strings/char

Help
S. Rigaud
2007-10-31
2012-12-29
  • S. Rigaud

    S. Rigaud - 2007-10-31

    Here is a simple M file that only reads from a text file
    and then displays the lines:

    srigaud@crusoe995:~$ cat gtm/test71.m
    readfile
            w "in rf",!
            n f,str,fdf
            s f="gtm/t2.txt"
            o f:(readonly)
            w "OK file "_f_" open",!
            s str=""

           ;<CR> = 10
            f  d  q:fdf
            . u f r line set fdf=$zeof
            . set str=str_line_$c(10)
            c f
            ;u 0
            u $p
            w "ok gone out of loop",!
           ;w "ok str: "_str
            w "ok str: ",!,str
            q

    Here is the file I read (80 chars/line):

    srigaud@crusoe995:~$ cat gtm/t2.txt
    123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789
    line 1 AAAAAAAAAAAAAAAaaaaaaAaAaAAaAaAAaaAaaaaaaaaaaaAAAAAAAaaaaaAaAaAaAaAaAaAaA
    then 2 bbbbbbbbBBBBBBBBBBBbbbbBBBBBBBBBBBBBbbbbbBBbBBbbBbbBBbbbbbbbbbbbbBBBBBBBB
    next 3 ccccccccccccCCCCCCCCCCCCCCCCCCCCCCCCcccccccccccccccccCCCCCCCcccCCcCcCCCCC
    and 4 dddddddddDDDDDDDDDDDDDDDdddDddDddddddDDDDDddddddddddddDDDDDDdddDDDdDdddddd
    srigaud@crusoe995:~$

    My problem is as follows: some lines get cut somewhere, somewhere mumps adds
    a carriage return in the string (below run connected from a client):

    srigaud@crusoe995:~$ mumps -dir

    GTM>d ^test71
    in rf
    OK file gtm/t2.txt open
    ok gone out of loop
    ok str:
    123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789
    line 1 AAAAAAAAAAAAAAAaaaaaaAaAaAAaAaAAaaAaaaaa
    aaaaaaAAAAAAAaaaaaAaAaAaAaAaAaAaA
    then 2 bbbbbbbbBBBBBBBBBBBbbbbBBBBBBBBBBBBBbbbbbBBbBBbbBbbBBbbbbbbbbbbbbBBBBBBBB
    next 3 cccccc
    ccccccCCCCCCCCCCCCCCCCCCCCCCCCcccccccccccccccccCCCCCCCcccCCcCcCCCCC
    and 4 dddddddddDDDDDDDDDDDDDDDdddDddDddddddDDDDDdddddddddddd
    DDDDDDdddDDDdDdddddd

    Funnily enough if I run the same .m file from the machine on which GT.M resides
    I get different truncations (but they happen to be ALWAYS the same when run
    several times from the same terminal):

    GTM>d ^test71
    in rf
    OK file gtm/t2.txt open
    ok gone out of loop
    ok str:
    123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789
    line 1 AAAAAAAAAAAAAAAaaaaaaAaAaAAaAaAAaaAa
    aaaaaaaaaaAAAAAAAaaaaaAaAaAaAaAaAaAaA
    then 2 bbbbbbbbBBBBBBBBBBBbbbbBBBBBBBBBBBBBbbbbbBBbBBbbBbbBBbbbbbbbbbbbbBBBBBBBB
    next
    3 cccccc ccccccCCCCCCCCCCCCCCCCCCCCCCCCcccccccccccccccccCCCCCCCcccCCcCcCCCCC
    and 4 dddddddddDDDDDDDDDDDDDDDdddDddDddddddDDDDD
    ddddddddddddDDDDDDdddDDDdDdddddd

    See ?, the line 3 for example has been cut here on another place (immediately
    after "next ")...

    If I write to a file this trouble DOES NOT occur, never (I mean if instead
    of writing to $P I write to another file). I tried with 'read *c' or 'read c#1'
    (converting with $char() where necessary and just doing ". use f2 write c" in
    the 'for' loop) but I have the same behaviour...

    Any idea ? What's wrong ? (it's the last version of GT.M running on Debian)

    Thanks a lot...
    Regards,
    S. Rigaud

     
    • S. Rigaud

      S. Rigaud - 2007-10-31

      Oops I made a mistake, I meant ". use $p write c" (instead of ". use f2 write c").
      Sorry.

       
    • Dr. Martin Lehr

      Dr. Martin Lehr - 2007-10-31

      Hello,

      I think your problem arises from linefeeds that gt.m adds while writing
      the lines to terminal (the line  w "ok str: ",!,str)
      Normally, after 80 chars output gt.m adds a $C(10) (wrapping)

      To avoid this, add this line:
      U $P:(NOWRAP:LENGTH=0) 

      Kind Regards

      Martin

       

Log in to post a comment.