HTDB : Docs : Designer's Guide : The Scripting Language
About
Overview
Philosophy
Features
News
Download
Help Us!

Docs
Overview
Designers
Language
Environment
C-Functions
S-Functions
Developers
Roadmap
Architecture

Community
Powered By

[home]
An initial cut at describing the logic control capabilities of the HTDB scripting language.

The HTDB scripting language is purposefully quite simple, but extensible. The following constructs make up the entirety of the language:

  • define
  • include
  • if/elseif/else/endif
  • while
  • loop

define

htdb resource documents are composed of one of more blocks of script called resources. such blocks are initiated when #define is found, and terminate at the occurence of another define, or the end of the file.

comment lines are those which have the # character in the leftmost column. comments may be interspersed within a resource block.

example:

#define pageTitle this is a test page #define pageColor #cfcfcf

# # this is a comment # #define index.html <html> <head><title>${pageTitle}</title></head> <body bgcolor=${pageColor}> hello world


include

a great strength of the HTDB system is the flexibility of the designer to templatize layouts and/or include elements across many documents. the #include directive is used to "suck-in" resource common definitions to make them available to a document.

example:

#include macros

#define index.html ${somethingDefinedInTheMacrosResourceFile}


if/elseif/else/endif

example using the environment variable _current_month:

#live if (getval(_current_month) == Jan) the month is January #live else if (getval(_current_month) == Feb) the month is February #live else the month is ${_current_month} #live endif

yields:

the month is June

example using the function function random():

#live if (random(10) > 8) BIG #live else if (random(10) > 4) MEDIUM #live else SMALL #live endif

yields:

BIG

loop

example:

#live loop(i, 1, 10) ${i}<br> #live endloop

yields:

1 2 3 4 5 6 7 8 9 10

example using loop and functions:

#live loop(i, 6, 12) ${num2month(${i})}<br> #live endloop

yields:

June July August September October November December

example using loop and functions as loop limits:

#live loop(i, 1, ${random(12)}) ${num2month(${i})}<br> #live endloop

yields:

January February

while

${define(randImage_1,154)} ${define(randImage_2,60)} ${define(randImage_3,66)} ${define(randImage_4,56)} ${define(randImage_5,125)}

#live while (t = randImage_*) randImage_${t}: <img src="/images/random/_${randImage_${t}}.jpg" width="75" height="75"> #live endwhile

yields:

randImage_1: randImage_2: randImage_3: randImage_4: randImage_5:

alternate implementation using looping and random:

${define(loopStart, 1)} ${define(loopEnd, 5)}

#live loop (i, ${loopStart}, ${loopEnd}) randImage_${i}: <img src="/images/random/_${random(200)}.jpg" width="75" height="75"> #live endloop

yields:

randImage_1: randImage_2: randImage_3: randImage_4: randImage_5:

   
10,625 impressions