Changes

Jump to navigation Jump to search
m
add missing period punctuation
| '''Top:''' [[System Macros]]| '''Next:''' [[System Macros/Mnemonics and Aliases|Mnemonics & Aliases]] >
=== The ConTeXt version ===
<code>\contextversion</code> contains the Even though ConTeXt version string. If you need to make sure you does not have a rigid versioning interface, there are running under ConTeXt, check for this macro. It is not defined in [[source:syst-gen.tex| syst-gen.tex]] but in [[source:context.tex| context.tex]]. This is because [[source:syst-gen.tex| syst-gen.tex]] is sometimes loaded under Latexa few macros that deal with versions.
<code>\contextversion</code> contains the ConTeXt version string. If you need to make sure you are running under ConTeXt, check for this macro. This macro is not defined in [[source:syst-gen.tex| syst-gen.tex]], but in [[source:context.tex| context.tex]], because [[source:syst-gen.tex| syst-gen.tex]] is sometimes loaded under LaTeX, and it would be bad to define <code>\contextversion</code> in that case. The expansion of the macro <context code="yes" text="is something like this:">\contextversion</context>  <code>\fmtname</code> is defined at the same time, and it always expands to <context code="yes" text="this:">\fmtname</context>  <code>\contextformat</code> is also defined at the same time, and it contains the name of the current format. The expansion of the macro <context code="yes" text="is something like this:">\contextformat</context>  <code>\contextmark</code> is also defined in [[source:context.tex| context.tex]], and it contains the ConTeXt major release marker. You can read more on this internal versioning marker in [[manual:mk.pdf| ConTeXt, mkii & mkiv]]. The expansion of the macro <context code="yes" text="is something like this:">\contextmark</context>  <code>\contextversionnumber</code> is defined in [[source:mult-ini.tex| mult-ini.tex]], by interpreting <code>\contextversion</code> and attaching the <code>\contextmark</code>. The expansion of the macro <contextcode="yes" text="is something like this:">\contextversionnumber</context>  <code>\newcontextversion</code> is the last macro in this section. It is set in [[source:cont-new.tex| cont-new.tex]], the file that is read in at runtime. This macro is a security measure: its content is compared with the value of <code>\contextversion</code> that was stored in the format file, and if the two do not match up, the job is aborted.
=== Conditional execution of engine-specific code ===
There are In [[source:syst-prm.tex| syst-prm.tex]], a few macrosthat macros are defined that can be used to delimit code that is executed conditionallyuses engine-specific features. <code>\beginTEX</code> and <code>\beginETEX</code> are mutually exclusive, depending on whether or not the format file was compiled under an e-TeX-enabled executable. In the latest ConTeXt releases, this will always imply using the <code>\beginETEX</code> code, because e-TeX availability has recently become a requirement for ConTeXt. The macros will stay, however, because bits and pieces of ConTeXt are used in formats like [[LaTeX]] and [[MPtoPDF]], that are not necesarily e-TeX. A typical way of setting up your code to use e-TeX where available is like this:
<texcode>
</texcode>
Code delimited by <code>\beginOMEGA ... \endOMEGA</code> is only executed if ConTeXt runs under Omega, and ignored otherwise.
The Code delimited by <code>\beginOMEGA ... \endOMEGA</code> is only executed if ConTeXt runs under [[Aleph]].  Code within <code>\beginXETEX ... \endXETEX</code> is only run when [[XeTeX]] is used.  Experimental code for [[LuaTeX]] can be put between <code>\beginMETATEX ... \endMETATEX</code>.  An optional argument after the <code>\begin...</code> can be used to give some more information to the viewer: the example above will print the following string to the terminal:
<texcode>
=== Guard against double-loading of input files ===
Because modules Sometimes, macro or layout definition files can be used in from within various contextsinside a single typesetting run. If that is the case, we want it can come in handy to be able to prevent macro files from being loaded more than once. This can be done using:
<texcode>
where <code>\command</code> is a command defined in the module to be loaded only once.
For example, [[source:syst-gen.tex| syst-gen.tex]] implements <code>\writestatus</code>, and therefore it starts could start with:
<texcode>
</texcode>
Actually Normally, you don't need this macro for modulesat all, since <code>\usemodule</code> does it's own bookkeeping. It is purely intended for files that are loaded via the TeX primitive <code>\input</code>.<code>\usemodule</code> does its own bookkeeping, and combining it with <code>\usetypescriptfile</code> is generally not a good idea.
=== Protecting internal macros ===
We can shield macros from users by using some special characters in their names. Some characters that TeX normally does not consider to be letters (and are therefore usedfor this purpose) are: <code>@</code>, <code>!</code> and <code>?</code>. Before and after the definition of protected macros, we have to change the <''catcode''> of these characters. This is done by <code>\unprotect</code> and <code>\protect</code>, for instance:
<texcode>
The newly defined command <code>\!test</code> can of course only be called upon when we are in the <code>\unprotect</code>'ed state, otherwise TeX reads the command <code>\!</code>, followed by the word <code>test</code> and probably complains loudly about not being in math mode.
General purpose low-level commands in the ConTeXt core sometimes contain one or more <code>@</code> signs.  Temporary values and definitions often start with two <code>!</code> markers, and macros that represent internal strings normally start with a single letter followed by a single exclamation mark, for example: <code>\v!off</code> stands for the meaning of ''off'' in the current interface language. More on this convention can be read in [[System Macros/Scratch Variables]].  Prefixes for parameter list assignments start with two <code>?</code> markers, like <code>\??ly</code>. This is explained in [[System Macros/Key Value Assignments]]. The protection/and unprotection commands can be nested (unlike <code>\makeatletter</code> in LaTeX). This nesting ability is a convenience, since it allows one to use the protection pair regardless of whether protection is already turned on.It is a very good habit to always start your macro files with <code>\unprotect</code> and end them with <code>\protect</code>, even if you don't need to access internal commands right away.   
When the nesting becomes deeper than one level, the system reports the current protection level.| '''Top:''' [[System Macros]] | '''Next:''' [[System Macros/Mnemonics and Aliases|Mnemonics & Aliases]] >
It is a good habit to always start your macro files with <code>\unprotect</code> [[Category:Programming and end them with <code>\protect</code>.Databases]][[Category:Tools]]
1

edit

Navigation menu