code: def setBlockValue(self, block, value):
          
          if self._bit_count == 0:
              raise Exception( "The margin '" + self._name +
                               "' did not allocate any bits for the values")
          if value < 0:
              raise Exception( "The margin '" + self._name +
                               "' must be a positive integer"  )
  
          if value >= 2 ** self._bit_count:
              raise Exception( "The margin '" + self._name +
                               "' value exceeds the allocated bit range" )
  
          newMarginValue = value << self._bitRange[ 0 ]
          currentUserState = block.userState()
  
          if currentUserState in [ 0, -1 ]:
              block.setUserState(newMarginValue)
          else:
              marginMask = 2 ** self._bit_count - 1
              otherMarginsValue = currentUserState & ~marginMask
              block.setUserState(newMarginValue | otherMarginsValue)
docs: Sets the required value to the block without damaging the other bits