Taking too long? Close loading screen.

Prophet – Programming Language

Overview

The Prophet programming language is the programming language used to create and maintain formula definitions for variables in each product and library. 

A formula in Prophet can be specified using either:

  • The standard Prophet language features or,
  • The Prophet Extended Formula features.

A formula created using the standard Prophet language generates values for one variable only. An extended formula however, can be used by many variables to calculate the values.

Standard Language Features

The standard Prophet programming language supports many of the features of a standard programming language. In particular it supports:

  • Standard arithmetic operators
  • Arithmetic and Boolean expressions
  • Arithmetic and logical functions
  • If Then Else expressions

The programming language is also supplemented by a number of Prophet specific functions that allow Prophet to:

  • Read the contents of tables and files
  • Inspect progress and control the processing of a Prophet run
  • Control the termination of a run and display appropriate error or warning messages.

A number of statistical, trigonometric and financial functions are also provided

Extended Formula Features

In addition to the standard programming language features Prophet extended formulas provide the following:

  • Conditional statements
  • If/Then/Else/EndIf statement, Switch / Case / Case Else / Endswitch
  • Looping statements
  • For/To/Step/Next, Do While/Loop, Do Loop/While, For Each / Next
  • Support for vector and array variables having up to 4 dimensions
  • Declaration of local and global variables
  • Declaration of local and global variables
    This is achieved using the Private and Public variable declarations
  • The retention of values
    These are values calculated between different model points and between runs of the same product within a
    dynamic or stochastic run

Language Rules

The general programming language rules that apply to both standard and extended formulas are:

  • Spaces or indentation in formulas are ignored. They are used solely to aid the readability of a formula.
  • All types of brackets are treated as being identical as long as they are matched. For example, Prophet accepts X[t] or X{t} and treats it as X(t). The supported bracket types are: (, {, [.
  • In general, you should use brackets to aid readability and to enforce the order of operators used in Prophet formula definitions.
  • All letters are treated as being upper case. Mixed case can however be used to enhance the readability of formula definitions.
  • Prophet ignores any text to the right of a semicolon and hence this allows comments to be included in formula definitions.

 

Programming language rules that apply only to standard formulas are:

  • Prophet supports time-dependent variables. It works out for itself during code generation whether a particular variable is time-dependent or not.

 

In addition to the general programming language rules that apply to both standard and extended formula definitions there are a number of rules that apply only to extended formulas:

  • An extended If/Then/Else statement is used which requires a closing EndIf statement at the end of an If/Then/Else statement. This differs from the If/Then/Else statement used in a standard formula which does not use a closing EndIf.
  • Variable assignments are made using the := syntax. l Variables, with the exception of normal Prophet variables included in the product, are declared either as Private, Public or Parameter.
  • A Private variable is a variable whose value can only be used within the current extended formula. It is stored locally and cannot be referenced by another variable outside of the current formula. It is usually used for intermediate calculations whose results do not need to be stored or passed on to other variables or for specifying the start and end points of a loop statement.
  • A Public variable is a variable whose value can be read by another variable.
  • A Parameter variable is a variable whose value will be specified when the extended formula is executed.

Programming Language Expressions

The Prophet programming language supports the following types of expressions:

  • Arithmetic Expressions

These are used in formula definitions

  • Logical Expressions

These are used in formula definitions and indicator expressions

  • If Then Else Statement

These are used in standard formula definitions

  • Switch / Case / Case Else / Endswitch Conditional Statement

This conditional statement is also used in an extended formula but with some differences.

Switch (<expression>)
Case <value>:<case clause>
Case <value +1>: <case clause>
......
Case <value +n>: <case clause>
Case Else: <case clause>]
EndSwitch

Where:

SWITCH (<expression>)
    The SWITCH expression is any expression that yields an integer, real or string value.

<case value>, <case value +1>...<case value +n>
    The case value must be a constant that can be a literal or a variable having a constant value.

<case clause>
    All case values used in the case clause must be compatible with the switch variable type. The clause can contain expressions when used in a normal Prophet formula, or statements when used in an extended formula.
    Valid combinations are specified by the following table. Invalid combinations are reported as errors.

Switch Variable Type Case Type Valid? Comparison Type
String String Valid String
String Integer Invalid  
String Real Invalid  
Real String Invalid  
Real Integer Valid Real
Real Real Valid Real
Integer String Invalid  
Integer Integer Valid Integer
Integer Real Invalid  
    • Usage in Normal and Extended Formulas

The SWITCH statement can be used in normal and extended formulas however there are differences as follows:

      • SWITCH Statement in a Prophet Formula

The SWITCH statement when used in a Prophet formula must return a value. Hence, each CASE statement in the SWITCH must evaluate to a valid expression. The return value of the SWITCH is then the evaluation of the expression of the selected CASE clause.

      • SWITCH Statement in an Extended Formula

In an extended formula the SWITCH statement does not return a value and so each CASE may contain multiple statements.

    • Switch Statement rules:
      • Only constant values are allowed in case statements
      • Duplicate values in case statements are not allowed
      • Nested SWITCH statements
      • CASE value evaluation order
  • For Each / Next Statement

This statement is also used in an extended formula but with a minor differences. It is used to repeat a group of statements for each element in an array of enumerations.

    • When an element contains the TYPE_QUIT enumeration then QUITLOOP is used to exit the loop.

Public My_Array(TYPE_ENUM) As Number
Private Type As TYPE_ENUM
For Each Type
    My_Array(Type) := 1
    If Type = TYPE_QUIT Then
        QUITLOOP
    EndIf
Next

Programming Language Operators

Type Symbol Purpose
Arithmetic ^ Power
Arithmetic * Multiplication
Arithmetic / Division
Arithmetic + Addition
Arithmetic Subtraction/Negation
Relational = Equal To
Relational <> Not Equal To
Relational < Less Than
Relational > Greater Than
Relational <= Less Than or Equal To
Relational >= Greater Than or Equal To
Logical not Logical negation
Logical and And
Logical or Or

Operators supported only by standard formula definitions are:

Type Symbol Purpose
Relational !=, ne Not Equal To
Relational lt Less Than
Relational gt Greater Than
Relational le Less Than or Equal To
Relational ge Greater Than or Equal To
Logical ! Logical negation
Logical && And
Logical || Or
  • Operator Priority in Prophet Programming Language

The order of decreasing priority of operators used in both standard and extended formulas is as follows:

not, !
- (negation)
^
*, /
+, -
=, !=, ne, <>
<, >, <=, >=, lt, gt, le, ge
and, &&
or, ||

These priorities can be changed by the use of brackets.