Mikroelektronika MIKROE-724 データシート

ページ / 726
mikroBasic PRO for dsPIC30/33 and PIC24
MikroElektronika
207
Here is an example:
dim msg as string[20]
    res_txt as string[5]
    res, channel as word
main:
  ‘...
  ‘ Get result of ADC
  res = Adc_Read(channel)
  ‘ Create string out of numeric result
  WordToStr(res, res_txt)
  ‘ Prepare message for output
  msg = “Result is “ +      ‘ Text “Result is”
          res_txt           ‘ Result of ADC
‘...
Notes
- In current version plus operator for concatenating strings will accept at most two operands. 
- mikroBasic PRO for dsPIC30/33 and PIC24 includes a String Library which automatizes string related tasks. 
Pointers
A pointer is a data type which holds a memory address. While a variable accesses that memory address directly, a 
pointer can be thought of as a reference to that memory address.
To declare a pointer data type, add a carat prefix (
^
) before type. For example, in order to create a pointer to an 
integer
, write:
^integer
In order to access data at the pointer’s memory location, add a carat after the variable name. For example, let’s declare 
variable 
p
 which points to a 
word
, and then assign value 5 to the pointed memory location:
dim p as ^word
‘...
p^ = 5
A pointer can be assigned to another pointer. However, note that only the address, not the value, is copied. Once you 
modify the data located at one pointer, the other pointer, when dereferenced, also yields modified data.