ListPLCs Appendix B CX-Server Communications Control
134
All PLC memory functions (e.g. A, AR, D, DM etc.) work in exactly the same
way. The following examples use the DM function to get and set the value of a
DM address in a PLC.
Example 1
intVal = CXServer.DM(100)
In this example, the contents of DM100 will be read from the PLC and stored
in 'intVal'.
Example 2
CXServer.DM(100) = 75
In this example, the value 75 will be written to DM100 in the PLC.
Bit addressing, that is accessing data from individual memory bits, is also
supported by these memory areas: IR, AR, HR and CIO.
Example 3
bVal = CXServer.IR("100.2")
In this example, the status of bit IR100.2 (i.e. bit 2 of IR100) will be read from
the PLC and stored in 'bVal' (e.g. 'bVal' will be set to TRUE or FALSE).
Example 4
CXServer.IR("100.2") = True
In this example, bit IR100.2 (i.e. bit 2 of IR100) in the PLC will be set to True.
Note that use of the quotes is optional, but is required to differentiate between
100.1 and 100.10
B.15 ListPLCs
Holds a list of all PLC names configured in the project file. This property is
read only.
Example
Dim arrayOfPLCs
Dim nUbound, nLbound
arrayOfPLCs = CXServer.ListPLCs
nLbound = LBound(arrayOfPLCs)
nUbound = UBound(arrayOfPLCs)
For Count = nLbound To nUbound
MsgBox arrayOfPLCs(Count)
Next
In this example, the list of PLC names in the project configured stored in
'arrayOfPLCs' and then each is displayed in a message box.
B.16 ListPoints
Holds a list of all point names configured in the project file or PLC. This
property is read only.
Example
Dim arrayOfPoints
Dim nUbound, nLbound
arrayOfPoints = CXServer.ListPoints(sPLC)
nLbound = LBound(arrayOfPoints)
nUbound = UBound(arrayOfPoints)
Note: These examples assume there is only 1 PLC in the CX-Server project file, or
that the 'SetDefaultPLC' function has been used to select the required PLC.
Refer to the 'SetDefaultPLC' function for details about using script with multiple
PLCs in the project.