Punctuators
The mikroPascal PRO for PIC punctuators (also known as separators) are:
Brackets
Brackets [ ]
indicate single and multidimensional array subscripts:
var alphabet : array[1..30] of byte; // ... alphabet[3] := 'c';
For more information, refer to Arrays.
Parentheses
Parentheses ( )
are used to group expressions, isolate conditional expressions and indicate function calls and function declarations:
d := c * (a + b); // Override normal precedence if (d = z) then ... // Useful with conditional statements func(); // Function call, no arguments function func2(n : word); // Function declaration with parameters
For more information, refer to Operators Precedence and Associativity, Expressions and Functions and Procedures.
Comma
Comma (,
) separates the arguments in function calls:
LCD_Out(1, 1, txt);
Furthermore, the comma separates identifiers in declarations:
var i, j, k : byte;
The comma also separates elements of array in initialization lists:
const MONTHS : array[1..12] of byte = (31,28,31,30,31,30,31,31,30,31,30,31);
Semicolon
Semicolon (;
) is a statement terminator. Every statement in Pascal must be terminated with a semicolon. The exceptions are: the last (outer most) end
statement in the program which is terminated with a dot and the last statement before end
which doesn't need to be terminated with a semicolon.
For more information, see Statements.
Colon
Colon (:
) is used in declarations to separate identifier list from type identifier. For example:
var i, j : byte; k : word;
In the program, use the colon to indicate a labeled statement:
start: nop; ... goto start;
For more information, refer to Labels.
Dot
Dot (.
) indicates an access to a field of a record. For example:
person.surname := 'Smith';
For more information, refer to Records.
Dot is a necessary part of floating point literals. Also, dot can be used for accessing individual bits of registers in mikroPascal.
What do you think about this topic ? Send us feedback!