Instructions

210Compiler
© 2013 Conrad Electronic
Text="hello world"
Len=StringLength(Text)
End Sub
In main the reference of text is presented as parameters to the function StringLength. If in a function
a normal parameter is changed then the change is not visible outside this function. With references
this is different. Through parameter str can in StringLength the contents of text be changed since str
is only the reference (pointer) to the array variable text.
Presently arrays can only be presented "by Reference"!
Pointer Arithmetic
In the current C-Control Pro software also arithmetic on a reference (pointer) is permitted, as the fol-
lowing example shows. The arithmetic is limited to addition, subtraction, multiplication and division.
Sub main()
Dim Len As Integer
Dim Text(15) As Char
Text="hello world"
Len=StringLength(Text+2*3)
End Sub
Pointer arithmetic is currently experimental and may possibly still contain errors.
Strings as Parameter
Since Version 2.0 of the IDE it is possible to call functions with a string as parameter. The called
function gets the string as reference. Since references are RAM based and predefined strings are
stored in the flash memory, the compiler creates internally an anonymous variable, and copies the
data from flash into memory.
Sub StringLength(ByRef str As Char) As Integer
....
End Sub
Sub main()
Dim Len As Integer
Len=StringLength("hallo welt")
End Sub
4.3.8 Tables