' Основная функция скрипта
Function DoEvent(UserSession, CardHost, CardData, ActivateFlags, ModeID)
    If Len(GetProp(CardData, "SCVOISTVO", "")) > 512 Then
        MsgBox "LAZHA", vbOKOnly, "OTSOY", vbExclamation
        DoEvent = -1
        Exit Function
    End If
    DoEvent = 0
End Function

' Получение секции карточки по имени
Function Sect(CardData, Alias)
    Set Sect = CardData.Sections(CardData.Type.AllSections.GetByAlias(Alias).ID)
End Function

' Строка свойства
Function Prop(CardData, Alias)
    Set Prop = Nothing
    Dim Row: For Each Row In Sect(CardData, "Properties").Rows
        If Row.Value("Name") = Alias Then
            Set Prop = Row
            Exit Function
        End If
    Next
End Function

' Получение значения свойства
Function GetProp(CardData, Alias, DefaultValue)
    Dim Row: Set Row = Prop(CardData, Alias)
    If Row Is Nothing Then
        GetProp = DefaultValue
    Else
        GetProp = Row.Value("Value")
        If IsNull(GetProp) Then GetProp = DefaultValue
    End If
End Function