AdsCreateVarHandle
Generates a unique handle for an ADS variable.
object.AdsCreateVarHandle(
varName As String,
hVar As Long
) As Long
Parameter
varName
[in] Name of the ADS variable
hVar
[out] Handle of the ADS variable
Return value
See ADS error codes
Comments
Note on PLC: Ensure that 'Symbol download' is enabled in PLC Control under Project / Options / TwinCAT. More detailed information can be found in the PLC Control manual.
The first parameter of the method consists of the POE name and the PLC variable to be addressed. If, for instance, the variable 'SPSVar1' from the function 'Funk1' is to be accessed, then 'Funk1.SPSVar1' must be supplied as the first parameter. When global variables are being accessed, the POE name is omitted, as, for instance, in '.SPSGlobVar'. The parameter 'varName' does not distinguish between upper and lower case letters. If only certain specific PLC variables are required in a form, the handle should only be created when the form is loaded, and should be released again when the form is closed. See also the AdsDeleteVarHandle() method.
Note on NC: In the System Manager, the symbol download must be enabled for each axis. This can be specified in the configuration dialog for the axis under 'General'. The 'Create symbols' box must be checked. See System Manager manual.
The symbolic names of the individual NC parameters have a fixed specification, and can be found in the NC documentation.
Example
-