Main ----- Copyright Up Previous Next

Expressions

Additionally to simple strings, you can use expressions to set the value of an attribute. Expressions must be enclosed inside "(" and ")". Inside expressions, you can refer to attributes simply by their name. String constants must be enclosed inside quotes.

Example:
    <$define image:string="hugo.gif">
    <IMG SRC=(image) ALT="image">

will be converted to

    <IMG SRC="hugo.gif" ALT="image">

Operators

Unary operators

not expression
negotiate (boolean) expression
set attribute
True, if attribute has been set during macro call
defined attribute
True, if attribute was defined with <$macro> or <$define>
exists(local uri)
True, if document at local URI exists (bool)
GetEnv(environment-variable)
get value of an environment variable
GetFileSize(uri)
get size of a specific file
GetGMTime()
get current Greenwich Mean time
GetTime()
get current local time

Binary operators

expression = expression
string comparison (case insensitive)
expression + expression
string concatenation
Example:
    <$define name:string="hugo">
    <$define here:string="here">

    <IMG SRC=(name+".gif") ALT=(name+" was "+here)>
    <$if (name="hugo")>
    This is hugo!
    <$else>
    Maybe it's sepp?
    </$if>
    AmigaOS version: <(GetEnv ("KickStart"))>

will be converted to

    <IMG SRC="hugo.gif" ALT="hugo was here">
    This is hugo!
    AmigaOS version: 40.63

At least on my machine.

Boolean expressions

If you pass an expression to a boolean attribute, the expression is evaluated as before. If the expression returned an empty string, the boolean attribute is interpreted as false. This will cause the attribute to be removed from the tag/macro-call.

Any none-empty string will set the attribute to true, resulting in a value equal to the name of attribute. (In html, writing ISMAP is short for ISMAP="ISMAP".)

Example:
    <IMG SRC=(name) ALT="nufin" ISMAP=(name="map.gif")>

will be converted to

    <IMG SRC="hugo.gif" ALT="nufin">

if name has been set to "hugo.gif", or to

    <IMG SRC="map.gif" ALT="nufin" ISMAP>

if name has been set to "map.gif". Note that only the second call enables the boolean attribute ISMAP, while it gets stripped for the first call.

Priorities

Important: Different to most programming languages, hsc does not support priorities for different operators. Therefor, expressions are simply processed sequentialy (I'm too lazy to build a tree).

But you can use nested brakets within complex expressions.


Thomas Aglassinger (agi@giga.or.at), 04-Dec-1996