Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Exit nested FOR loops
Message
From
27/07/2007 13:33:27
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivia
 
 
To
27/07/2007 10:36:49
Jay Johengen
Altamahaw-Ossipee, North Carolina, United States
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
01244106
Message ID:
01244175
Views:
18
An EXIT will exit the inner loop. You need another EXIT to exit the outer loop. What I usually do to exit multiple loops is to set a variable, in the inner loop, that can be tested in the outer loop.

>When the VALID comes back .F. in this button:
>
>
>			@ 7,2 GET cmd_Next_Open ;
>				FUNCTION '*NH Add Appointment;Next Open;Cancel' ;
>				SIZE but_height, 8 ;
>				VALID v_cmd_Next_Open( cmd_Next_Open )
>
>
>I want to get out of all the FOR loops. Thanks!
>
>
>FOR yy = 1 TO max_room
>	FOR xx = 1 TO n_lines
>
>		IF xx + show_from - 1 <= max_slots
>			slot_val = VAL(slot_per_room( xx + show_from - 1, yy ))
>		ELSE
>			slot_val = 0
>		ENDIF
>
>
>* JJ - TESTING ONLY
>* disp_date = {^2007/07/27}
>m.TestTime = SUBSTR(TTOC(CTOT(TIME()) - 36000),12,8)
>
>
>		IF slot_val = 1 AND disp_date >= DATE() AND RIGHT( "0" + ALLTRIM( slot_time( xx + show_from + 1 ) ), 5 ) > LEFT( m.TestTime, 5 )
>
>			WAIT WINDOW "Next slot: " + 'Room ' + ALLTRIM(STR(yy)) + ' - ' + 'Line ' + ALLTRIM(STR(xx)) + ' : ' + ALLTRIM(STR(x_room( xx, yy ))) + ' / ' + ALLTRIM(STR(slot_val))
>
>			DEFINE WINDOW sch_Next_Open ;
>				FROM 0,0 TO 20,60 ;
>				&win_style ;
>				FLOAT ;
>				TITLE " Next Open Appointment " ;
>				FONT fonname, fonsize
>			MOVE WINDOW sch_Next_Open CENTER
>
>			ACTIVATE WINDOW sch_Next_Open
>
>			IF !EMPTY( m_disp_date )
>				STORE m_disp_date TO disp_date
>			ELSE
>				STORE DATE() TO disp_date
>			ENDIF
>
>			old_date = disp_date
>			m.NewDateValue = old_date
>
>			@ 3,2 SAY 'Date: ' + ALLTRIM( DTOC( disp_date ) ) + 'Time: ' + RIGHT( "0" + ALLTRIM( slot_time( xx + show_from + 1 ) ), 5 )
>
>			@ 7,2 GET cmd_Next_Open ;
>				FUNCTION '*NH Add Appointment;Next Open;Cancel' ;
>				SIZE but_height, 8 ;
>				VALID v_cmd_Next_Open( cmd_Next_Open )
>
>			READ CYCLE MODAL
>
>		ENDIF
>	ENDFOR
>ENDFOR
>
>* Want to end up here if .F. was returned from VALID
>
>
Difference in opinions hath cost many millions of lives: for instance, whether flesh be bread, or bread be flesh; whether whistling be a vice or a virtue; whether it be better to kiss a post, or throw it into the fire... (from Gulliver's Travels)
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform