aboutsummaryrefslogtreecommitdiff
path: root/src/hyper/pages/HTXAdvPage3.ht
blob: 9db9209c4c08dcb43befc1b5ccc0aef9321d18e9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
\begin{page}{HTXAdvPage3}{Macros}
\centerline{\fbox{{\tt \thispage}}}\newline
\begin{scroll}


Sometimes you may find yourself having to
write
almost the same piece of \HyperName{}
text many times. Thankfully, there is a command to ease
the work.
It is the {\tt \\newcommand} command and provides
a macro facility for \HyperName{}.
In this way, you can give a short name to a sequence of \HyperName{}
text and use that name to include the sequence in your pages.
The way this works is the following
\beginImportant
\newline
\centerline{{\tt \\newcommand\{\\{\it name}\}[{\it number of arguments}]\{{\it \HyperName{} text}\}}}
\endImportant
and here is an example from {\bf util.ht}
\beginImportant
\newline
{\tt \\newcommand\{\\axiomSig\}[2]\{\\axiomType\{\#1\} \{\\tt ->\} \\axiomType\{\#2\}\}}
\newline
{\tt \\newcommand\{\\axiomType\}[1]\{\\lispdownlink\{\#1\}\{(|spadType| '|\#1|)\}\}}
\endImportant

You see that a macro's definition can invoke another.
Don't create a circular definition though!
Notice how the arguments of the macro are used
in the definition. The {\tt \#{\it n}} construct
is the place--holder of the {\it n}'th argument.

To use the macro, just treat it as an ordinary command.
For instance
\beginImportant
\newline
{\tt \\axiomSig\{Integer\}\{List Integer\}}
\endImportant
displays and acts like this
\beginImportant
\newline
\axiomSig{Integer}{List Integer}
\endImportant

The best way to familiarise yourself to
macros is to study the macros defined in
\centerline{
{\bf \env{AXIOM}/doc/hypertex/pages/util.ht}
}
It is highly probable that a good many of them
will prove useful to you.
Clever use of macros will allow you to
create \HyperName{} text that can be
formatted by other programs (such as TeX).
The \Language{} User Guide was written
in such a way as to make translation in
\HyperName{} form and TeX form a mechanical process.




\end{scroll}
\beginmenu
\menulink{Next Page --- Patch and Paste}{HTXAdvPage4}
\endmenu

\end{page}