[categories] [index] [all (553)] [latest]
gv x.ps
stty raw -echo; cat >> x.txt
/Sleep { 1000000 mul {} repeat } def
/buffer 8 string def
/FILENAME (/Users/nseriot/Desktop/x.txt) def
/shouldTruncate false def
% create file
{
FILENAME (w) file closefile } stopped {
(Error creating file ) print FILENAME = flush
quit
} if
0 1 10000 {
/i exch def
(-- ) =only i ==
% read file contents
{
FILENAME (r) file buffer readstring { (full) == } { (not full) == } ifelse
dup length 0 ne /shouldTruncate exch def
{ = } forall
} stopped {
(stopped) ==
stop
} if
% truncate file if needed
shouldTruncate {
{
FILENAME (w) file closefile
} stopped {
(Error truncating file) =
} if
/shouldTruncate false def
} if
flush
200 Sleep
} for