Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
The FOR EACH loop
Message
From
11/04/2001 00:34:34
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00494274
Message ID:
00494291
Views:
17
>Can someone, help me understand the for each command, (I think I am reading to much into it)



You may be. The command applies only to arrays and collections (which are basically arrays of objects)

Every form has a collection of controls which are contained in the form. You can create a loop that cycles through all of them like this:
FOR EACH oobj IN THISFORM.controls

   IF vartype(oobj.enabled)<>"U"     && not all controls have enabled property
        [Do something with it]
   ENDIF

ENDFOR
A useful method supported by FORMS is the SetAll method. Look up SetAll
in your VFP online help and play around with it a little. Look at the examples in the help and notice which types of controls support SetAll. It's a pretty useful initialization tool to use in the Init method of your form.

You can also use FOR EACH to cycle through arrays.
local a(5)
a(1)='10'
a(2)='Eleven'
a(3)='12welve'
a(4)='thoideen'
a(5)='quinze'

for each cchar in a
   ? cchar
endfor
Hope this helps
"The Iron Fish: The water is cold...but the fish don't mind"
...Jay Jenks, boyhood chum
Previous
Reply
Map
View

Click here to load this message in the networking platform