Byref, Byval, Readonlybyref - Crestron SIMPL+ Reference Manual

Language reference guide
Hide thumbs Also See for SIMPL+:
Table of Contents

Advertisement

Crestron SIMPL+
Keyword Meanings
KEYWORD
MEANING
ByRef
Changes made to the variable that is passed to the function actually change the contents of the
source variable. Note that any change made to the source variable will be reflected in the function.
For example, if an INTEGER is passed ByRef and its state changes, the function will know about
the change. It is typically more efficient to pass a variable by reference because space is not taken
up by making local copies as with ByVal.
Also referred to as "Pass by Reference".
ByVal
The variable that is passed to the function has a local copy made of it. Changes made to the
variable in the function are made on a local copy. The local copy is destroyed when the function
terminates. The contents of this variable are a "snapshot" of the contents of the variable that was
passed. Unlike Pass by Reference, changes made to the original variable that was passed to the
function are not recognized in the function. When an expression is passed, it may only be passed
by value since there is no source variable that the ByRef keyword may potentially modify.
Also referred to as "Pass by Value".
ReadOnlyByRef
This performs a Pass by Reference, identical to ByRef, but the compiler catches operations that
write to the variable that has been passed. This would be typically be used if a DIGITAL_INPUT
or other input type has been passed and which cannot be written. It is also used as a tool to catch
unintentional writes to variables that have been passed.
Language Reference Guide - DOC. 5797G
®

ByRef, ByVal, ReadOnlyByRef

NOTE: Passing STRINGs with BYVAL an BYREF is not allowed in the 2-Series
Control System. All STRINGs are passed by referenced in the 2-Series Control
System.
NOTE: Passing I/O datatype variables (DIGITAL_INPUT, ANALOG_INPUT and
STRING_INPUT) is not allowed in the 2-Series Control System.
If not specified in the function declaration, variables will be passed by reference if
applicable. If the variable cannot be passed by reference (such as an element of an
array), it will be passed by value. Any expression will always be passed by value.
The following table shows legal access methods for the basic data types when passed
to a function.
Software
®
SIMPL+
269

Advertisement

Table of Contents
loading

Table of Contents