Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.postscript > #1226

Re: save restore problem - is it possible to use it in this way?

From John Deubert <john@acumentraining.com>
Organization Acumen Training
Newsgroups comp.lang.postscript
Date 2013-01-07 06:38 -0800
Message-ID <2013010706381659521-john@acumentrainingcom> (permalink)
References <7f92a7b6-e0fa-4481-b50a-9ba3aa56be07@googlegroups.com> <0e0e2def-ead5-467b-8ce9-3729ed1cd0ad@googlegroups.com>
Subject Re: save restore problem - is it possible to use it in this way?

Show all headers | View raw


On 2013-01-04 18:10:00 +0000, luser- -droog said:

> On Friday, January 4, 2013 10:39:09 AM UTC-6, wojt...@gmail.com wrote:
> 
>> Should it be ok too?
>> 
>> If yes then probably there is something wrong with the stack between 
>> save and restore and restore have wrong data on the stack? How to check 
>> it? PS file has more than 1k lines :/
> 
> If you can't trust the stack, trust the dictionary.
> 
> /saveobjectA save def
> 
> /saveobjectB save def
> 
> saveobjectB restore
> 
> saveobjectA restore

I'd go a step further and say you should absolutely not use the operand 
stack to store the save objects created by save and used by restore; 
too much opportunity for things to go wrong. It is much better to put 
the objects into a key-value pair, as droog says above.

If you absolutely must leave the saveobject on the stack (perhaps 
because you're working with existing code written by someone else), 
then you can test the top of the stack before executing restore:

dup type /savetype
{ restore }{ ... handle or head off typecheck error here ... } ifelse

- John

-- 
========
John Deubert
Acumen Training
PostScript & PDF Engineering Classes & Consulting
www.acumentraining.com

Learn PostScript programming techniques
Read the free Acumen Journal
acumentraining.com/acumenjournal.html

Back to comp.lang.postscript | Previous | Next — Previous in thread | Find similar | Unroll thread


Thread

save restore problem - is it possible to use it in this way? wojtulek@gmail.com - 2013-01-04 08:39 -0800
  Re: save restore problem - is it possible to use it in this way? ken <ken@spamcop.net> - 2013-01-04 16:40 +0000
  Re: save restore problem - is it possible to use it in this way? luser- -droog <mijoryx@yahoo.com> - 2013-01-04 10:10 -0800
    Re: save restore problem - is it possible to use it in this way? John Deubert <john@acumentraining.com> - 2013-01-07 06:38 -0800

csiph-web