Name Spaces

Name space is a scope within which an identifier must be unique. The mikroBasic PRO for PIC uses two distinct categories of identifiers:

  1. Global variables are visible throughout the whole unit, from the place of declaration. Also. they can be seen in other units, if they are declared above the Implementation section.
  2. Local variables, parameters, types, function results - must be unique within the block in which they are declared.

For example:

dim level as byte

sub procedure control(dim sens as byte)
  dim location as byte
  location = 1
  sens = location
  level = 123
end sub

sub procedure temperature
  location = 0      ' ILLEGAL
  sens = 23         ' ILLEGAL: redefinition of sens
  level = 95
end sub
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