Tabulation, and pop_charout_col 
Author Message
 Tabulation, and pop_charout_col

The following procedure is nice and handy as a way of laying things out
in columns if they don't happen to have a fixed print length.

define tabto n;
  if n<0 then nl(1)
  elseif n<pop_charout_col then nl(1); tabto(n)
  else sp(n-pop_charout_col)
  endif
enddefine;

But of course it does not work if you are outputting to anything other
than the "terminal". Now clearly one can program round any problems, but
is there a nice easy way of generating disc-files with tabulated output?

Robin



Fri, 03 May 1996 21:53:37 GMT  
 Tabulation, and pop_charout_col

Quote:

> But of course it does not work if you are outputting to anything other
> than the "terminal". Now clearly one can program round any problems, but
> is there a nice easy way of generating disc-files with tabulated output?

> Robin

A standard way of printing to disk is simply to reassign cucharout
to a character consumer that sends the data to disk, and then just
print in the normal way.

E.g.

    define name_space;
        npr('     my    name    is    Ian       Rogers');
    enddefine;

    define print_to_disc;
        dlocal cucharout = discout('name_file');
        name_space();
        cucharout(termin);
    enddefine

The final 'cucharout(termin);' is needed to close the disk device,
although it's not strictly needed as the garbage collector will do
it for you at the next collection.

pop_charout_col and company will work for these "disk" devices
as well as for "terminals". Ie., from REF * CHARIO:

  pop_charout_col -> int                                        [variable]
  int -> pop_charout_col
  pop_charerr_col -> int                                        [variable]
  int -> pop_charerr_col
          These variables  contain  integers representing  the  number  of
          columns filled  by charout  and  charerr respectively  in  their
          current lines,  where  tab  characters  count  as  vedindentstep
          columns if in VED or 8 otherwise, control characters (i.e. ASCII
          value < 32) count as none, and all other characters count as  1.
          These values are reset to 0 on outputting a newline character.

Ian                  



Sun, 05 May 1996 02:14:23 GMT  
 Tabulation, and pop_charout_col

Quote:
> pop_charout_col and company will work for these "disk" devices
> as well as for "terminals". Ie., from REF * CHARIO:

>   pop_charout_col -> int                                        [variable]
>   int -> pop_charout_col
>   pop_charerr_col -> int                                        [variable]
>   int -> pop_charerr_col
>           These variables  contain  integers representing  the  number  of
>           columns filled  by charout  and  charerr respectively  in  their

                               ^^^^^^^       ^^^^^^^

Pah! That's what I get for not reading the documentation properly :-(
charout is the default value of cucharout, so reassigning cucharout will
stop pop_charout_col from being updated.

But, the standard pretty printers in Pop *will* work (honest, I've
actually checked this time :-), and printf and so one will also work.

    define print_big;
        [oh freddled [gruntbuggly, thy] micturations are to me as plurdled
        gabbleblotchets [on a [lurged] bee] [groop [I implore you [my
        footing turlingdrome [and] hooptiously drangle] me in crinkly]
        bindle wurgles]] ==>
    enddefine;

    define big_to_disk;
        dlocal cucharout = discout('hrummph');
        print_big();
        cucharout(termin);
    enddefine;

    big_to_disk();

Ian.                  



Sun, 05 May 1996 02:43:03 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Call for participation: TAPD2000, 2nd Workshop on Tabulation in Parsing and Deduction

2. Final CFP: TAPD 2000, 2nd Workshop on Tabulation in Parsing and Deduction

3. 2nd CFP: TAPD2000, 2nd Workshop on Tabulation in Parsing and Deduction

4. CFP: TAPD2000, 2nd Workshop on Tabulation in Parsing and Deduction

 

 
Powered by phpBB® Forum Software