Short syntax for collection data-type?...

Post

Posted
Rating:
#1 (In Topic #1396)
Regular
chrisRoald is in the usergroup ‘Regular’
Hi folks, and HNY!
     Just a quick question re. populating a collection array…
Is there a shortcut collection syntax that can reduce these lines of code to just two, which would each add a collection (processX) to my collection array (processes[])

Code (gambas)

  1.     Dim processes As New Collection[]
  2.     Dim processX As New Collection
  3.  
  4.             processX.add(fileTypes, "%ClearEntries")
  5.             processes.Add(processX.Copy())
  6.             processX.Clear()
  7.             processX.add(fileTypes, "%AddEntries")
  8.             processes.Add(processX.Copy())
  9.  

i was half hoping that I could use:-  

Code (gambas)

  1.            processes.Add(new collection.Add(fileTypes, "%AddEntries"))
  2.  
but the compiler 'voids' this   :?

Is my first example the shortest way to do this, or is there another 'collection' syntax?

Thanks in advance,
C.
Online now: No Back to the top

Post

Posted
Rating:
#2
Guru
BruceSteers is in the usergroup ‘Guru’
You mean like this?

Code (gambas)

  1. cCol = ["Keyname1": variant1, "keyname2": variant2]
  2.  

That is the one line syntax for creating a collection.

Not sure about further additions though.
Online now: No Back to the top

Post

Posted
Rating:
#3
Regular
chrisRoald is in the usergroup ‘Regular’
Thanks Bruce,
    That is a lot tidier and easy to follow :)
 

Code (gambas)

  1.            dim processes as collection[]
  2.             processes.add( ["%ClearEntries": fileTypes] )
  3.             processes.Add( ["%AddEntries" : fileTypes] )
  4.             processes.add( ["nextEntry" : value] )
  5.             processes.add( ["nextEntry2" : value] )
  6.  
Cheers,
C.
Online now: No Back to the top

Post

Posted
Rating:
#4
Guru
BruceSteers is in the usergroup ‘Guru’
even this…

Code (gambas)

  1. dim processes as collection[]
  2.  processes = [["%ClearEntries": fileTypes],
  3.               ["%AddEntries": fileTypes],
  4.               ["nextEntry": value],
  5.               ["nextEntry2": value]]
  6.  
Online now: No Back to the top
1 guest and 0 members have just viewed this.