Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.
\documentclass[pstricks,border=12pt]{standalone}
\usepackage{pstricks-add}

\begin{document}

\begin{pspicture}[showgrid=bottom](4,2)
\pstVerb
{
    /a 2 def
    /bb 1 def
}%
\rput(!a bb){First Page}
\end{pspicture}

\end{document}

My a silently overrides the PSTricks' definition. I need a way to know this silent substitution. Is there a way to know name clashes in PostScript level between ones used in PSTricks packages and our own definitions?

share|improve this question

2 Answers 2

up vote 8 down vote accepted
+500

I suppose the correct thing to do is always make your local definitions in a private dictionary to avoid the problem but this postscript addresses the question as asked:

The sequence

 dup where {pop == (already defined) ==} {3 def} ifelse

will define the preceding token to 3 if it is not defined, and leave it untouched and echo a warning if it is defined.

tested with /a defined to be 2 and /b undefined

GS>/a 2 def
GS>/a dup where {pop == (already defined) ==} {3 def} ifelse
/a
(already defined)
GS>a ==
2
GS>/b dup where {pop == (already defined) ==} {3 def} ifelse
GS> b ==
3

a gets left as 2 but b is defined to be 3.

share|improve this answer
    
Note in the other answer Herbert shows what I noted above is the "correct thing to do" :-) –  David Carlisle Sep 6 '12 at 13:26
\documentclass{article}
\usepackage{pstricks}\SpecialCoor
\begin{document}

\begin{pspicture}[showgrid=bottom](4,2)
\pstVerb
{  userdict begin
    /a 2 def
    /bb 1 def
  end }
\rput(! userdict begin a bb end){First Page}
\end{pspicture}

\end{document}
share|improve this answer
    
I used this in my project but I accepted David solution because it conforms to the question. –  In PSTricks we trust Sep 6 '12 at 13:32
    
Is there a method to avoid repeating userdict begin ... end in each points? –  In PSTricks we trust Sep 6 '12 at 13:53

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.