Lotusscript: pass by reference during assignments

HiI’ve a problem with some cashing functionality. I have a script that integrate relational data with a NotesView. Some of the columns has external dependecies to other tables. Values in these are cashed in a List object. When 2 columns are dependant upon the same table they should share cash, in other word contain references (pointer) to the same List object. But when I updates values in the List in one column, this is not updated in the list for the other column.

In some strange way objects must have been passrd by value during one of the assignments. Can this be when converting between Variants and List objects?

Some code:

Public Function mapColumns(view As Notesview) As Variant

	' This function go through all columns in view and creates a Column object for each describing them

	' If column title includes the string " external key from " values are stored in a external table and values needs to be translated to keys from this table

	' For these a ODBCResultSet pointing to external table are created in adition to a list containing all keys and values in table (for fast and easy access and translation

	Dim resultSets List As ODBCResultSet

	Dim externalKeyMaps List As Variant

	Dim columnMap List As Column

	Dim tmpColumn As Column

	Dim table As String

	Dim mapKey As String

	Dim mapValue As String

	Dim i As Integer

	

	Forall col In view.Columns

		Set tmpColumn = New Column			

		i =  Instr(Lcase(col.title), " external key from ")

		If i<>0Then

			' External value from other table

			tmpColumn.title = Left$(col.title,i-1)

			table = Trim(Right$(col.title,Len(col.title)-(i-1)-Len(" external key from ")))

			If Iselement(resultSets(table)) Then

				' Table has been used in prior column, pas references to prior objects

				Set tmpColumn.resultSet = resultSets(table)

				tmpColumn.externalKeyMap= externalKeyMaps(table)

			Else

				' Table has not been used before create resultset for table and cashed map of values 

				Set tmpColumn.resultSet = super.connectThroughODBC(table)

				Set resultSets(table) =  tmpColumn.resultSet

				Do 

					Dim tmpExternalKeyMap List As String

					tmpColumn.resultSet.nextrow

					mapKey = tmpColumn.resultSet.GetValue(2)

					mapValue = Cstr(tmpColumn.resultSet.GetValue(1))

					tmpExternalKeyMap(mapKey)= mapValue

				Loop  Until tmpColumn.resultSet.Isendofdata() 

				tmpColumn.externalKeyMap= tmpExternalKeyMap

				externalKeyMaps(table) = tmpColumn.externalKeyMap

			End If

			tmpColumn.isExternalKey = True

		Else

			tmpColumn.title = col.title

			tmpColumn.isExternalKey = False

		End If

		Set columnMap(Cstr(col.position))=tmpColumn

	End Forall

	mapColumns = columnMap

End Function

Public Class Column

' Class is just a bundle of properties for convenient storage in Lists. No methods

Public title As String

Public isExternalKey As Variant

Public resultSet As ODBCResultSet

Public externalKeyMap As Variant ' List As String  Map that caches all values in external table for easy access

End Class

Subject: lotusscript: pass by reference during assignments

well, but Lists are not objects (BTW when you assign objects you use “Set”). It’s like if you assign variable containing an array to another variable; you would not expect that they are linked in some way.

Subject: RE: lotusscript: pass by reference during assignments

So creating a object wraping the List, and refering to this would solve my problem?

Subject: RE: lotusscript: pass by reference during assignments

Sure. You would be referencing the exact same List variable (property).