122
Compiler
© 2008 Conrad Electronic
Sub func1(param1 As Word, param2 As Single)
Msg_WriteHex(param1)
' first parameter output
Msg_WriteFloat(param2)
' second parameter output
End Sub
Similar to local variables passed parameters are only visible within the function itself.
In order to call up function func1 by use of the parameters the parameters for call up should be
written in the same succession as they have been defined in func1. If the function does not get
parameters the parenthesis will stay empty.
Sub main()
Dim a As Word
Dim f As Single
func1(
128
,
12.0
)
' you can pass Numerical constants
a=
100
f=
12.0
func1(a+
28
,f)
' or yet variables too and even numerical expressions
End Sub
When calling up a function all parameters must always be stated. The following call up is
inadmissible:
func1()
'
func1 gets 2 parameters!
func1(
128
)
'
func1 gets 2 parameters!
Return Parameters
It is not only possible to pass parameters. A function can also offer a return value. The data type of
this value is during function definition entered after the parameter list of the function.
Sub func1(a As Integer) As Integer
Return a-
10
End Sub
The return value is within the function stated as instruction "return Expression". If there is a function
without return value then the return instruction can be used without parameters in order to leave the
function.
References
Since it is not possible to pass on arrays as parameters the access to parameters is possible
through references. For this the attribute "ByRef" is written ahead of the parameter name in the
parameter declaration of a function.
Sub StringLength(ByRef str As Char) As Integer
Dim i As Integer
i=
0
Summary of Contents for C-Control Pro Mega Series
Page 1: ... 2008 Conrad Electronic C Control Pro Mega Series ...
Page 9: ...VIII Inhalt 2008 Conrad Electronic ...
Page 10: ...Part 1 ...
Page 17: ...Part 2 ...
Page 23: ...Part 3 ...
Page 41: ...32 Hardware 2008 Conrad Electronic 3 3 5 3 Component Parts Plan ...
Page 57: ...48 Hardware 2008 Conrad Electronic 3 4 5 3 Component Parts Plan ...
Page 58: ...Part 4 ...
Page 91: ...82 IDE 2008 Conrad Electronic ...
Page 92: ...Part 5 ...
Page 135: ...126 Compiler 2008 Conrad Electronic 31 1F US 63 3F 95 5F _ 127 7F DEL ...
Page 136: ...Part 6 ...
Page 231: ...Part 7 ...
Page 240: ......