HistoryCal - Manual
Script Language
Home Manual Script

Section Under Construction

Introduction

The HistoryCal program has a built-in script language called HistoryCal Script. This is different from the input that has been described at the beginning of this manual, which is called a HistoryCal Date Expression. The Date Expression is similar to the script but is simplified and designed for easier input. The Date Expression is converted into a HistoryCal Script to be evaluated.

The script is designed to serve two main purposes.

The scripts for the default calendar definitions are shown in the calendar definitions section.

Hello World

A script consists of one or more statements. As is obligatory in these circumstances, we present a hello world script.

Hello Script
// Hello world script. writeln "Hello world!";
Screen Print 1

Using a text editor, copy the script and save as "hello.hcs". Run the HistoryCal Script by starting the HistoryCal program. Under the menu option "File > Run Script ..." find the file and select it. This should then result in the message shown.

Comments and White Space

The first line in the above script is a single line comment. Every thing from the "//" token to the end of the line taken to be a comment.

Multi-line comments can be included by placing them between the "/*" and "*/" tokens. Multi-line comments cannot be nested.

// A single line comment /* This is a multi-line comment. */

Tabs, spaces, newlines and comments can appear anywhere within a script without affecting its meaning. They are required only when necessary to separate tokens.

Expressions and Variables

Values in the HistoryCal Script can exist as one of a number of types:-

Variables are defined by using the let statement, but their type is determined by their context. There are a number of operators which are used in expressions and the values in these expressions are automatically converted, wherever possible.

Statements

A script consists of one or more of the following Statements:-

Statement List
StatementUseExample
clearDelete all variables.clear;
doRun script until a condition is met.do while y <= 2015 writeln "1 Jan " + y; y += 1; loop
endStop running the script.end;
formatDefine a Format for a grammarformat j:ydm, "(Year)| (Day)| (Month:m)";
grammarDefine a Grammar for a calendar.grammar J { inherit j; format ydm, "(Year)| (Day)| (Month:m)"; }
ifRun code depending on condition.if value = today write "<b>" + str value + "</b>"; else write str value; endif
letInitialise or change a variable.let d = 1;
markSet a named mark in the script.mark "test1";
schemeDefine a calendar Scheme.scheme j { name "Julian"; base julian; }
setSet a global default setting.set output g:iso;
vocabDefine a Vocabulary for a calendar field.vocab ce { name "Historic Era"; tokens { 0, "Before Christ", "BC"; 1, "anno Domini", "AD"; } }
writeCreate output.write value + ", ";
writelnCreate output, followed by a new line.writeln "Today is " + str today;
Home Manual Script

Managed by WebPageLayout Validated by HTML Validator (based on Tidy)

10th March 2014