是否可以在后记中获取argv [0]? [英] Is it possible to get argv[0] in postscript?

查看:90
本文介绍了是否可以在后记中获取argv [0]?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否可以在脚本中获取argv [0]。

I was wondering if it is possible to get argv[0] in postscript.

例如,我希望能够打印后记文件的名称。

For example, I want to be able to print the postscript file's name.

如果我将后标文件命名为1.ps,则它将打印出1;如果我将其命名为2.ps,则它将输出2,依此类推。

If I name the postscript file 1.ps then it will print out 1 and if I name it 2.ps it will print out 2 and so on.

推荐答案

通常对于Postscript来说这是不可能的。许多后记环境(例如在打印机中)根本没有文件系统或文件名。通常,文件只是一次访问一个字节序列的抽象。

This is not possible with Postscript in general. Many postscript environments, like in a printer, will not have a filesystem or filenames at all. A file in the general sense is just an abstraction for accessing a sequence of bytes one at a time.

Ghostscript解释器实现了一个扩展,该扩展可能使您能够执行所需的操作。

The Ghostscript interpreter implements an extension which may enable you to do what you want.


< file> .filename< string> true

< file> .filename false

如果文件是由文件或.tempfile运算符打开的,则返回文件名和true;否则,返回true。如果文件是过滤器,则返回false。

<file> .filename <string> true
<file> .filename false
If the file was opened by the file or .tempfile operator, returns the file name and true; if the file is a filter, returns false.

Ghostscript和PostScript语言

但更常见的做法是生成其他程序的postscript输出。这样一来,确定源文件可能会更好,因为可以想象到,后记可以即时生成并进行传输,而无需在磁盘上存在。

But a much more common thing to do would be to generate the postscript output from another program. It then would probably be better to identify the source file, since the postscript might conceivably be generated on the fly and transmitted without needing to exist on disk.

或者为了简单起见,在程序顶部的字符串中定义文件名,以便轻松查找是否要更改它。

Or for simpler purposes, define the filename in a string at the very top of the program so it's easy to find if you ever want to change it.

%!
/thisfile (myfilename.ps) def

这篇关于是否可以在后记中获取argv [0]?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆