是否可以在后记中获取argv [0]?

编程入门 行业动态 更新时间:2024-10-27 19:18:58
本文介绍了是否可以在后记中获取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]?

本文发布于:2023-10-29 20:26:43,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1540655.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:后记   argv

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!