Message 1 of 10
Writing a subroutine or loop in iLogic rule
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I have the start of a code that needs to repeat 4 times. I can recognize the need for a loop, but I don't know how to write it.
'Rule to position Block 1 preset1 = (railWidth + (blockWidth / 2) - oversize) preset2 = length - railWidth - blockWidth / 2 + oversize preset3 = innerRail1 - blockWidth / 2 - railWidth / 2 preset4 = innerRail1 + blockWidth / 2 + railWidth / 2 preset5 = innerRail2 - blockWidth / 2 - railWidth / 2 preset6 = innerRail2 + blockWidth / 2 + railWidth / 2 Select Case railCount Case 0 If block1position = 0 Then Feature.IsActive("Block1") = False ElseIf block1position = 1 Then Feature.IsActive("Block1") = True block1 = preset1 ElseIf block1position = 2 Then Feature.IsActive("Block1") = True block1 = preset2 ElseIf block1position > 2 And block1position < preset1 Then MessageBox.Show("Block position not available in this configuration", "Block Position Error") Feature.IsActive("Block1") = False ElseIf block1position >= preset1 Then Feature.IsActive("Block1") = True block1 = block1position End If Case 1 If block1position = 0 Then Feature.IsActive("Block1") = False ElseIf block1position = 1 Then Feature.IsActive("Block1") = True block1 = preset1 ElseIf block1position = 2 Then Feature.IsActive("Block1") = True block1 = preset2 ElseIf block1position = 3 Then Feature.IsActive("Block1") = True block1 = preset3 ElseIf block1position = 4 Then Feature.IsActive("Block1") = True block1 = preset4 ElseIf block1position > 4 And block1position < preset1 Then MessageBox.Show("Block position not available in this configuration", "Block Position Error") Feature.IsActive("Block1") = False ElseIf block1position >= preset1 Then Feature.IsActive("Block1") = True block1 = block1position End If Case 2 If block1position = 0 Then Feature.IsActive("Block1") = False ElseIf block1position = 1 Then Feature.IsActive("Block1") = True block1 = preset1 ElseIf block1position = 2 Then Feature.IsActive("Block1") = True block1 = preset2 ElseIf block1position = 3 Then Feature.IsActive("Block1") = True block1 = preset3 ElseIf block1position = 4 Then Feature.IsActive("Block1") = True block1 = preset4 ElseIf block1position = 5 Then Feature.IsActive("Block1") = True block1 = preset5 ElseIf block1position = 6 Then Feature.IsActive("Block1") = True block1 = preset6 ElseIf block1position > 6 And block1position < preset1 Then MessageBox.Show("Block position not available in this configuration", "Block Position Error") Feature.IsActive("Block1") = False ElseIf block1position >= preset1 Then Feature.IsActive("Block1") = True block1 = block1position End If End Select
There are 4 blocks that will be placed, so the above code needs to run for Block1, Block2, Block3 and Block4. I assume I need to dimension the integer for the blocks and possibly also dimension the integer for the preset positions. I think this should be an easy code to write, but I just don't know where to start. Any help greatly appreciated.