Introduction |   |
The HareScript language is the core language of the WebHare Application Portal, and is used to implement the graphical web interface and to build many other components in this system. It is a fourth-generation scripting language that integrates support for SQL statements directly into an imperative language.
This article contains some HareScript code snippets to illustrate the approaches taken by the language. Although the code will look very familiar if you've already seen SQL before, there is one important difference with respect to column renaming and selecting expressions into columns. The usual syntax in SQL for this is to use '<expression> AS <columnname>' inside a SELECT. Although HareScript does support this syntax, most HareScript code uses a different syntax: '<columnname> := <expression>'. We feel that this syntax improves readability, especially when a lot of columns are renamed.
As an example, the following HareScript SQL code:
SELECT files.id
, files.description AS filedescription
, (files.title = "" ? files.name : files.title) AS filetitle
FROM files; |
Is functionally equivalent to:
SELECT id
, filedescription := files.description
, filetitle := files.title = "" ? files.name : files.title
FROM files; |
As mentioned, HareScript accepts both syntaxes, and neither of the possible syntaxes is faster or more efficient than the other. Our preferred syntax only serves to improve readability - the AS syntax is provided for compatibility with SQL.
|
Sections in this chapter
|
 |
|