DIAdem Help

Method: Add for AssignmentList <Data>

  • Updated2024-09-12
  • 3 minute(s) read

Method: Add for AssignmentList <Data>

Creates a new assignment in the assignment list of an assignment channel in the script interface for internal data .

Set oAssignment = Object.Add(Value, Definition)
ObjectAssignmentList <Data>
Object with this method
ValueString
Specifies the text value of an assignment.
DefinitionVariant
Specifies the single value or the value range of the assignment. Use a visual basic array with two values, for example, Array(1,2) to specify a value range.
oAssignmentAssignment <Data>
Returned object

Note  DIAdem always orders the list of assignments in the ascending order of the Definition property. If you used the methods Add or Remove to change the list of assignments, the index no longer corresponds with the previous position of the assignment in the list.

The following example generates an assignment channel with three assignments and displays the definition values and the associated texts:

VBScriptPython

 

Dim oMyGrp, oMyChn, oMyAssgnList, Assignment
Set oMyGrp = Data.Root.ChannelGroups(1)
Set oMyChn = oMyGrp.Channels.AddAssignmentChannel("MyAssignmentChn","Default Value", DataTypeChnFloat64, 1)
Set oMyAssgnList = oMyChn.AssignmentList
Call oMyAssgnList.Add("text1",1)
Call oMyAssgnList.Add("text2",2)
Call oMyAssgnList.Add("text3",3)
For Each Assignment in oMyAssgnList
  Call MsgBoxDisp("Definition Value: " & Assignment.Definition & vbCrLf & "Text: " & Assignment.Value)
Next

The following example generates an assignment channel, in which texts are assigned to three value ranges, and outputs the value ranges and the associated text:

VBScriptPython

 

Dim oMyGrp, oMyChn, oMyAssgnList, Assignment, vRange
Set oMyGrp = Data.Root.ChannelGroups(1)
Set oMyChn = oMyGrp.Channels.AddAssignmentChannel("MyAssignmentChn","Default Value", DataTypeChnFloat64, 1)
Set oMyAssgnList = oMyChn.AssignmentList
Call oMyAssgnList.Add("text1",Array(1,2))
Call oMyAssgnList.Add("text2",Array(3,4))
Call oMyAssgnList.Add("text3",Array(5,6))
For Each Assignment in oMyAssgnList
  vRange = Assignment.DefinitionRange
  Call MsgBoxDisp("Definition Range " & vRange(0) & " - " & vRange(1) & ": " & Assignment.Value)
Next