The Regnus Scripting Tutorial
Part 11: Automatic Grammar Characters
In a recent chapter, we looked at using hidden text brackets. This ability is actually part of a whole group of special characters in Regnus called "Automatic Grammar Functions", or "AG Functions" for short. These characters can be inserted into your text in order to affect in some way the characters near them. This chapter will document these characters and explain how to use them.
Pluralisation
A common requirement in a Regnus script is to be able to pluralise nouns without resorting to including both singular and plural versions of each word in separate groups. For example:
GROUP PluralisationExample
ENTRY <Example>My friend has just one ##Fruit;, but I have several ##Fruits;!
GROUP Fruit
ENTRY banana
ENTRY plum
ENTRY apple
GROUP Fruits
ENTRY bananas
ENTRY plums
ENTRY apples
As you can see, this would be an inefficient way to write a script! Luckily, there is an AG character to solve this problem. To us it, simply place a tilde character ("~") at the end of any word which you would like to be pluralised. For example:
GROUP PluralisationExample
ENTRY <Example>My friend just has one ##Fruit;, but I have several ##Fruit;~!
GROUP Fruit
ENTRY banana
ENTRY plum
ENTRY apple
You will find when you run this example that the result of the second reference is automatically pluralised.
The pluralisation function is fairly intelligent, and will correctly pluralise most words in the English language. However, there are of course certain exceptions which it will incorrectly pluralise, and there is a way to get around this: the "MULTI" qualifier. This simply allows you to define a noun, and its plural form. So, to use one example which the parser will have trouble with:
GROUP PluralisationExample
ENTRY <Example>I like ##Animal;~!
GROUP Animal
ENTRY cat
ENTRY sheep
MULTI sheep:sheep
If you run this script, you will see that the parser correctly pluralises "cat" to "cats", but if you remove the "MULTI" qualifier, it will try to correct "sheep" to "sheeps", which is of course incorrect.
Capitalisation
Another common requirement in Regnus scripts is to be able to capitalise letters of words. For example, you may want to start a sentence with a random word, but also use that entry in the middle of a sentence.
In these cases, you can use the circumflex accent character ("^") to convert the following letter to uppercase. So for instance:
GROUP CapitalExample
ENTRY <Example>I have a #>(0):Fruit;. ^##[0];~ are nice!
GROUP Fruit
ENTRY banana
ENTRY plum
ENTRY apple
Here, we have used both a pluralisation and a capitalisation character on the second reference, in order to convert (for instance) "banana" into "Bananas".
New Lines
One issue you may well have already encountered is that, as Regnus relies on all text from an entry remaining on the same line as its qualifier, you cannot include line breaks in your scripts.
Luckily, the vertical line character ("|") achieves just that!
GROUP Example
ENTRY <Example>This is line 1...|And this is line 2!|...And hey, this is line 3!
Escape Characters
As you may have noticed, Regnus relies on a lot of special characters to signify various things, which has the side-effect of precluding these characters being used in the text of your script. For instance, if you want to include a hash character in your text, the parser will return an error message because it expects a reference, and if you include any of the AG characters, they will be treated as such rather than displayed in the text output.
So, to get around this, you can use Regnus' escape character, the asterisk ("*"), to overstep parsing of characters which you want to use exactly as they are. For example:
GROUP Example
ENTRY <Example 1>This will cause an error: #
ENTRY <Example 2>...But this won't: *#
ENTRY <Example 3>And if you want to include an asterisk, just use two!: **
Note: you can also use the asterisk to escape the letter "a" if there is a single example in your script which you want to debar from article correction, regardless of what word follows it.