ChaosPro Home
Introduction
What's New
Palettes
Using Formulas
Layering in ChaosPro
Rendering
Fractal Parameter Windows
Windows
Menu
3D Transformations
Animations
Formula Compiler
Writing Formulas
Language Reference
Introduction
Basic Syntax
Datatypes
Constants
Variables
Basics
Variable Scope
Predefined Variables
Parameters
Expressions
Operators
Functions
Control Structures
Compiler Directives
Functions
Interface to ChaosPro
Special Features, Notes...
Compatibility
Fractal Type Reference
Tutorials
Appendix
CHAOSPRO 4.0
Release 4.0
.

Basics

Variables in ChaosPro need to be declared by specifying their name and type. They are represented by the name of the variable. The variable name is case-sensitive.

A valid variable name starts with a letter or underscore, followed by any number of letters, numbers, or underscores. As a regular expression, it would be expressed thus: '[a-zA-Z_][a-zA-Z0-9_]*' ;-)

Note:

For our purposes here, a letter is a-z, A-Z.

Examples:

real d,D;
  d = 3;
  D = 4;
  z=d*D;        // z will be 12, variable names are case-sensitive!

real 4d;
  4d = 3.4;     // invalid; starts with a number

complex _4d;
  _4d = 3.4;    // valid; starts with an underscore

real hägen;
  hägen = 77;   // invalid; 'ä' (ASCII 228) is not a letter.

In ChaosPro, variables are always assigned by value. That is to say, when you assign an expression to a variable, the entire value of the original expression is copied into the destination variable. This means, for instance, that after assigning one variable's value to another, changing one of those variables will have no effect on the other. For more information on this kind of assignment, see the chapter on Expressions.

Another way to assign values to variables is "assign by reference". This means that the new variable simply references (in other words, "becomes an alias for" or "points to") the original variable. Changes to the new variable affect the original, and vice versa. ChaosPro does not support this method with variables, but with function parameters:
Each function parameter can be either "by value" or "by reference", just as you define it. This enables you to return more than one value from a function.