Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

&<img src="../resources/images/opentocr.png" title="Open Contents list" border="0"&>
You are here: Anchor_Toc23491766_Toc23491766 .NET Collections
.NET Collections can accessed using the following methods:

Visual LANSA For statement

     Define Field(#LNum6501) Type(*INT)
Define Field(#LStr6501) Type(*STRING) Length(20)
Define Field(#LBol6501) Type(*BOOLEAN)
 
Define_Com Class(#DNE003_SystemDll.System.Collections.Specialized.StringCollection) Name(#LCls6501_Coll) Reference(*DYNAMIC)
 
#LCls6501_Coll <= *New #DNE003_SystemDll.System.Collections.Specialized.StringCollection
 
#LStr6501 := 'Test'
#LCls6501_Coll.Add( 'Test1' )
#LCls6501_Coll.Add( 'Test2' )
#LCls6501_Coll.Add( 'Test3' )
 
#LNum6501 := 0
#LBol6501 := true
For Each(#Current) In(#LCls6501_Coll)
#LNum6501 += 1
If (#Current <> (#LStr6501 + #LNum6501.AsString))
#LBol6501 := false
Endif
Endfor

...

.NET indexer (commonly represented by the Item property)

     Define Field(#LNum6601) Type(*INT)
Define Field(#LStr6601) Type(*STRING) Length(20)
Define Field(#LBol6601) Type(*BOOLEAN)
 
Define_Com Class(#DNE003_SystemDll.System.Collections.Specialized.StringCollection) Name(#LCls6601_Coll) Reference(*DYNAMIC)
 
#LCls6601_Coll <= *New #DNE003_SystemDll.System.Collections.Specialized.StringCollection
 
#LStr6601 := 'Test'
#LCls6601_Coll.Add( 'Test0' )
#LCls6601_Coll.Add( 'Test1' )
#LCls6601_Coll.Add( 'Test2' )
 
* ++++++++++++++++++++++++++++++++++++

...

     * A string collection - GET

...


#LBol6601 := False

...


If (#LCls6601_Coll.Item\[2\] = "Test2")

...


#LBol6601 := True

...


Else
#LBol6601 := False

...


Endif

* ++++++++++++++++++++++++++++++++++++

...

     * A string collection - SET

...

 

#LCls6601_Coll.Item\[0\] := 'NewValue0'

...


#LCls6601_Coll.Item\[1\] := 'NewValue1'

...


#LCls6601_Coll.Item\[2\] := 'NewValue2'

...


If (#LCls6601_Coll.Item\[1\] = 'NewValue1')

...


#LBol6601 := True

...


Else
#LBol6601 := False

...


Endif

.NET enumerator

     Define Field(#LNum6401) Type(*INT)

...


Define Field(#LNum6402) Type(*INT)

...


Define Field(#LStr6401) Type(*STRING) Length(20)

...


Define Field(#LBol6401) Type(*BOOLEAN)

...



Define_Com Class(#DNE003_SystemDll.System.Collections.Specialized.StringCollection) Name(#LClass6401_Coll) Reference(*DYNAMIC)

...


Define_Com Class(#DNE003_SystemDll.System.Collections.Specialized.StringEnumerator) Name(#LClass6402_Enum) Reference(*DYNAMIC)

...



#LClass6401_Coll <= *New #DNE003_SystemDll.System.Collections.Specialized.StringCollection

...



#LStr6401 := 'Test'

...


#LClass6401_Coll.Add( 'Test1' )

...


#LClass6401_Coll.Add( 'Test2' )

...


#LClass6401_Coll.Add( 'Test3' )

...



* ++++++++++++++++++++++++++++++++++++
* Use Enumerator
 
#LClass6402_Enum <= #LClass6401_Coll.GetEnumerator()
#LNum6401 := 0
#LBol6401 := true
#LClass6402_Enum.Reset()
Dowhile Cond(#LClass6402_Enum.MoveNext())
#LNum6401 += 1
If (#LClass6402_Enum.Current <> (#LStr6401 + #LNum6401.AsString))
#LBol6401 := false
Endif
Endwhile
 
If (#LBol6401)
#STD_TEXT := 'Success'
Else
#STD_TEXT := 'Failed'

...

     Endif