Altova Authentic 2023 Desktop

Die Authentic-Ansicht unterstützt die Verbindung zu Events pro Objekt. Die Implementierung dieser Funktion basiert auf COM Connection Points und steht in Umgebungen zur Verfügung, die diesen Mechanismus unterstützen.


Das folgende Beispiel ist ein Beispiel für VBScript-Code, in dem gezeigt wird, wie man von einem VBScript-Projekt aus Events verwendet.



' --------------------------------------------------------------------------
' VBScript example that demonstrates how to use events.
' --------------------------------------------------------------------------
' Event handler for OnSelectionChanged event of AuthenticView
  IfobjAuthenticRange.FirstTextPosition <> objAuthenticRange.LastTextPosition Then
      CallWScript.Echo("Selection: " & objAuthenticRange.Text & vbNewLine & vbNewLine & "Close this dialog.")
      CallWScript.Echo("Cursor position: " & objAuthenticRange.FirstTextPosition & vbNewLine & vbNewLine & "Close this dialog.")
' Start/access XMLSpy and connect to its automation interface.
SetWshShell = WScript.CreateObject("WScript.Shell")
SetobjSpy = GetObject("", "XMLSpy.Application")
' Make the UI of XMLSpy visible.
objSpy.Visible = True
' Find out user's personal folder and locate one of the installed XMLSpy examples.
personalFolder = WshShell.ExpandEnvironmentStrings("%UserProfile%")
majorVersionYear = objSpy.MajorVersion + 1998
xmlspyExamplesFolder = personalFolder & "\Documents\Altova\XMLSpy" & majorVersionYear  & "\Examples\"
docPath = xmlspyExamplesFolder & "ExpReport.xml"
' Create object to access windows file system and test if the our document exists.
Setfso = CreateObject("Scripting.FileSystemObject")
Iffso.FileExists(docPath) Then
  ' open the document
  CallobjSpy.Documents.OpenFile(docPath, False)
  setobjDoc = objSpy.ActiveDocument
  ' switch active document to authentic view
  objDoc.SwitchViewMode 4 ' spyViewAuthentic
  ' Register for connection point events on the authentic view of the active document.
  ' Any function with a valid event name prefixed with "AuthenticViewEvent_" will
  ' be called when the corresponding event gets triggered on the specified object.
  setobjView = objDoc.AuthenticView
  CallWScript.ConnectObject(objView, "AuthenticViewEvent_")
  CallWScript.Echo("Events are connected." & vbNewLine & vbNewLine & "Now set or move the cursor in XMLSpy." & vbNewLine & vbNewLine & "Close this dialog to shut down XMLSpy.")
  ' To disconnect from the events delete the reference to the object.
  setobjView = Nothing
  CallWScript.Echo("The file " & docPath & " does not exist.")
' shut down XMLSpy when this script ends
objSpy.Visible = False


© 2017-2023 Altova GmbH