Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
For Each ....
Message
From
22/05/2004 03:16:05
Neil Mc Donald
Cencom Systems P/L
The Sun, Australia
 
 
To
22/05/2004 01:54:17
Suhas Hegde
Dental Surgeon
Sirsi, India
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Miscellaneous
Thread ID:
00906200
Message ID:
00906203
Views:
14
Hi,
I am not quite sure what you mean by "interchangeable" an example of what you trying to achieve would help, but possibly the LOOP command is what you are looking for, I have listed the help below regarding this.

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.

I have also listed the VFP8 help example which may help.

In the following example, five command buttons are placed on a form. FOR EACH is used to display the buttons on the form and specify the captions, font styles and positions of each button.

PUBLIC oMyObject
oMyObject = CREATEOBJECT("frmTest")
oMyObject.SHOW

DEFINE CLASS frmTest AS FORM
Height = 200
DIMENSION MyArray[5]
PROCEDURE Init

FOR i = 1 to 5
THIS.AddObject('THIS.MyArray[i]',;
'COMMANDBUTTON')
ENDFOR

****** FOR EACH - NEXT ******
FOR EACH oButton IN THIS.MyArray
oButton.Visible = .T.
NEXT

****** FOR EACH - NEXT element ******
FOR EACH oButton IN THIS.MyArray
oButton.FontBold = .T.
NEXT obutton

j = 1
****** FOR EACH - ENDFOR ******
FOR EACH oButton IN THIS.MyArray
oButton.top = j * 30
j = j + 1
ENDFOR

****** FOR EACH - ENDFOR element ******
FOR EACH oButton IN THIS.MyArray
oButton.FontItalic = .T.
ENDFOR obutton

j = 1
****** EXIT ******
FOR EACH oButton IN THIS.MyArray
oButton.Caption = "test" + str(j)
j = j+1
IF j > 3
EXIT
ENDIF
NEXT

j = 1
****** LOOP ******
FOR EACH oButton IN THIS.MyArray
IF j > 3
LOOP
ENDIF
j = j + 1
oButton.Left = 25
NEXT
ENDPROC
ENDDEFINE


>hello all,
>I am unable to understand the following
>
>
>For each ..
>endfor | next | var
>
>
>can "endfor" or "next" or "next var" be used interchangable ? Can someone please tell ?
>
>Suhas
Regards N Mc Donald
Previous
Reply
Map
View

Click here to load this message in the networking platform