Global variables

Roger Price rprice at
Thu Apr 27 18:13:08 CEST 2000

Dear List, I use teTeX (tetex-0.4pl8-11.src.rpm).

I am trying to define a LaTeX class in which two environments A and B
communicate via global variables (booleans).  I wish to check that the
environments are being used in the correct order.  In the main code
section of the class file (see the LaTeX Companion p.468) I declare
three booleans:

\newboolean{P at rt0}
\setboolean{P at rt0}{true}     % Initial value = true
\newboolean{P at rt1}           % Initial value = false
\newboolean{P at rt2}           % Initial value = false

and a command which will check that A and B are in the correct order.
The first argument is the number of the previous part, the second is
the number of the current part.

\newcommand{\CheckOrder}[2]{\ifthenelse{\boolean{P at rt#1}}
  {\setboolean{P at rt#2}{true}
   \typeout{Correct order.}
  {\setboolean{P at rt#2}{true}
   \typeout{Incorrect order.}

The environment declarations are 

The document instance contains the environments in the correct order:


xdvi shows the correct "Hello World", but the console output is:

Correct order.
Incorrect order.

Why can't environments A and B communicate with each other?
Is this because P at rt0, P at rt1 and P at rt2 are not global variables?
How does one create global variables in LaTeX?

My apologies if this is a FAQ. Any help would be much appreciated.
rprice at 

More information about the texhax mailing list