FOR EACH ... ENDFOR Command

Executes a set of commands for each element in a Visual FoxPro array or collection.

FOR EACH Var [AS Type [OF Class Library]] IN Group [FOXOBJECT]
      Commands
   [EXIT]
   [LOOP]
ENDFOR | NEXT [Var]

Parameters

Var

A variable or array element used to iterate through the elements of Group.

Type

A base class, class name, or type library. (For Intellisense only)

Class Library

Class library containing the base class, class name, or type library specified with Type. (For Intellisense only)

Group

A Visual FoxPro array, an OLE array, a Visual FoxPro collection, or an OLE collection.

FOXOBJECT

Specifies that the variable or array element Var will contain only native (not COM) Visual FoxPro objects.

Commands

Specifies the Visual FoxPro commands to be executed for each element in Group. Commands can include any number of commands.

EXIT

Transfers control from within the FOR EACH ... ENDFOR loop to the command immediately following ENDFOR. You can place EXIT anywhere between FOR EACH and ENDFOR.

LOOP

Returns control directly back to the FOR EACH clause without executing the statements between LOOP and ENDFOR. LOOP can be placed anywhere between FOR EACH and ENDFOR.

Expand imageExamples

Expand imageSee Also


© , 1996-2020 • Updated: 11/10/20
Comment or report problem with topic