出力の一時停止と再開
Posted feedbacks - PostScript
無謀にも PostScript で。 GhostScript 7.07 のファイル関連のオペレーターのbug だか仕様だかに泣かされました...
どうにもならなかったので ghostscript 2本並列実行で文字入力と表示を役割分担しています。 プロセス間通信は名前付きファイルで... 激しくファイルの open/close をしますので実用的ではありません。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | %% Terminal 1
% stty raw < /dev/tty
% gs -sDEVICE=nullpage echoback.ps
%% Terminal 2
% gs -sDEVICE=nullpage pause.ps
%------------------ echoback.ps ----- Cut Here ---------
%!PS
/Stdin (%stdin) (r) file def
(/tmp/test) (w) file closefile
% p: 112, q: 113
{
Stdin read
{
(/tmp/test) (w) file dup 2 index write closefile
113 eq { exit } if
} {exit} ifelse
} loop
quit
%-------------------- pause.ps ------ Cut Here ---------
%!PS
/Sleep { % OutputFlag Timer Sleep OutputFlag'
realtime
{
realtime 1 index sub
2 index ge {exit} if
(/tmp/test) (r) file dup read
{
exch closefile (/tmp/test) (w) file exch
dup 113 eq { quit } if
112 eq { 4 -1 roll not 4 1 roll } if
} if
closefile
} loop
pop
pop
} def
true
{
1000 Sleep
dup {(a) print flush} if
} loop
|


nobsun
#6346()
Rating3/3=1.00
起動すると、標準出力に1秒毎に'a'の1文字を出力し続けるプログラムで、 以下の条件を満たすものを「どう書く?」
[ reply ]