[NTG-context] Dirty trick / clean solution

Hans Hagen pragma at wxs.nl
Thu Mar 23 12:04:35 CET 2006


Antoine Junod wrote:
> Hello list,
>
> I've got a piece of code that is absolutely
> aful. Unfortunately (sic) it makes what I want.
>
> \defineparagraphs[p][n=2,before={},after={}]
> \setupparagraphs[p][1][width=.2\textwidth,style=bold]
>
> \definetyping
>   [code]
> \setuptyping
>   [code]
>   [margin=.23\textwidth,before={},after={\vskip-10pt}]
>
> \startp Operation: \p AuctionClient::providePersData($p$:
> Person)\stopp
> \startp Description: \p Fournit les données personnelles
> nécessaires à la création d'un compte, encapsulées dans un
> objet $p$.\stopp
> \startp Messages: \p{\tt auctionServer\^{}createAccount(p:
> Person);}\stopp\startcode
> sender^message(msg: String);
> sender^requestPersData()
> \stopcode
> \startp Pre: \p {\tt true}\stopp
> \startp Post: \p{\tt  if
> (self.checkPersData(p))}\stopp\startcode
> then
>   self.auctionServer.createAccount(p) and
>   not(sender.message('Malformed personal data')) and
>   not(sender.requestPersData())
> else
>   not(auctionServer^createAccount(p)) and
>   sender^message('Malformed personal data') and
>   sender^requestPersData()
> endif
> \stopcode
> \blank
>
> How could I improve that? I've tried a lot of different
> things but the main problem is that i can't type in verbatim
> mode because i'm in reduced horizontal mode.
>
> Thanks a lot for you help
> -AJ
>   
\starttext

\definedescription[procedure]  [width=10em]
\definedescription[operation]  [procedure]
\definedescription[description][procedure]
\definedescription[post]       [procedure]

\setupdescriptions[operation]  [title=no,text=Operation]
\setupdescriptions[description][title=no,text=Description]
\setupdescriptions[post]       [title=no,text=Post]

\definetyping[code][before=\vskip-\lineheight,after=]

\startoperation
AuctionClient::providePersData($p$: Person)
\stopoperation

\startdescription
Fournit les données personnelles
nécessaires à la création d'un compte, encapsulées dans un
objet $p$.
\stopdescription

\startpost
\startcode
if (self.checkPersData(p)) then
  self.auctionServer.createAccount(p) and
  not(sender.message('Malformed personal data')) and
  not(sender.requestPersData())
else
  not(auctionServer^createAccount(p)) and
  sender^message('Malformed personal data') and
  sender^requestPersData()
endif
\stopcode
\stoppost

\stoptext

please wikify this

(i'll make the title keyword inheritable)

Hans

-- 

-----------------------------------------------------------------
                                          Hans Hagen | PRAGMA ADE
              Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
     tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com
                                             | www.pragma-pod.nl
-----------------------------------------------------------------



More information about the ntg-context mailing list