Sub OnDatapointChanged(ByVal DP As Object, ByVal prop As String) '-------------------------------------------------------------- On Error Resume Next 'MultiRoomControl If prop = "ActualValue" Then If Left(DP.Name, 8) = "MRC_ROOM" Then If DP.Value("MRC_dirty") Then 'if AV changes but the value is dirty we do nothing but reset the dirty flag 'the funktion of the dirty flag is only to reduce the number of calculations DP.Value("MRC_dirty") = False Else Print "MRC startet by " & DP.Name SetRoomValues(DP.Name) End If End If End If '-------------------------------------------------------------- 'write here other functions of OnDatapointChanged End Sub Sub SetRoomValues(sRoom As String) 'MultiRoomControl 'Harald Pokorny 31.10.2003 'Copyright IT GmbH 'get all open rooms to sRoom and set the NV and dirty flag Dim Walls As Object Dim Wall As Object Dim sWalls() As String ReDim sWalls(1) Dim i As Integer Dim nWallCount As Integer Dim sRooms() As String ReDim sRooms(1) Dim j As Integer Dim k As Integer Dim nRoomCount As Integer Dim sRoomNumber As String Dim sRoomFunction As String Dim sHelp As String Dim nLen As Integer Dim nPos1 As String Dim bFound As Boolean Dim sWallRoom1Number As String Dim sWallRoom2Number As String Dim sWallRoomNumber As String Dim bNewWallRoom As Boolean 'first get a list of all open walls 'second get a list of all rooms (from the walls) open to the starting room (=sRoom) i = 0 Set Walls = Database.Datapoints("Name like 'MRC_WALL%'") For Each Wall In Walls If Wall.ActualValue = False Then ReDim Preserve sWalls(i + 1) 'set new array size sWalls(i) = Wall.Name i = i + 1 End If Next nWallCount = i 'get room number If Left(sRoom, 8) = "MRC_ROOM" Then nLen = Len(sRoom) nPos1 = InStr(10,sRoom,"_") sRoomNumber = Mid(sRoom, 9, nPos1 - 8) sRoomFunction = Right(sRoom, nLen - nPos1) 'Print "MRC sRoomNumber: " & sRoomNumber 'Print "MRC sRoomFunction: " & sRoomFunction End If 'fill list of open rooms j = 0 sRooms(j) = sRoomNumber j = j + 1 nRoomCount = j bFound = True While bFound 'search in list of walls until no open wall to any room in sRooms can be found bFound = False For j = 0 To nRoomCount-1 Print "MRC j=" & Str(j) & " Room: " & sRooms(j) For i = 0 To nWallCount-1 Print "MRC i=" & Str(i) & " Wall: " & sWalls(i) If InStr(1, sWalls(i), sRooms(j)) Then 'get both rooms from wall If Left(sWalls(i), 8) = "MRC_WALL" Then nLen = Len(sWalls(i)) nPos1 = InStr(10,sWalls(i),"_") sWallRoom1Number = Mid(sWalls(i), 9, nPos1 - 8) sWallRoom2Number = Right(sWalls(i), nLen - nPos1 + 1) 'Print "MRC sWallRoom1Number: " & sWallRoom1Number 'Print "MRC sWallRoom2Number: " & sWallRoom2Number If (sWallRoom1Number = sRooms(j)) And (sWallRoom2Number <> sRooms(j)) Then sWallRoomNumber = sWallRoom2Number ElseIf (sWallRoom2Number = sRooms(j)) And (sWallRoom1Number <> sRooms(j)) Then sWallRoomNumber = sWallRoom1Number Else Print "MRC Error: no room in wall or both fit!" sWallRoomNumber = "" End If End If 'check if then wall-room are in list of rooms 'Print "sWallRoomNumber: " & sWallRoomNumber If sWallRoomNumber <> "" Then bNewWallRoom = True For k = 0 To nRoomCount-1 'Print "MRC k=" & Str(k) & " Room: " & sRooms(k) If sRooms(k) = sWallRoomNumber Then bNewWallRoom = False Exit For End If Next k End If If bNewWallRoom Then ' new room found! 'Print "new room found: " & sWallRoomNumber ReDim Preserve sRooms(nRoomCount + 1) 'set new array size sRooms(nRoomCount) = sWallRoomNumber nRoomCount = nRoomCount + 1 bFound = True End If End If Next i Next j Wend 'now set the NV of the other rooms For k = 1 To nRoomCount-1 sHelp = "MRC_ROOM" & sRooms(k) & sRoomFunction Print "MRC set " & sHelp Database.Datapoint(sHelp).Value("MRC_dirty") = True Database.Datapoint(sHelp).NominalValue = Database.Datapoint(sRoom).ActualValue Next k End Sub