Punctuators

The mikroBasic PRO for PIC punctuators (also known as separators) are:

Brackets

Brackets [ ] indicate single and multidimensional array subscripts:

dim alphabet as byte[30]
' ...
alphabet[2] = "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
sub function func2(dim n as word)  ' Function declaration w/ 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:

dim i, j, k as word

The comma also separates elements in initialization lists of constant arrays:

const MONTHS as byte[12] = (31,28,31,30,31,30,31,31,30,31,30,31)

Colon

Colon (:) is used to indicate a labeled statement:

start:  nop
  '...
goto start

For more information, refer to Labels.

Dot

Dot (.) indicates access to a structure member. For example:

person.surname = "Smith"

For more information, refer to Structures.

Dot is a necessary part of floating point literals. Also, dot can be used for accessing individual bits of registers in mikroBasic PRO for PIC.

Copyright (c) 2002-2012 mikroElektronika. All rights reserved.
What do you think about this topic ? Send us feedback!
Want more examples and libraries? 
Find them on LibStock - A place for the code