Sparx Systems Forum
Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: Hoefler1 on August 11, 2016, 01:57:15 am
-
Can anyone tell me why this would not work? There is an error " 'Function' expected" appearing in the line with "End Try".
There are basically 3 cases:
1. The GUID of the AttrClassifier is in OwnElems -> set IsValid = true
2. The GUID is not in OwnElems -> set IsValid = false
3. There is no Element with the ID of the Classifier (Catch the Exception thrown in first line of Try-Block) -> set IsValid = true
public function Validate(item)
dim validationResult
set validationResult = new ValidationResult
...
Try
Dim AttrClassifier As EA.Element = Repository.GetElementByID(Attribute.ClassifierID)
Dim guid
Set guid = AttrClassifier.ElementGUID
If THandler.OwnElems.Contains(guid) Then
validationResult.IsValid = true
set Validate = validationResult
Else
validationResult.IsValid = false
set Validate = validationResult
End If
Catch Exception
validationResult.IsValid = true
set Validate = validationResult
Return 'ignore default classifiers and elements without classifier
End Try
end function
-
There is no try-catch in VBScript. See http://stackoverflow.com/questions/4999364/try-catch-end-try-in-vbscript (http://See http://stackoverflow.com/questions/4999364/try-catch-end-try-in-vbscript)
VBScript <> VB
Geert
-
For an explanation of what it does have and how to handle errors:
http://stackoverflow.com/questions/157747/vbscript-using-error-handling#157785 (http://stackoverflow.com/questions/157747/vbscript-using-error-handling#157785)