Main About Download Documentation Resources
Data Types
Integer Data Type
The Integer data type is one of the most commonly used types in programming. An integer can store a positive or negative
whole number, but can't store fractional values. So, it can store values such as 5, 42, 1947, but can't store numbers such as
3.2, 4.5, etc...
If a number with a fractional value is stored into a integer, the fractional value will be discarded. Hence, if 3.2 is stored into
an integer, it will only retain 3.
The Variable Watch Window displays integers in blue.
Real Data Type
The Real data type can store any number - both whole numbers and ones with fractional values. In many languages, this is
called a "double" after the implementation standard known as "double-precision floating point".
The Variable Watch Window displays reals in purple.
String Data Type
The String data type is used to store any textual data. This includes words, letters, or anything else you would send in a text
message. In programming, the text is delimited with double quotes. For example: "CSU, Sacramento", "computer", and
"Year 1947" are all strings.
The Variable Watch Window displays strings in red.
Boolean Data Type
Flowgorithm - Documentation 1 1
The Boolean Data Type can store either "true" or "false". These are the basis of decision making in a computer program.
The Variable Watch Window displays Booleans in teal.
Summary Chart
Data Type Notes
Boolean Stores either Boolean true or false
Real Stores a real number.
Integer Stores an integer number.
String Stores textual data.
Flowgorithm - Documentation 1 2
Main About Download Documentation Resources
Identifiers
Any time you define a function or variable, it is given a unique name called an "identifier". To prevent identifiers from being confused with other items in an
expression, they must follow a naming convention. Every programming language has one and it is fairly consistent from language to language.
In Flowgorithm, identifiers must adhere to the following rules:
They must start with a letter.
After the first letter, the identifier can contain additional letters or numbers.
Spaces are not allowed.
They cannot be reserved words or words already defined by Flowgorithm (please see below)
Also note:
Languages such as Visual Basic and C also allow the underscore character "_". Flowgorithm, however, does not allow it.
Identifiers are not case-sensitive.
The following are some simple example identifiers.
Valid Identifiers Notes
x Identifiers can be single letter.
name
noun2 Numbers are allowed after the first letter
Keywords
Overview
Flowgorithm - Documentation 2 3
Many words using in programming languages overlap the naming convention used by identifiers. In these cases, the word is "reserved" and cannot be used for
Identifiers. In addition, many programming languages predefine functions and other constants. These also cannot be used.
Reserved Words
Flowgorithm only has a few reserved words that are used in expressions.
and not true
false or
mod pi
Data Type Keywords
To prevent confusion, the system also prevents identifiers from using the data type names.
boolean real
integer string
Illegal Keywords (used in functions)
Flowgorithm does not permit the names of intrinsic functions to be used.
abs int sin tofixed
arccos len size tointeger
arcsin log sqrt tostring
arctan log10 tan toreal
char random tochar
cos sgn tocode
Flowgorithm - Documentation 2 4
Reserved for Future Use
Future versions of Flowgorithm will expand the number of intrinsic functions. The following were reserved if they are included.
arccosh cosh
arcsinh sinh
arctanh tanh
Flowgorithm - Documentation 2 5
Main About Download Documentation Resources
Operators
About
Expressions combine operators used in the two major families of programming languages. The "BASIC-family" contains English keywords and operators. The "C-
family" (which includes C, Java, C#) is far more symbolic.
Since both families are supported, there are a number of redundant operators. These are:
Operator C Family BASIC Family
Negation ! not
Modulo % mod
Equality == =
Inequality != <>
Logical And && and
Logical Or || or
Flowgorithm also adds a few unique Visual Basic operators since if they have helpful, clearly defined, semantics
Visual Basic Operator Name
& String Concatenation
^ Exponent
In Java and C#, the "+" operator is used for both string concatenation and addition. This can be quite confusing given the rather complex semantics. In Flowgorithm,
addition will only work with numbers. The ampersand "&" is used for concatenation.
Flowgorithm - Documentation 3 6
Also, C# and Java lack an exponent operator - instead relying their respective Math classes. Flowgorithm uses the Visual Basic "^".
Precedence
The following are the precedence levels from high (evaluated first) to low.
Level Name Operators Notes
8 Unary - ! not In Visual Basic, "not" precedence level is far lower - above "and", but below all relational operators.
7 Exponent ^ The exponent operator does not exist in C# or Java.
6 Multiply * / % mod Division will always be high-precision (floating point)
5 Addition + - "+" will only work with numbers.
4 Concatenate & C# and Java use the ambiguous "+" operator for addition and concatenation.
3 Relational > >= < <=
== = != <>
2 Logical And and &&
1 Logical Or or ||
Examples
Expression Result Notes
1 + 3 ^ 2 10
10 * 2 + 5 * 6 50 10 * 2 and 5 * 6 have higher precedence than addition. The addition is done last.
7 * (4 - 1) 21 Parenthesis are used for subexpressions, which are evaluated as a whole.
6 / 3 * 2 4 In mathematics, multiplication and division have the same precedence levels. So, they are evaluated left-to-right. The
"PEMDAS" acronym, used in high-school, is a tad misleading.
10 mod 3 1 Modulo math gives the remainder from division
10 % 3 1 Same expression, but using the C-Family operator
Flowgorithm - Documentation 3 7
Main About Download Documentation Resources
Intrinsic Functions
Mathematics
Function Description Version Added
Abs(n) Absolute Value
Arcsin(n) Trigonometric Arcsine 1.7
Arccos(n) Trigonometric Arccos 1.7
Arctan(n) Trigonometric Arctangent
Cos(n) Trigonometric Cosine
Int(n) Integer of a real number
Log(n) Natural Log
Log10(n) Log Base 10
Sgn(n) Mathematical sign (-1 if n is negative, 0 if zero, 1 if positive)
Sin(n) Trigonometric Sine
Sqrt(n) Square Root
Tan(n) Trigonometric Tangent
Strings
Flowgorithm - Documentation 4 8
Function Description
Len(s) Length of a string
Char(s, i) Returns a character from the string s at index i. Characters are indexed starting at 0.
Data Type Conversion
Function Description Version Added
ToChar(n) Convert a character code n into an character 1.5
ToCode(c) Convert a character c into a character code (integer). 1.8
ToFixed(r, i) Convert real number r to a string with i digits after the decimal point. 1.8
ToInteger(n) Convert a string to an integer
ToReal(n) Convert a string to an real
ToString(n) Convert a number to a string
Other
Function Description Version Added
Random(n) A random number between 0 and (n - 1)
Size(a) The size (number of elements) in an array 1.7
Flowgorithm - Documentation 4 9
Main About Download Documentation Resources
Built-in Constants
Flowgorithm predefines three commonly used constants. True and False are often used to initialize Boolean variables. Pi is commonly used in mathematics.
Constant Notes
true Boolean True
false Boolean False
pi Mathematical PI. Approximately 3.1415.
Flowgorithm - Documentation 5 10
Main About Download Documentation Resources
Basic File Format
Most applications save data in a complex binary file where the contents are seldom published. Often this does make sense given that the data is complex and
techniques, such as compression, are used to minimalize the file size.
Programs in Flowgorithm are quite simple. There is no large data elements that need compression nor are there different types of data to be stored. It's a simple
program - just like anything written in Java, C#, etc... So, rather than having complex binary files, files will be easy to read and port to other systems. The idea is that
programs "written" using this application can be easily used by third-party tools. To accomplish this, files will be stored in simple XML.
Example
Given the following program...
Flowgorithm - Documentation 6 11
The program will be saved using the following format:
Sample File
<?xml version="1.0"?>
<flowgorithm fileversion="2.0">
<attributes>
<attribute name="name" value="Age"/>
<attribute name="authors" value="Devin Cook"/>
<attribute name="about" value="A simple example of an If Statement">
<attribute name="saved" value="1/7/2015 11:27:10 PM"/>
</attributes>
<function name="Main" type="None" variable="">
<parameters/>
<body>
<declare name="age" type="Integer" array="False" size=""/>
<output expression=""Please enter your age""/>
Flowgorithm - Documentation 6 12
<input variable="age"/>
<if expression="age >= 21">
<then>
<output expression=""Kegger!""/>
</then>
<else>
<output expression=""Milk!""/>
</else>
</if>
</body>
</function>
</flowgorithm>
Flowgorithm - Documentation 6 13
Main About Download Documentation Resources
Assignment Shape
Default Appearance
What it Does
The Assignment shape is used to store the result of a calculation into a variable. This is one of the most common tasks found
in programs.
Example
The example, to the right, declares two variables: area (which stores real numbers) and radius (which stores integers). It
then uses an Assignment Statement to set the 'radius' to 7. Finally, it computes the area of a circle and stores the result in
'area'.
Flowgorithm - Documentation 7 14
Main About Download Documentation Resources
Breakpoint Shape
Default Appearance
What it Does
The Breakpoint Shape temporality halt the execution of the program. This is useful both for debugging programs and for
demonstrations. Most professional software development applications have some form of the breakpoint.
Example
The example, to the right, creates a variable called 'value' and assigns it an initial value of 12. The program then encounters a
breakpoint shape - which still halt execution.
This will allow the user to see the current value of 'n' in the Variable Watch Window. Once execution is continued, the second
assignment shape is executed.
Flowgorithm - Documentation 8 15
Main About Download Documentation Resources
Call Shape
Default Appearance
What it Does
A Call Statement transfers control to a function. Information being passed into the function are called 'arguments'.
Example
The following example uses the Call Shape to execute a function called 'Greeting'.
When the program executes, the first shape will call the Greeting Function. After it outputs "Hello!", it will return and the Main Function and it will output "Goodbye!".
Flowgorithm - Documentation 9 16
Flowgorithm - Documentation 9 17
Main About Download Documentation Resources
Comment Shape
Default Appearance
What it Does
Comments don't affect how your program runs. They are used to include documentation about the
program for other programmers. These can include: the logic of a loop, known issues, changes made,
future changes, etc...
Example
The example, to the right, contains a comment between two Output Shapes. It has no affect on the
program.
Flowgorithm - Documentation 10 18
Main About Download Documentation Resources
Declare Shape
Default Appearance
What it Does
A Declare Statement is used to create variables and arrays. These are used to store data while the program runs.
Example
The example, to the right, declares two variables: area (which stores real numbers) and radius (which stores integers). It
then uses an Assignment Statement to set the 'radius' to 7. Finally, it computes the area of a circle and stores the result in
'area'.
Flowgorithm - Documentation 11 19
Main About Download Documentation Resources
Do Shape
Default Appearance
What it Does
A Do Loop is similar to a While Loop except that the block of statements is executed at least once before the
expression is checked.
Example
The example, to the right, shows a Do Statement that accepts only valid input. It will loop while the 'age' variable
is less than 1 or greater than 100.
Flowgorithm - Documentation 12 20
Main About Download Documentation Resources
For Shape
Default Appearance
What it Does
For Loops increment a variable through a range of values. This is a common, useful, replacement for a While Statement.
Example
The example, to the right, prints the numbers from 1 to 100. The loop executes 100 times. The value of 'n' starts at 1 and
increases by 1 each time the loop executes. The loop ends when 'n' reaches 100.
Flowgorithm - Documentation 13 21
Main About Download Documentation Resources
If Shape
Default Appearance
What it Does
An If Statement checks a Boolean expression and then executes a true or false branch based on
the result.
Example
The example, to the right, declares an integer called 'age'. It then reads the age from the keyboard.
Finally, an If Statement checks if the age is greater than or equal to 18. Based on this, it either
takes the false branch and displays "Sorry, not yet", or takes the true branch and displays "Go
vote!".
Flowgorithm - Documentation 14 22
Main About Download Documentation Resources
Input Shape
Default Appearance
What it Does
An Input Statement reads a value from the keyboard and stores the result in a variable.
Example
The example, to the right, creates two variables: 'area' and 'radius'. It then uses an Input Statement to read the radius from
the keyboard. A final Output Statement then displays the result.
Flowgorithm - Documentation 15 23
Main About Download Documentation Resources
Output Shape
Default Appearance
What it Does
An Output Statement evaluates an expression and then displays the result on the screen.
Example
The example, to the right, creates two variables: 'area' and 'radius'. It then uses an Input Statement to read the radius from
the keyboard. A final Output Statement then displays the result.
Flowgorithm - Documentation 16 24
Main About Download Documentation Resources
While Shape
Default Appearance
What it Does
A While Loop evaluates a Boolean expression and, if true, executes statements. It rechecks the expression and loops until it
is false.
Example
The example, to the right, prints the numbers from 1 to 100. The assignment statement "n = n + 1" increments the variable 'n'
by 1 for each iteration of the loop.
Flowgorithm - Documentation 17 25