Aspen SCM‎ > ‎Expert System‎ > ‎1. Elements‎ > ‎

1.6 Statements

Structure of Statements

Aspen SCM Expert System code is written in a mixture of structured and free format. The structural keywords IF, THEN and NOTE are only recognised in the Code section of a rule. AND and OR can appear in either the Code or the Description while opening and closing brackets and in-line comment markers are recognised only in the Description

The structural keywords act as delimiters in separating statements from one another. Structural keywords in the Code have a stronger meaning than the identical keyword in the Description. Only one structural keyword is permitted in the Code section of any line (except that a NOTE may precede another keyword, which is then treated as a comment, along with the rest of the line)

The contents of the Description are free format (within the maximum length of any line of the Description) and may extend over many lines. In effect the presence of a structural keyword in the Code represents the start of a paragraph, which continues until the next structural keyword in the Code.

Within such a “paragraph” the end of one line is followed immediately by the start of the next: no blank or other punctuation is inserted. This means that words do not need to be completed on one line but can be continued from mid-word on the next. Conversely, where a blank is required between two words, it must be inserted either at the end of one line or the start of the next. Beware of ending statements (except in-line comments) at character 64: the next line must start with a blank if your code is to work as you intend.

Statements Limited to 80 Characters and 10 Tokens

Statements are subject to various limits which result from the way that the contents of a paragraph of Description are processed. This can be thought of as follows. The contents of the Descriptions are concatenated together and scanned for structural keywords. Everything between two successive keywords is loaded into a buffer which is 80 characters long. It is then separated into a maximum of 10 tokens delimited by blanks (but with complications to handle quoted strings which may contain blanks).

As a result Aspen SCM Expert System statements are truncated to 80 characters and 10 tokens. Anything beyond the 80 characters or 10 tokens is simply ignored, without any message that this is happening. Some types of statement are processed further using string variables and these are then truncated to 79 characters. Usually such truncation will cause an overlong statement to fail and produce an error, but sometimes the statement will be valid code and will produce unexpected results.

Note that the count of characters towards the limit of 79 or 80 starts at the first non-blank of the statement and continues through the blanks at the end of one line and those at the start of the next. The limit cannot be circumvented by using in-line comments: these are not permitted within a statement as the start of an in-line comment is regarded as a structural keyword which ends the current statement.

Recommendations for Writing Statements

As the Description is itself 64 characters long, you should try to ensure that statements do not overflow a line. If a statement threatens to overflow a line, recast it by using local variables to hold elements which would otherwise occupy many characters, e.g. a table element or a character string. If absolutely necessary, move the structural keywords surrounding the statement to adjacent lines.

Another recommendation follows from the direct concatenation of the end of one line with the start of the next. This is that if the Code section of a line is blank, so also should be the first character of the Description. This will ensure that whatever appears in the Description will be recognised as beginning with a new word rather than with the continuation of the last word of the preceding line. Do not think that because you have left a blank at the end of the preceding line, it is safe to use the first column. It is not. Your successor may change the code and fill up the Description on the preceding line. This applies even (indeed especially) to closing brackets. Do not put a closing bracket in column 1 of the Description. Put it in column 2 (or beyond).

The limit of 10 tokens per statement is less onerous. All the Aspen SCM commands stay within this limit and only one arithmetic operation is permitted in a statement. As a result, the only statements which could possibly exceed this limit are predicates, which are restricted to a predicate verb and up to 9 predicate arguments (see section 1.7).


Back                                Next
Comments