KB-12286: Creating links at runtime.

Question:

How can I create links between I/O tags and objects already added to the screen, at runtime?

Solution:

To do so, use the object’s CreateLink method.:

CreateLink (Property, Source[, Type])

Where:

  • Property: name of the property for which the link will be created
  • Source: name of the link’s source object
  • Type (optional): type of link to be created. When this parameter is omitted, a simple link will be created

Available options for Type parameter:

0 – Simple Link: source value is copied to the property whenever it is modified. 

1 – Bidirectional Link: same as above; however, if the property changes, its value is copied to the source, thus generating a bidirectional link.

2 – Analog Link: establishes a conversion scale between the source’s variable and the property. 

3 – Digital Link: fixed or alternant values are specified for the property, and they are attributed according to the source (true or false).

4 – Table Link: where conditions between variable, values, and destination can be established. Minimum and maximum values are specified on the table, in addition to other settings.

5 – Reverse Link: this is a unidirectional link from property to source.

6 – Multiple Link: this is similar to a table link, except that each line on the link is able to retrieve value from a different source.

Sample script between a screen display and a demo tag, creating a simple link:

Screen.Item(“Display”).Links.CreateLink “Value”, “Data.TagDemo1.Value”, 0
Print Friendly, PDF & Email

Este artigo foi útil? Was this helpful?

Classificação média - Average rating 5 / 5. Count: 1

Leave a Reply

Your email address will not be published.Required fields are marked *