extension needed to compile doc-poly.tex

Denis Girou Denis.Girou at idris.fr
Wed Mar 11 12:20:50 CET 1998


-----------------------------------------------------------------------------
This is the PSTricks mailing list, devoted to discussions about computational
graphics in (La)TeX using the PSTricks package from Timothy van Zandt.
For help using this mailing list, see instructions at the end of message.
-----------------------------------------------------------------------------

>>>>> "Maurice.Diamantini" == Maurice DIAMANTINI <diam at ensta.fr> writes:

    Maurice.Diamantini> It is also a good exemple to show how to create 
    Maurice.Diamantini> vew hight level macro.

  If you just want to see how to define new PSTricks macros with optional
parameters, using the `keyval' (+ `pst-key') packages, I can give you this
basic example that I used when I write my own interface to `keyval' and later
to test `pst-key'.

  It produce no output result. It interest is only to compile it, to look at
the messages and to understand the code.

D.G.

test-obj.tex
------------

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -*- Mode: Latex -*- %%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% test-obj.tex --- Test file for the `pst-obj' object demonstration package
%% 
%% Author          : Denis GIROU (CNRS/IDRIS - France) <Denis.Girou at idris.fr>
%% Created the     : Tue Apr 29 18:51:58 1997
%% Last mod. by    : Denis GIROU (CNRS/IDRIS - France) <Denis.Girou at idris.fr>
%% Last mod. the   : Wed Mar 11 12:29:17 1998
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\documentclass{article}

\usepackage{pst-obj}

\begin{document}

\typeout{^^JEnter return when you get an error message.^^J}

\PstObject

\PstObject[Real=35.75]

\PstObject[Integer=20,Undefined=12]

\psset{linecolor=red}
\PstObject[Boolean=true,Integer=150]

\psset{Boolean=true,Integer=66}
\PstObject

\PstObject[linecolor=green,Real=11.11]

\PstObject

\end{document}


pst-obj.sty
-----------

\ProvidesPackage{pst-obj}[1997/04/29: package wrapper for PSTricks pst-obj.tex]
\input pst-obj.tex
\endinput


pst-obj.tex
-----------

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -*- Mode: Latex -*- %%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% pst-obj.tex --- Demonstration of how to define high level PSTricks object
%%
%% Author          : Denis GIROU (CNRS/IDRIS - France) <Denis.Girou at idris.fr>
%% Created the     : Tue Apr 29 18:37:05 1997
%% Last mod. by    : Denis GIROU (CNRS/IDRIS - France) <Denis.Girou at idris.fr>
%% Last mod. the   : Wed Mar 11 12:27:43 1998
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\def\fileversion{0.3}
\def\filedate{98/03/11}

\message{`Pst-Object v\fileversion, \filedate\space (Denis Girou)}

\csname PstObjectLoaded\endcsname
\let\PstObjectLoaded\endinput

% Require of course the PSTricks package
\ifx\PSTricksLoaded\endinput\else\input{pstricks.tex}\fi

% DPC interface to the `keyval' package (until keyval based version of PSTricks)
\input pst-key.tex

\edef\PstAtCode{\the\catcode`\@}
\catcode`\@=11\relax

% Definition of the parameters
% ----------------------------

% A parameter containing an integer value
\define at key{psset}{Integer}{%
\pst at cntg=#1\relax
\edef\psk at Integer{\the\pst at cntg}}

% A parameter containing a real value
\newdimen\psl at Real
\define at key{psset}{Real}{\pssetlength\psl at Real{#1}}

% A parameter containing a boolean value
\newif\ifPst at Boolean
\define at key{psset}{Boolean}[true]{\@nameuse{Pst at Boolean#1}}

% Defaults values:
% ---------------
\setkeys{psset}{Integer=10,Real=9999pt,Boolean=false}

% The macro \PstObject
% --------------------

\def\PstObject{%
\@ifnextchar[\@PstObject{\@PstObject[]}}

\def\@PstObject[#1]{{%
 \setkeys{psset}{#1}%
%
% Validation of the parameters
% ----------------------------
\ifnum\psk at Integer<1
{\@pstrickserr{Integer must be greater than 0
   (and not `\psk at Integer')}\@eha}%
\fi
\ifnum\psk at Integer>100
{\@pstrickserr{Integer must be less or equal to 100
   (and not `\psk at Integer')}\@eha}%
\fi
%
\typeout{Values of parameters:}
\typeout{--------------------}
%
\typeout{linecolor is `\pslinecolor'}
%
\typeout{Integer\space\space\space is `\psk at Integer'}
%
\typeout{Real\space\space\space\space\space\space is `\the\psl at Real'}
%
\ifPst at Boolean
  \typeout{Boolean\space\space\space is `true'^^J}
\else
  \typeout{Boolean\space\space\space is `false'^^J}
\fi
}}

\catcode`\@=\PstAtCode\relax
\endinput
%%
%% END: pst-obj.tex

-----------------------------------------------------------------------------
The list interface (subscription, information, access to the archives) is on:
http://www.tug.org/cgi-bin/lwgate/pstricks
Otherway to unsubscribe, send mail to pstricks-request at mail.tug.org
with a blank subject and in body the line unsubscribe <email-address>
-----------------------------------------------------------------------------



More information about the PSTricks mailing list