PostScript control loop - server loop

时间:2017-06-15 09:43:37

标签: postscript

I'm investigating the start/server loop. The Insi de Postscript book explains the /start procedure. One part of that procedure is the control loop:

...
{
  //serverdict /server get exec

  //serverdict begin

  setstreams
  setnulldevice
  /execjob
  load

  end
  exec
} loop
...

Now i'm trying to find out what /server exactly does and how it might look like (in its most simple form).

//serverdict /server get exec

This line above gets the server procedure and executes it immediately.

Now I have a server loop like this:

/server {
 { % server loop
    (i'm in a server loop) print flush
    (%stdin) run
 }
 loop
} def

but i'm stuck in an infinite loop. How and when can the server loop ever go to the next step (//serverdict begin setstreams etc...) as it is currently in an infinite loop?

1 个答案:

答案 0 :(得分:1)

在您显示的控制循环中,绑定到名称server的对象似乎不会像您的代码那样循环。它似乎做了一些初始化然后返回。表达式/execjob load似乎运行当前作业。除此之外,{ ... } loop表达式似乎是您实现的服务器循环。

如果要将自己的服务器代码插入到提供的循环中,则需要使用解释程序提供的//serverdict内容。如果你想编写自己的服务器循环,似乎你需要走出一个级别,并替换整个{ ... } loop表达式,也可能//serverdict

如果你想“找出/服务器究竟做了什么以及它看起来如何......”,那么看它呢?道德等同于:

//serverdict /server get == flush