Hi All,
I am tyring to edit a mulitilevel/multiDimensional list but I am getting a compile error.
What I am trying to do is;
1. to generate a list of parameters for listed children
2. edit the created list based on a few conditional checks
Now the list is created and is working fine, but when I want to edit an item in the list; I am getting the comlie error.
Here's what my rule looks like:
Rule lstPreStdPanels As List
Dim panelCounter As Integer
'loop to create the panel parameters list
For panelCounter = 1 To intNoStdPanels
lstPreStdPanels = lstPreStdPanels + {{ _
":origin", Point(panelCounter * StdPanelLength,0,0), _
":xDirection", Vector(0, -1, 0), _
":yDirection", Vector(-1, 0, 0), _
":panel_length" , StdPanelLength }}
Next
Dim openingCounter As Integer
'Loop through the opening list to check if need changed length
For openingCounter = 1 To length ( lstOpeningList )
If nth (5, nth( openingCounter , lstOpeningList ) ) = "T" Then
For panelCounter = 1 To intNoStdPanels
'Determine the target panels
If GetX(Second(nth(panelCounter,lstPreStdPanels)) >50 Then
'nth(8, nth( panelCounter, lstPreStdPanels ) ) = 5
End If
Next' panel counter
EndIf' If opening List = T
Next' openings counter
End Rule
I am getting the error on the commented line.
I could try to place the conditional checks as the list is generated, but I have more that one conditions which are themself in a loop (in contrast to this sample code).
All help is appreciated.
Thanking you,
Wajih
Solved! Go to Solution.
Solved by Chris_Rogers. Go to Solution.
Hello,
Editing an element of a list is not possible in the intent language as you have shown. I have worked around this before by creating a replaceItem function which takes a list, an element index, and a newValue and essentially splits the originally list at the index, excluding the item to replace and builds a new list inserting the newValue between the start and end pieces of the two parts of the list.
Could you please post/attach the function/snippet.
Trying to accomplish what I had asked has exhausted: I am out ideas.
A fresh perspective would be a re-boot.
Thanking you,
Wajih
Here is a method that I wrote which replaces an item in a list by index.
Method ReplaceItemInList(inputList As List, indexOfItemToReplace As Integer, newValue As Any) As List
Dim lowerList As List = {}
Dim upperList As List = {}
If indexOfItemToReplace > 1 Then
lowerList = subList(inputList, 1, indexOfItemToReplace -1)
End If
If indexOfItemToReplace < length(inputList) Then
upperList = subList(inputList, indexOfItemToReplace + 1, length(inputList))
End If
Return lowerlist + {newValue} + upperList
End Method