#129277 - 2004-11-11 09:17 AM
Break the For!
|
wolfteeth
Fresh Scripter
Registered: 2004-03-22
Posts: 15
|
Could anybody tell me what's function can break to the up level of For... For example For $I=2 to 464 For $J=2 to 453 If $VS=$VY Do something Return EndIF Next Next
|
|
Top
|
|
|
|
#129279 - 2004-11-11 11:12 AM
Re: Break the For!
|
wolfteeth
Fresh Scripter
Registered: 2004-03-22
Posts: 15
|
It seems can't work. please re check the below code for you reference. for the code I just want to quit the J FOR when VS=VY. Code:
;debug on break on
$oXL = CreateObject("EXCEL.application") $oYL = CreateObject("EXCEL.application")
If @error = 0 $VS = "" $VY = "" $oXL.Visible = 1 $RFP = $oXL.Workbooks.Open("C:\Temp\01.xls") $RFD = $oYL.Workbooks.Open("C:\Temp\02.xls") test ;$oXL.UserControl = 1 Else Showmessage(@error + " / " @serror) EndIf ;$oXL.quit
Function test For $I=2 to 464 For $J=2 to 453 $VS = $oXL.Cells($I,3).Value $VY = $oYL.Cells($J,1).Value If $VS=$VY $oXL.Cells($I,6).Value=$oYL.Cells($J,4).Value $oXL.Cells($I,4).Value=$oYL.Cells($J,2).Value exit 0 EndIF Next Next EndFunction
Function ShowMessage($Message) MessageBox($Message,"Attention!",4160) EndFunction
|
|
Top
|
|
|
|
#129281 - 2004-11-11 11:57 AM
Re: Break the For!
|
wolfteeth
Fresh Scripter
Registered: 2004-03-22
Posts: 15
|
I dislike GO or GOsub...should you give me hand? thanks.
|
|
Top
|
|
|
|
#129285 - 2004-11-11 02:24 PM
Re: Break the For!
|
Shawn
Administrator
   
Registered: 1999-08-13
Posts: 8611
|
Another thing we've (I) have done in past (long, long ago), is to artificially inflate the values of the variables, like this:
Code:
break on
dim $i, $j
for $i = 0 to 10
for $j = 0 to 10
if $i = 5 and $j = 5
$i = 10 $j = 10
endif
next
next
Although "structured", think this is bad form too imho.
|
|
Top
|
|
|
|
#129292 - 2004-11-11 02:59 PM
Re: Break the For!
|
Jochen
KiX Supporter
   
Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
|
|
|
Top
|
|
|
|
#129296 - 2004-11-12 03:42 AM
Re: Break the For!
|
wolfteeth
Fresh Scripter
Registered: 2004-03-22
Posts: 15
|
Yep. That's one is very very very very good , I was trapped for the "Return" or "Continue" or "Break". Genius. thanks so much.
|
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 837 anonymous users online.
|
|
|