PostScript 字符串转换失败 - 无法捕获/类型检查错误
我想检查函数中最上面参数的类型,如果它的类型是字符串,则将其转换为 int。如果字符串包含字母,我会收到 /typecheck 错误。我的代码是:
/doConvert {
dup type /stringtype eq { cvi } if
...
} def
现在我可以将值保存在变量中并执行类似的操作:
/a exch def a type /stringtype eq { {a cvi} stopped {pop 0} if} if
在不使用变量的情况下可以获得相同的结果吗?我尝试过使用 cvx 和 exec 但我总是收到 /typecheck 错误,因为我没有在大括号中进行类型转换。
I want to check the type of the top most parameter in my function and convert it to int if it's type is string. If the string contains letters I get a /typecheck error. My code is:
/doConvert {
dup type /stringtype eq { cvi } if
...
} def
Now I can save the value in a variable and do something like this:
/a exch def a type /stringtype eq { {a cvi} stopped {pop 0} if} if
Can I get the same result without using variables? I have tried using cvx and exec but I always get the /typecheck error because I do not have the type conversion in curly brackets.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论