首页 > 解决方案 > 如何将堆栈的全部内容复制到 PostScript 中的数组中

问题描述

简单明了:如何将堆栈的内容复制到 PostScript 中的数组中?

标签: postscript

解决方案


首先你需要做一个足够大的数组来容纳所有的元素,所以你需要用它count来找出有多少元素。然后您需要创建一个该大小的数组,最后您需要将所有元素放入数组中。

如果你想让堆栈不受干扰,这对我来说并不是很明显,所以这里有两种方法:

%!
count        % Count elements on stack - stack contains <elements...> n
array        % Create array of that size - stack contains <elements...> []
astore       % Move all elements from stack to array - stack contains [<elements...>]

现在,如果您想让堆栈不受干扰:

%!
count        % Count elements on stack - stack contains <elements...> n
array        % Create array of that size - stack contains <elements...> []
astore       % Move all elements from stack to array - stack contains [<elements...>]
aload        % Push elements from array to stack - stack contains <elements...> [<elements...>]

推荐阅读