Forum Discussion
Manfred_F
9 years agoRegular Contributor
You can do this.
I've Extended the facilities of aqObject.GetPropertyValue to accept constant arguments and also dots in the PropertyName string.
Here is my code example, maybe You can use it for orientation purposes.
It recursively navigates down the propertyname(arg1).SubProperty(arg2, arg3) ... tree to finally reach the desired Level.
What is missing is to wait at each Level for an appropriate time, if necessary.
Function GetPropertyValue( _
myObj, _
ByVal PropertyName, _
ByVal Routine _
)
' GetPropertyValue-Funktion, die auch untergeordnete Objekteigenschaften auswertet:
' PropertyName darf Punkte enthalten und einzelne Argumente
Const cRoutine = "GetPropertyValue"
Dim Ergebnis
Dim Pfad
Dim Ziel, ZielTxt, ArgAro
Dim TmpObj
Dim ErrLock
Dim Ts
' Set Ts = PVA_0.Debug.gCallInfo(mcModul & cRoutine).Activate(PropertyName, False, False)
Set mZielObj = Nothing
If Me.IsSupported(myObj, PropertyName, PVA_0.TcLog.CallInfo(mcModul, cRoutine, Routine)) Then
' Ts.Keep "IsSupported True "
Pfad = Split(PropertyName, ".")
' global, aus IsSupported
Set TmpObj = mZielObj
Set mZielObj = Nothing
Ziel = Pfad(uBound(Pfad))
ZielTxt = Ziel
Set ArgAro = ArgumentAro(Ziel)
If Util.ObjectIsSet(ArgAro) Then Ziel = ArgAro(0)
' kann trotzdem fehlschlagen
On Error Resume Next
Set ErrLock = PVA_0.TcLog.ErrorLock(PVA_0.TcLog.CallInfo(mcModul, cRoutine, Routine))
If ArgAro Is Nothing Then
Util.Zuweisen Ergebnis, aqObject.GetPropertyValue(TmpObj, Ziel)
'log.Warning "4" & Ergebnis, cRoutine
' JS Properties als Methoden implementiert, aufrufen
If Typename(Ergebnis) = "JScriptTypeInfo" Then
If instr(Ergebnis, "function(") = 1 Then
Util.Zuweisen Ergebnis, aqObject.CallMethod(TmpObj, Ziel)
End If
End If
' mit Argument
Else
Err.Clear
Util.Zuweisen Ergebnis, aqObject.GetPropertyValue(TmpObj, Ziel, ArgAro(1))
If Err.Number <> 0 Then
Err.Clear
Util.Zuweisen Ergebnis, aqObject.CallMethod(TmpObj, Ziel, ArgAro(1))
End If
End If
' Ts.Keep "Zugriff "
If Err.Number <> 0 And PVA_0.TcLog.Level(3) Then _
log.Warning "Fehler bei Zugriff auf " & PropertyName, Err.Description & vbCr & PVA_0.TcLog.CallInfo(mcModul, cRoutine, Routine)
ErrLock.Restore
On Error GoTo 0
' nicht gefunden
ElseIf PVA_0.TcLog.Level(3) Then
' Ts.Keep "IsSupported False "
Log.Warning "Methode nicht gefunden", "Name: " & PropertyName & vbCr & PVA_0.TcLog.CallInfo(mcModul, cRoutine, Routine)
End If
Util.Zuweisen GetPropertyValue, Ergebnis
' Ts.EndCall PropertyName
End Function