Alaska Software Inc. - "For Each" syntax in xbase
Username: Password:
AuthorTopic: "For Each" syntax in xbase
Pascal Boivin"For Each" syntax in xbase
on Fri, 16 Jan 2009 13:47:05 -0500
Hi

What is the xbase equivalent for "For Each Item In Collection"?

--- Visual Basic ---
Dim oObject As Something.Object
Dim oResult As Something.Result

  Set oObject = New Something.Object
  Call oObject.DoSomething
  For Each oResult In oObject.Results
    Call oResult.xxx
  Next

--- XBase ---
Local oObject, oResult

  oObject = CreateObject("Something.Object")
  oObject:DoSomething()
  For ???    
    oResult:xxx()
  Next

************************
* Pascal Boivin        *
* N.B. Automation inc. *
************************
AUGE_OHRRe: "For Each" syntax in xbase
on Fri, 16 Jan 2009 21:42:40 +0100
Hi,

> What is the xbase equivalent for "For Each Item In Collection"?
>
>  For Each oResult In oObject.Results
>    Call oResult.xxx
>  Next

a activeX (Image) Collection is a Array. it shoud have a Methode
:Count() so you can use a "normal" FOR/NEXT.

btw: what for you use a Collection ?

greetings by OHR
Jimmy
Ott HavasvlgyiRe: "For Each" syntax in xbase
on Fri, 16 Jan 2009 21:53:33 +0100
Hi,

I think AEval() , provided the collection is an array.
But it was be good if there was a syntax for this like in VB, because it is
cleaner, and local variables are visible inside the block.
BTW what is the type of oObject.Results?

Best regards,
Otto


"Pascal Boivin" <pascal.boivin@nbautomation.com> az albbiakat rta a
kvetkezo zenetben news:xn0g58h5ucdwq0000@xpd300...
> Hi
>
> What is the xbase equivalent for "For Each Item In Collection"?
>
> --- Visual Basic ---
> Dim oObject As Something.Object
> Dim oResult As Something.Result
>
>   Set oObject = New Something.Object
>   Call oObject.DoSomething
>   For Each oResult In oObject.Results
>     Call oResult.xxx
>   Next
>
> --- XBase ---
> Local oObject, oResult
>
>   oObject = CreateObject("Something.Object")
>   oObject:DoSomething()
>   For ???
>     oResult:xxx()
>   Next
>
> -- 
> ************************
>  Pascal Boivin        
> * N.B. Automation inc. *
> ************************
Pascal BoivinRe: "For Each" syntax in xbase
on Fri, 16 Jan 2009 16:56:05 -0500
Ottó Havasvölgyi wrote:

> Hi,
> 
> I think AEval() , provided the collection is an array.
> But it was be good if there was a syntax for this like in VB, because
> it is cleaner, and local variables are visible inside the block.
> BTW what is the type of oObject.Results?
> 

I have documents that contains drawings that contains objects that
contains points!  All of those are class derived from "Collection"
class.

  oDoc.LoadFile(sFile & ".AGI")  
  For Each oDraw In oDoc.Drawings
    For Each oObj In oDraw.Objects
      For Each oPoint In oObj.Points

After some search, I've discovered every collection look like these:

Class Collection
  Var Count
  METHOD Item
...

Method Collection:Item(nItem)
RETURN ::InternalArray(nItem)

Visual Basic automatically use the "Item" and "Count" properties when
using a "For Each" statement.  So with Xbase I will have to do
something like this:

  aItem = oDoc:Results
  nItemMax := aItem:Count()
  For nItem := 1 To nItemMax
    oItem := aItem:Item(nItem)  

I will try this next monday!  Have a nice weekend!

************************
* Pascal Boivin        *
* N.B. Automation inc. *
************************