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 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<TITLE>hsc - Features - Macros - Attribute Declaration</TITLE>
<LINK REV="owns" TITLE="Thomas Aglassinger" HREF="mailto:agi@giga.or.at">
<LINK REL="Next" HREF="../features/if.html">
<LINK REL="Copyright" HREF="../copy.html">
<LINK REL="Previous" HREF="flag.html">
<META name="ROBOTS" content="NOINDEX, NOFOLLOW">
</HEAD>
<BODY>
<A HREF="../index.html"><IMG SRC="../image/main.gif" ALT="Contents" ALIGN="middle" WIDTH="70" HEIGHT="16"></A>
<IMG SRC="../image/noindex.gif" ALT="-----" ALIGN="middle" WIDTH="70" HEIGHT="16">
<A HREF="../copy.html"><IMG SRC="../image/copy.gif" ALT="Copyright" ALIGN="middle" WIDTH="70" HEIGHT="16"></A>
<A HREF="../index.html"><IMG SRC="../image/back.gif" ALT="Up" ALIGN="middle" WIDTH="70" HEIGHT="16"></A>
<A HREF="flag.html"><IMG SRC="../image/prev.gif" ALT="Previous" ALIGN="middle" WIDTH="70" HEIGHT="16"></A>
<A HREF="../features/if.html"><IMG SRC="../image/next.gif" ALT="Next" ALIGN="middle" WIDTH="70" HEIGHT="16"></A>
<HR>
<H1>Attribute Declaration</H1>
<P>Attributes are comparable to function arguments in programming languages
like Pascal, Oberon or E. So attributes are arguments passed to a tag or
macro.</P>
<P>Additionally, you can create/update attributes using <A HREF="../features/spctags.html#define"><CODE><$define></CODE></A>
and <A HREF="../features/spctags.html#let"><CODE><$let></CODE></A> therefor using them like variables.</P>
<H2>General Syntax</H2>
Within <A HREF="macros.html"><CODE><$macro></CODE></A>, <A HREF="../features/spctags.html#define"><CODE><$define></CODE></A> and <A HREF="../features/prefs.html#deftag"><CODE><$deftag></CODE></A>,
an attribute is declared using
<BLOCKQUOTE>
<I>name</I> ":" <I>type</I> [ "/" <I>modifiers</I> ] [ "=" <I>default value</I> ]
</BLOCKQUOTE>
<H2><A NAME="type">Attribute Types</A></H2>
<DL>
<DT><CODE>STRING</CODE>
<DD> any text
<DT><CODE>URI</CODE>
<DD> references to an URI. Is affected by CLI
options like <A HREF="../options.html#stripexternal"><KBD>STRIPEXTERNAL</KBD></A>.
<DT><CODE>BOOL</CODE>
<DD> boolean flag
<DT><CODE>ENUM</CODE>
<DD> enumerator type; accepts only given values (eg the
<CODE>ALIGN</CODE>
attribute of <CODE><IMG></CODE>).
<DT><CODE>ID</CODE>
<DD> id for current position in document; can be refered
with <CODE><A HREF="#id"></CODE>
<DT><CODE>NUM</CODE>
<DD> decimal integer value
<DT><CODE>COLOR</CODE>
<DD> a color-value matching the template <CODE>"#rrggbb"</CODE>
or one of the values defined using
<A HREF="../features/spcattr.html#colornames"><CODE>HSC.COLOR-NAMES</CODE></A>.
</DL>
<H2><A NAME="modifier">Attribute Modifiers</A></H2>
<DL>
<DT><CODE>/CONST</CODE>
(short: <CODE>/C</CODE>)
<DD>
Attribute is read-only; you can't set a new value using <A HREF="../features/spctags.html#let"><CODE><$let></CODE></A>.
This option is only allowed within <A HREF="../features/spctags.html#define"><CODE><$define></CODE></A>
<DT><CODE>/GLOBAL</CODE>
(short: <CODE>/G</CODE>)
<DD>
Attribute is global. Useful if you want to define an attribute inside
a macro, that is not removed after macro has been processed.
This option is only allowed within <A HREF="../features/spctags.html#define"><CODE><$define></CODE></A>.
<DT><CODE>/JERK</CODE>
(short: <CODE>/J</CODE>)
<DD>
Attribute is only used by a <A HREF="../questions.html#jerk">jerk</A>.
</DL>
Within <A HREF="macros.html"><CODE><$macro></CODE></A> and <A HREF="../features/prefs.html#deftag"><CODE><$deftag></CODE></A>, URIs also can have the following options:
<DL>
<DT><CODE>/REQUIRED</CODE>
(short: <CODE>/R</CODE>)
<DD>
Attribute must be set with a value when macro/tag is called.
<DT><CODE>/SIZE</CODE>
(short: <CODE>/Z</CODE>)
<DD>
If the attribute references to a local file, try to evaluate
the "size" of the file, search for attributes called
<CODE>WIDTH</CODE> and <CODE>HEIGHT</CODE> within the same tag
and set them with these values (if they have not been set before).
At they moment, only tags like <CODE><IMG></CODE> support this.
<DT><CODE>/STRIPEXT</CODE>
(short: <CODE>/X</CODE>)
<DD>
Strip whole tag, if the attribute references to an external URI
and option <A HREF="../options.html#stripexternal"><KBD>STRIPEXTERNAL</KBD></A> has been enabled.
</DL>
<H2>Default Value</H2>
<P>The default value initialises the attribute every time the
macro is called. If the attribute is not set within the macro call, the
default value is used. Otherwise, the value passed to the macro
will be used as new value.</P>
<H2>Examples</H2>
<DL>
<DT><CODE>DO-IT:bool</CODE>
<DD>
defines a boolean attribute
<DT><CODE>UP:uri=":main.html"</CODE>
<DD>
defines an URI attribute and sets it's default value to "<CODE>:main.html</CODE>".
The ":" indicates that the default value is a <A HREF="../features/uris.html#prjrel">Project Relative URI</A>.
<DT><CODE>MODE:enum("ascii|bin|hex")</CODE>
<DD>
defines an enumerator type; allowed values are <CODE>ascii</CODE>,
<CODE>bin</CODE> and <CODE>hex</CODE>.
</DL>
</BODY></HTML>
|