Dictionary Postscrip/Ghostscript如何将堆栈顶部另存为字典项

Dictionary Postscrip/Ghostscript如何将堆栈顶部另存为字典项,dictionary,postscript,Dictionary,Postscript,我在Linux下使用Ghostscript,但仍然觉得自己是个新手。我希望将该值保存在堆栈顶部,以便以后可以调用该值,而无需执行复杂的堆栈操作来检索它。该值将是从数据文件读取的纬度,因此我无法直接合并它;在节目中有一个很好的例子。在我看来,显而易见的解决方案是将值作为键/值对存储在userdict中,类似于(保存纬度值): 请有人解释一下如何使用括号中的位?很可能是我把一切都搞错了,在这种情况下,我该怎么办呢 背景:我正在编写一个程序,使用文件中的纬度和经度数据,绘制可以剪切并粘贴到球上的血迹,

我在Linux下使用Ghostscript,但仍然觉得自己是个新手。我希望将该值保存在堆栈顶部,以便以后可以调用该值,而无需执行复杂的堆栈操作来检索它。该值将是从数据文件读取的纬度,因此我无法直接合并它;在节目中有一个很好的例子。在我看来,显而易见的解决方案是将值作为键/值对存储在userdict中,类似于(保存纬度值):

请有人解释一下如何使用括号中的位?很可能是我把一切都搞错了,在这种情况下,我该怎么办呢


背景:我正在编写一个程序,使用文件中的纬度和经度数据,绘制可以剪切并粘贴到球上的血迹,从而制作一个世界地球仪。有一个相当多的数学需要衡量经度,以适应他们的正确;我使用的数据是gnuplot安装中包含的
world.dat
中的1320个坐标集。

您没有提供足够的数据继续,什么是“坐标”和“纬度”

您已经在操作数堆栈上创建了一个2项字典,“coords”是一个可执行的过程吗?如果是,它是否返回操作数堆栈上的字典

通过按现有方式执行“put”,您将在当前字典中定义一个数组,其键为“lat”,不管对象类型是什么。然后,您需要再次访问“lat”,以便从字典中检索对象(或者在字典中使用forall,并且仍然很难检索特定值)

要回答您的问题,这将定义当前字典中操作数堆栈顶部的值:

5       %% put an object on top of the dictionary stack, stack is now: 5
/Saved  %% create a name object on the operand stack, stack is now: 5 /Saved
exch    %% exchange the objects, stack is now: /Saved 5
def     %% define the value on the stack in the current dictionary, using the
        %% key also on the stack
请注意,这在字典堆栈顶部的当前字典中定义。要在userdict中显式定义它,请执行以下操作

5          %% put an object on the operand stack, stack is now: 5
/Saved     %% put a name object on the operand stack, stack is now: 5 /Saved
exch       %% exchange the objects, stack is now: /Saved 5
userdict   %% put a pointer to userdict on the operand stack, stack is now /Saved 5 <<userdict>>
3 1 roll   %% roll the stack, stack is now: <<userdict>> /Saved 5
put        %% put the value from the operand stack, using the key from the operand stack, in the dictionary also on the operand stack
5%%将对象放在操作数堆栈上,堆栈现在为:5
/已保存%%将名称对象放入操作数堆栈,堆栈现在为:5/已保存
exch%%交换对象,堆栈现在保存:/5
userdict%%将指向userdict的指针放在操作数堆栈上,堆栈现在/保存为5
3 1滚动%%滚动堆栈,堆栈现在保存:/5
put%%使用操作数堆栈中的键将操作数堆栈中的值放入字典中,也放入操作数堆栈中

谢谢你,肯斯。我的问题的一个简单完美的答案。很抱歉我在userdict上的失礼。我让这一切听起来比必要的更复杂。我将编辑这个问题,以更完整地解释我在做什么
5          %% put an object on the operand stack, stack is now: 5
/Saved     %% put a name object on the operand stack, stack is now: 5 /Saved
exch       %% exchange the objects, stack is now: /Saved 5
userdict   %% put a pointer to userdict on the operand stack, stack is now /Saved 5 <<userdict>>
3 1 roll   %% roll the stack, stack is now: <<userdict>> /Saved 5
put        %% put the value from the operand stack, using the key from the operand stack, in the dictionary also on the operand stack