Is it possible to get argv[0] in postscript?

孤者浪人 提交于 2019-12-02 11:09:31

问题


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.

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.


回答1:


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.

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

<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 and the PostScript language


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


来源:https://stackoverflow.com/questions/25777636/is-it-possible-to-get-argv0-in-postscript

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!