[Gambas-user] drove me crazy

Dimitris Anogiatis dosida at ...626...
Wed Jan 20 21:01:27 CET 2010


Charlie, Benoit,

Wouldn't something like that usually work?

PUBLIC SUB Main()
DIM col1 AS NEW Collection
DIM col2 AS NEW Collection
DIM sKey AS String
Dim Counter as Integer
 col1.Add("1", "one")
 col1.Add("2", "two")
 col1.Add("3", "three")
 col1.Add("4", "four")
 PRINT "Returns the key of the last read or last enumerated element. "
  FOR Counter = 0 to col1.Count
     sKey = col1[Counter].Key
     PRINT sKey & " = " & sElem
     col2.Add(sElem, sKey)
  NEXT
END

The documentation mentions that a Collection acts like a read/write array
so even though the workaround isn't very elegant, would it work?

Regards,
Dimitris

On Wed, Jan 20, 2010 at 11:17 AM, Charlie Reinl <Karl.Reinl at ...9...>wrote:

> Am Mittwoch, den 20.01.2010, 17:27 +0100 schrieb Benoît Minisini:
> > > Am Dienstag, den 19.01.2010, 17:30 -0700 schrieb Dimitris Anogiatis:
> > > > Hey Charlie,
> > > >
> > > > Try changing this line
> > > >
> > > >      sKey = col1.Key
> > > >
> > > > to
> > > >
> > > >      sKey = sElem.Key
> > > >
> > > >
> > > > Hope this helps
> > > >
> > > > Regards,
> > > > Dimitris
> > > >
> > > > On Tue, Jan 19, 2010 at 4:09 PM, Charlie Reinl <Karl.Reinl at ...2364.....
> > net.de>wrote:
> > > > > Salut Benoit,
> > > > >
> > > > > its about Collection KEY and Debug-Window on gambas2.
> > > > >
> > > > > If you run that project, and open col1 and col2 in a Debug-Window
> > > > > (DBl-Click on the var), the Collection Key is always the last
> > > > > enumerated element.
> > > > >
> > > > > If you run it without Debug-Window or only col2 in a Debug-Window ,
> the
> > > > > Collection Key is the last read.
> > > > >
> > > > > PUBLIC SUB Main()
> > > > > DIM col1 AS NEW Collection
> > > > > DIM col2 AS NEW Collection
> > > > > DIM sElem AS String
> > > > > DIM sKey AS String
> > > > >  col1.Add("1", "one")
> > > > >  col1.Add("2", "two")
> > > > >  col1.Add("3", "three")
> > > > >  col1.Add("4", "four")
> > > > >  PRINT "Returns the key of the last read or last enumerated
> element. "
> > > > >   FOR EACH sElem IN col1
> > > > >      sKey = col1.Key
> > > > >      PRINT sKey & " = " & sElem
> > > > >      col2.Add(sElem, sKey)
> > > > >   NEXT
> > > > > END
> > > > >
> > > > > see attached project.
> > > > > --
> > > > > Amicalement
> > > > > Charlie
> > > > >
> > > > > [OperatingSystem]
> > > > > OperatingSystem=Linux
> > > > > KernelRelease=2.6.24-26-generic
> > > > > DistributionVendor=ubuntu
> > > > > DistributionRelease="Ubuntu 8.04.3 LTS"
> > > > >
> > > > > [System]
> > > > > CPUArchitecture=i686
> > > > > TotalRam=506932 kB
> > > > >
> > > > > [Gambas]
> > > > > Gambas1=gbx-1.0.17
> > > > > Gambas1Path=/usr/bin/gbx
> > > > >
> > > > > Gambas2=2.19.0                  rev.2613
> > > > > Gambas2Path=/usr/local/bin/gbx2
> > > > >
> > > > > Gambas3=2.99.0                  rev.2602 (can't compile actually)
> > > > > Gambas3Path=/usr/local/bin/gbx3
> > >
> > > Salut Dimitris,
> > >
> > > no can't work like that , sElem is 'only' a String.
> > >
> > > It is like written in the doc,
> > > "Returns the key of the last read or last enumerated element."
> > > The  problem is, I think, that the Debug-Window loops the collection,
> > > (every time I move in the collection), to refresh all members, so when
> I
> > > try to set the 'sKey = col1.Key' the last element was read and its KEY
> > > returned.
> > > The Watch-Window shows the right value. But also the col1 collection in
> > > the Watch-Window 'derange' to find the right col1.key
> > >
> >
> > Yes, that is exactly the problem. But I don't see any good fix for Gambas
> 2 at
> > the moment. For Gambas 3, I can change the behaviour of Collection.Key so
> that
> > it returns the last enumerated element, not the last read one (the
> debugger
> > does not enumerate the collection, it just read it).
> >
> > Regards,
> >
>
> Salut Benoit,
>
> I'v looked in the IDE. I also don't see where we can stop/arrange that.
> So I think we should add a warning , to the documentation!
>
>
> --
> Amicalement
> Charlie
>
>
>
> ------------------------------------------------------------------------------
> Throughout its 18-year history, RSA Conference consistently attracts the
> world's best and brightest in the field, creating opportunities for
> Conference
> attendees to learn about information security's most important issues
> through
> interactions with peers, luminaries and emerging and established companies.
> http://p.sf.net/sfu/rsaconf-dev2dev
> _______________________________________________
> Gambas-user mailing list
> Gambas-user at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user
>



More information about the User mailing list