« il: 15 Agosto 2013, 17:37:56 »
Vi riporto questa discussione apparsa nella Mailing List internazionale relativa ad una implementazione apportata con le revisioni #5797 e #5798:
"
Hi Benoit,
what bothers me from time to time is that With is *so* handy but can't be
used to access Array or Collection elements like: With hCollection ' or hArray
Print ["key"] ' or Print [0]
End With
I see that this would be a syntactical problem because ["key"] and
equivalently well be recognised as inline arrays. But we have another
option, right? There is still the ! operator which is unambiguous: With hCollection
Print !key
End With
Should be no problem if implemented. What do you think? And while we are at it,
couldn't the ! operator at the same time get the capability to support integers,
so that the above will also work with an array: With hArray
Print !0
End With
Regards,
Tobi "
"
The '!' can't be used, because a!b is just syntactic sugar for a["b"].
Maybe a syntax like .[ x ] = y could be used, as at the moment .[ x ] is a
syntax error... I will think about it. "
"
This is implemented in revision #5797:Dim aStr As New String[2]
With aStr
.[0] = "a"
.[1] = "b"
Print .[0];; .[1]
End With
Enjoy!
--
Benoît Minisini "
"
Nice! Works also with Collection-like objects. The only thing I noticed was
that it's not very comfortable to type in the IDE, i.e. once you are in the
With clause and type ".", you will presented the list of symbols in the
auto-completion popup. If you press "[", the first thing in there is
inserted before the "[".
Anyway, this is very great!
Thanks,
Tobi "
"
Yep, the IDE is not yet aware of that new syntax...
In revision #5798, I implemented the same thing for the "!" operator.With < some Result object or Collection >
!field1 = "foo"
!field2 = "bar"
End With
Regards,
--
Benoît Minisini "
"
Yes, everything works perfectly. The IDE now, too. Thank you very much.
Regards,
Tobi "
« Ultima modifica: 16 Agosto 2013, 09:53:58 da vuott »
Registrato
« Chiunque, non ricorrendo lo stato di necessità, nel proprio progetto Gambas fa uso delle istruzioni Shell o Exec, è punito con la sanzione pecuniaria da euro 20,00 a euro 60,00. »