[Gambas-user] #11 and a bug in the editor

mike-nought at ...17... mike-nought at ...17...
Sun Aug 6 21:10:58 CEST 2006


Am Sonntag, 6. August 2006 20:07 schrieb Benoit Minisini:
> On Sunday 06 August 2006 07:49, mike-nought at ...17... wrote:
> > Hi Benoit, hi all.
> >
> > I am currently writing a quite large project (an ID3-Tagger) with the
> > development version and discovered Gambas not to behave as it should at
> > two points. Here is the function I wanted to use for merging several
> > objects (of the same type), keeping those values which are same and
> > resetting all others:
> >
> > PUBLIC FUNCTION merge(values AS Object[]) AS Object
> >
> >   DIM o AS Object
> >   DIM i AS Variant
> >   DIM x AS Boolean
> >   DIM result AS Object
> >   DIM t AS String
> >   DIM v1 AS Variant
> >   DIM v2 AS Variant
> >
> >   IF values.Count = 0 THEN RETURN NULL
> >   t = Object.Type(values[0])
> >
> >   ' (1) this SELECT CASE should be replacable with result=New(t)
> >   SELECT CASE t
> >     CASE "CMPEGHeader"
> >       result = NEW CMPEGHeader
> >     CASE "CTag"
> >       result = NEW CTag
> >     CASE "CTagv1"
> >       result = NEW CTagv1
> >     CASE "CTagv2"
> >       result = NEW CTagv2
> >   END SELECT
> >
> >   FOR EACH i IN Classes[t].Symbols
> >     FOR EACH o IN values
> >       IF NOT x THEN
> >         TRY Object.SetProperty(result, i, Object.GetProperty(o, i))
> >         x = TRUE
> >       ELSE
> >         v1 = NULL
> >         v2 = NULL
> >         TRY v1 = Object.GetProperty(result, i)
> >         TRY v2 = Object.GetProperty(o, i)
> >         IF NOT (v1 = v2) THEN
> >           TRY Object.SetProperty(result, i, "")
> >         END IF
> >       END IF
> >     NEXT ' (2) interpreter jumps here after RETURN
> >     x = FALSE
> >   NEXT
> >
> >   RETURN result
> >
> > END
> >
> > I marked the location of both bugs(?) with (1) and (2).
> >
> > (1): Here a new instance of the type of the passed objects should be
> > created, which was formerly possible through result=New(t) in this case.
> > But now this doesn't work anymore, because the editor replaces New([...])
> > with NEW ([...]) which I cannot use here.
>
> I get it :-) This is not a bug, just the way the editor rewrites your code.
> But it works!
>
> The rule is that if there are brackets after NEW or New (Gambas language is
> not case sensitive), then the class name is dynamic. Otherwise it is
> static.
>
> Regards,

Yeah, sorry for the double-mail, I recognized this just now as well :/.
Perhaps the documentation should be altered, to comply with the code-changes 
the editor makes?

Any news about the #11-bug?

Regards,
Franz




More information about the User mailing list