Brightsign BrightScript 2 Reference Guide Instrukcja Użytkownika Strona 31

  • Pobierz
  • Dodaj do moich podręczników
  • Drukuj
  • Strona
    / 59
  • Spis treści
  • BOOKMARKI
  • Oceniono. / 5. Na podstawie oceny klientów
Przeglądanie stron 30
31
Dynamic
In addition to the above types, the return type can be:
Void
Parameters can have default values and expressions.
For example:
Function cat(a, b)
Return a+b „a, b could be numbers or strings
End Function
Function five() As Integer
Return 5
End function
Function add(a As Integer, b As Integer) As Integer
Return a+b
End function
Function add2(a As Integer, b=5 as Integer) As Integer
Return a+b
End Function
Function add3(a As Integer, b=a+5 as Integer) As Integer
Return a+b
End Function
Functions have their own scope.
The statement “Sub” can be used instead of “function” as a shortcut to a function of Void
return Type.
If a function is called from an associative array, then a local variable “m” is set to the
AssociatiaveArray that the function is stored in.
For example:
sub main()
obj={
add: add
a: 5
b: 10
}
obj.add()
print obj.result
end sub
function add() As void
Przeglądanie stron 30
1 2 ... 26 27 28 29 30 31 32 33 34 35 36 ... 58 59

Komentarze do niniejszej Instrukcji

Brak uwag