DDE Appendix F Obsolete Features
315
'Request a column of cells from Excel and copy
into Array2, using
'the return 'flag
Array2 = DDERequest(chan, "R1C2:R3C2",
bReturnFlag)
'Request a cell value from Excel and copy into
element 2 of 'Array1'
Array1[2] = DDERequest(chan, "R3C2")
ENDIF
F.4.3.3 DDE Server Array Points
The value of an array point named 'ddearray' in a CX-Supervisor project called
'ddetest.srt' can be read from a Microsoft Excel worksheet by entering the
following formula format into a cell.
=<Server>|<Topic>!<item>.<index>
Example
=SCS|Point!ddearray.3 'access ddearray[3] using
'Point' topic
or
=SCS|ddetest.srt|ddearray.0 'access ddearray[0] using
'Project' topic
The above example is the simplest way to access/read single elements of an
array from Microsoft Excel, to read/write whole arrays, it is necessary to use
macros (Microsoft Excel Visual Basic scripts).
The example scripts that follow have all been created using Microsoft Excel
and are working examples. They contain the minimum amount of information
required to demonstrate the particular facility being described; i.e. they do not
contain any error-checking code.
F.4.3.4 Sending Arrays to CX-Supervisor via DDEPoke()
In order to write to an CX-Supervisor array point using the DDEPoke()
function, it must first be given DDE Read/Write access, via the Advanced Point
Settings dialog box when adding or modifying the point. The following script
shows how to send arrays of values from Microsoft Excel to CX-Supervisor via
DDEPoke().
Example sending array values from Microsoft Excel to CX-Supervisor:
Sub SendArrayValues()
Dim chan As Integer
chan = DDEInitiate("SCS", "Point")
If chan <> 0 Then
'Send a row of data to an array point named
"Array1"
DDEPoke chan, "Array1", Range(Cells(1,1),
Cells(1,3))
Note: All the above points must have DDE Read/Write access set.
Note: Microsoft Excel accepts the square brackets '[ ]' used in CX-Supervisor to
reference an array index in a formula; use '.' instead.
Note: The index must always be specified if an individual array element is required.
Note: CX-Supervisor supports 'Hot' DDE links, if Microsoft Excel has the link option
automatic set, then the value in Microsoft Excel are updated whenever
ddearray[index] changes.