Hi,
ich erzeuge in einer LotusScript Klasse einen Array eines Types. Wie kann ich auf diesen Array mit einer Function (oder Property) der Klasse zugreifen?
Es geht wenn ich direkt auf den Member der Klasse zugreife, in dem der ArrayType gespeichert ist.
Beispielcode als Agent:
Options:
| Option Public |
| %INCLUDE "lsconst.lss" |
declarations:
| Public Type Foo |
| theValue As String |
| End Type |
| |
| Public Class MyClass |
| |
| Public result() As Foo |
| |
| |
| Sub new |
| Redim Preserve result(0) |
| Dim tempFoo As Foo |
| tempFoo.theValue = "aaa" |
| result(0) = tempFoo |
| |
| Redim Preserve result(1) |
| Dim tempFoo2 As Foo |
| tempFoo2.theValue = "bbb" |
| result(1) = tempFoo2 |
| |
| Redim Preserve result(2) |
| Dim tempFoo3 As Foo |
| tempFoo3.theValue = "ccc" |
| result(2) = tempFoo3 |
| |
| |
| End Sub |
| |
| Public Function getFoo As Variant |
| 'getFoo = result |
| End Function |
| |
| Public Property Get resultOut As Variant |
| 'resultOut = result() |
| End Property |
| |
| End Class |
initialize:
| Sub Initialize |
| Dim anObject As New MyClass() |
| |
| Dim strResult As String |
| strResult = "" |
| For i = 0 To Ubound(anObject.result) |
| strResult = strResult & |anObject.result(| & Cstr(i) & |)=[theValue="| & anObject.result(i).theValue & |"]|& Chr$(13) & Chr$(10) |
| Next |
| Msgbox strResult, MB_ICONINFORMATION, "result" |
| End Sub |
Die Klasse MyClass speichert einen Array vom Type Foo in die Instanzvariable result(). Wie in Initialize oben zu sehen ist, kann ich von aussen auf die Instanzvariable zugreifen, sofern ich sie public deklariere. Aber wie schreibe ich in der Klasse eine Methode, die dieses Datenkonstrukt zurückgibt?