Autor Thema: [LS]: Auf einen Type-Array mit einer Class-Funktion o. Property zugreifen  (Gelesen 1666 mal)

Offline flaite

  • Gold Platin u.s.w. member:)
  • *****
  • Beiträge: 2.966
    • mein del.icio.us
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:
Code
Option Public
%INCLUDE "lsconst.lss"

declarations:
Code
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:
Code
Sub Initialize
	Dim anObject As New MyClass()
	' instance variable access works
	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?
Ich stimm nicht mit allen überein, aber mit vielen und sowieso unterhaltsam -> https://www.youtube.com/channel/UCr9qCdqXLm2SU0BIs6d_68Q

---

Aquí no se respeta ni la ley de la selva.
(Hier respektiert man nicht einmal das Gesetz des Dschungels)

Nicanor Parra, San Fabian, Región del Bio Bio, República de Chile

 

Impressum Atnotes.de  -  Powered by Syslords Solutions  -  Datenschutz