Procedural Programming Example
This function illustrates many of Analytica's key constructs for procedural programming. It computes the prime factors of an integer «x»:
Here's more detail on the numbered procedural features in this function:

VAR x := e
defines a local identifierx
and sets its value to the result of evaluating expressione
. See Defining a Local Value.  Expressions (statements) in a sequence should be separated by “;” (semicolons). The expressions can be on the same line, successive lines, or may be broken over multiple lines. Newlines are just for clarity and have no effect on the syntax. See BeginEnd for Grouping Expressions.
 WHILE
test DO body
tests conditionest
, and, if True, evaluatesBody
, and repeats untilTest
is False. See While(Test) Do Body.  One way to group a sequence of expressions separated by semicolons “;” is to enclose them as
BEGIN e1; e2; … END
— in this case as the body of a While loop. See BeginEnd for Grouping Expressions.  Another way to group a sequence of expressions is to enclose them between parentheses
(e1; e2; …)
— in this case, as the action to be taken in the Then case. See BeginEnd for Grouping Expressions. 
x := e
assigns the value of expressione
to a local valuex
or, as in the first case, to a parameter of a function. See Assigning to a local value.  The value returned from a sequence of expressions, in this case the Definition of the Function, is the value of the last expression. Here the function
Factors
returns the final expression, which is simple the local valueresult
.
See Also
 Defining a Local Value
 Assigning to a local value
 BeginEnd for Grouping Expressions
 For and While Loops
 Function calls and parameters
Comments
Enable comment autorefresher