Question:
How can I create links via scripts?
Solution:
To do so, you must use the CreateLink() method of the object with which you want to create the link.
The complete command is: CreateLink(Property, Source [,Type])
where:
Property: sets the name of the property with which the link will be created.
Source: sets the name of the origin-object of the link.
Type (optional): sets the type of link to be created. If this parameter is omitted, a simple link is created.
And the types of link (Type field) are:
0 – Simple link
1 – Bidirectional link
2 – Analog link
3 – Digital link
4 – Table link
5 – Reverse link
6 – Multiple link
Script creating a simple link: Source = "Data.Tag.Value" 'Link source string Set Obj = Screen.Item("Text1") Set Bind = Obj.Links.CreateLink("Value", Source, 0) 'CreateLink (Property string, Source string, 0) Script creating a bidirectional link: Source = "Data.Tag.Value" 'Link source string Set Obj = Screen.Item("Text1") Set Bind = Obj.Links.CreateLink("Value", Source, 1) 'CreateLink (Property string, Source string, 1) Script creating an analog link: Source = "Data.Tag.Value" 'Link source integer Set Obj = Screen.Item("Text1") Set Bind = Obj.Links.CreateLink("Value", Source, 2) 'CreateLink (Property string, Source string , 2) Bind.SrcHiValue = 1 ‘Source highest value Bind.SrcLoValue = 0 ‘Source lowest value Bind.DstHiValue = 100 ‘Property highest value Bind.DstLoValue = 0 ‘Property lowest value Script creating digital link: Source = "Data.Tag.Value" 'Link source Boolean Set Obj = Screen.Item("Text1") set Bind = obj.Links.CreateLink("Value", Source, 3) 'CreateLink (Property string, Source string, 3) Bind.OnValue = "Text ON" Bind.OffValue = "Text OFF" Script creating a table link: Source = "Data.Tag.Value" 'Link source integer Set Obj = Screen.Item("Text1") Set Bind = Obj.Links.CreateLink("ForegroundColor", Source, 4) 'CreateLink (Property string, Source string, 4) Bind.InsertRow() Bind.Item(1).Value = RGB(255,0,0) Bind.Item(1).Min = 0 Bind.Item(1).Max = 10 Script creating a reverse link: Source = "Data.Tag.Value" 'Link source string Set Obj = Screen.Item(“Text1”) Set Bind = Obj.Links.CreateLink("Value", Source, 5) 'CreateLink (Property string, Source string, 5) Script creating a multiple link: Source = "Data.Tag.Value" 'Link source integer Tag1 = "Data.Tag1.Value" 'Row 1 source tag Set Obj = Screen.Item("Text1") Set Bind = Obj.Links.CreateLink("Value", Source, 6) 'CreateLink (Property string, Source string, 6) Bind.InsertRow() Bind.Item(1).Source = Tag1 Bind.Item(1).Min = 0 Bind.Item(1).Max = 10