Apache OpenOffice (AOO) Bugzilla – Issue 33807
For Each syntax to basic
Last modified: 2005-09-21 10:06:59 UTC
Add syntax 'For Each' to OO.o Basic: - Supports Arrays or Uno object that has the interface com.sun.star.container.XEnumeration.
Created attachment 17535 [details] Patch that add 'For Each' syntax to basic
patch for "foreach" for you Andreas
I first want to have a deeper look on the complete Collection subject that probably will be addressed in general before added new language features related to this. -> OOo later
It seens that someone applied a very modified patch for this issue in m76, but i couldn't find the branch in eis. Can someone tell me the status?
I've added "For each" in the scope of implementing the Collection object support. The original patch could not be used, because it did not support the Collection object of course. Besides that I was not completely happy with some code in this patch, e.g. the unnecessarily complex type conversion in nextElement() and the usage of XEnumeration (the object has to support XEnumerationAccess instead). But nevertheless, thanks for the effort and now "for...each" is supported by OOo Basic anyway. -> Resolved
I got a minor problem, in the code: Sub Main Dim vet(3) Dim var as boolean vet(1) = 1 vet(2) = 2 vet(3) = 3 for each var in vet MsgBox var next End Sub This code is invalid, because loop control variable must be variant type. Also the index of array begins in 0 and end in 3, so actually the array size is interpreted as 4 instead of 3.
In general I don't consider it as a severe problem if code runs that does not run in VB. Concerning the array size: It really is 4, the valid indices are 0, 1, 2, 3. That's just how the array is specified. -> Closed, if there are still problems please submit another issue
Target milestone is currently OOo Later However it is already available in 1.9.130 (probably also in older releases). Should the Target milestone be changed ? Please remember designers that without an updated documentation their work may never be used. I would like to see the on-line Help updated with examples. I could not find how to make it work on an enumeration.