Saturday, October 25, 2008

For Next iterations Similar to the 'continue' keyword of C and

Hi all,Is there any 'trick' anyone knows to control a For Next to pass to the nextiteration in ASP VBScript? ..Similar to the 'continue' keyword of C andC++?Thanks in advance..-BB
10 Answers Posted

Brian Burgess
Guest
n/a Posts
July 19th, 200506:05 AM #2
Re: For Next iterations
Ah cool. That points me in the right direction...Kinda makes me feel stupid .. but it works .. :-Pthanks-BB"Evertjan." wrote in messagenews:Xns93C759FC8ED8Ceejj99@194.109.133.29...[color=blue]> Brian Burgess wrote on 29 jul 2003 in> microsoft.public.inetserver.asp.general:>[color=green]> > Is there any 'trick' anyone knows to control a For Next to pass to the> > next iteration in ASP VBScript? ..Similar to the 'continue' keyword> > of C and C++?> >[/color]>> For i=1 to 100> continue=false> ' do things> if i=17 then continue=true> if not continue then> ' do things> end if> Next>> can be done simpler.>> --> Evertjan.> The Netherlands.> (Please change the x'es to dots in my emailaddress)[/color]

Brian Burgess
Guest
n/a Posts
July 19th, 200506:05 AM #3
Re: For Next iterations
Hey I got a cool way from Walter Zackery/Michael Harris in the VBScriptgroup...For Count = 1 to 5DoIf Count = 3 Then Exit DoMsgBox CountExit Do:LoopNextCool eh? a Do Loop wrapper ..-BB"Brian Burgess" wrote in messagenews:uj6AYAaVDHA.1480@tk2msftngp13.phx.gbl...[color=blue]> Ah cool. That points me in the right direction...>> Kinda makes me feel stupid .. but it works .. :-P>> thanks>> -BB>>> "Evertjan." wrote in message> news:Xns93C759FC8ED8Ceejj99@194.109.133.29...[color=green]> > Brian Burgess wrote on 29 jul 2003 in> > microsoft.public.inetserver.asp.general:> >[color=darkred]> > > Is there any 'trick' anyone knows to control a For Next to pass to the> > > next iteration in ASP VBScript? ..Similar to the 'continue' keyword> > > of C and C++?> > >[/color]> >> > For i=1 to 100> > continue=false> > ' do things> > if i=17 then continue=true> > if not continue then> > ' do things> > end if> > Next> >> > can be done simpler.> >> > --> > Evertjan.> > The Netherlands.> > (Please change the x'es to dots in my emailaddress)[/color]>>[/color]

Tom B
Guest
n/a Posts
July 19th, 200506:05 AM #4
Re: For Next iterations
I'm sure I don't see the point. The following does exactly the same thing,is easier to read and understand by others and is logical.For Count = 1 to 5If count <> 3 then'blah blah blah -- can't use a Msgbox in ASP/VBScriptend ifNext"Brian Burgess" wrote in messagenews:%238110HgVDHA.2544@tk2msftngp13.phx.gbl...[color=blue]> Hey I got a cool way from Walter Zackery/Michael Harris in the VBScript> group...>> For Count = 1 to 5> Do> If Count = 3 Then Exit Do> MsgBox Count> Exit Do:Loop> Next>> Cool eh? a Do Loop wrapper ..>> -BB>>> "Brian Burgess" wrote in message> news:uj6AYAaVDHA.1480@tk2msftngp13.phx.gbl...[color=green]> > Ah cool. That points me in the right direction...> >> > Kinda makes me feel stupid .. but it works .. :-P> >> > thanks> >> > -BB> >> >> > "Evertjan." wrote in message> > news:Xns93C759FC8ED8Ceejj99@194.109.133.29...[color=darkred]> > > Brian Burgess wrote on 29 jul 2003 in> > > microsoft.public.inetserver.asp.general:> > >> > > > Is there any 'trick' anyone knows to control a For Next to pass to[/color][/color][/color]the[color=blue][color=green][color=darkred]> > > > next iteration in ASP VBScript? ..Similar to the 'continue'[/color][/color][/color]keyword[color=blue][color=green][color=darkred]> > > > of C and C++?> > > >> > >> > > For i=1 to 100> > > continue=false> > > ' do things> > > if i=17 then continue=true> > > if not continue then> > > ' do things> > > end if> > > Next> > >> > > can be done simpler.> > >> > > --> > > Evertjan.> > > The Netherlands.> > > (Please change the x'es to dots in my emailaddress)[/color]> >> >[/color]>>[/color]

Evertjan.
Guest
n/a Posts
July 19th, 200506:05 AM #5
Re: For Next iterations
Brian Burgess wrote on 29 jul 2003 inmicrosoft.public.inetserver.asp.general:[color=blue]> Hey I got a cool way from Walter Zackery/Michael Harris in the VBScript> group...>> For Count = 1 to 5> Do> If Count = 3 Then Exit Do> MsgBox Count> Exit Do:Loop> Next>> Cool eh? a Do Loop wrapper ..[/color]Silly American word "cool", and wrong too:If Count=1 the do-loop will trigger indefinitly,outputting messageboxes galore,never even reaching count=2The "Exit do:" as a label is also nonsense,"Exit do" does not even use/need a label.--Evertjan.The Netherlands.(Please change the x'es to dots in my emailaddress)

Tom B
Guest
n/a Posts
July 19th, 200506:05 AM #6
Re: For Next iterations
That's what I was thinking when I first saw it, but I think the colon isbeing used as a statement separator.as inFor Count = 1 to 5DoIf Count=3 then Exit DoMsgBox CountExit DoLoopNextI think that's what they were going for.Furthermore, what's wrong with "cool?" I also enjoy saying "sit on it" andI'm not American."Evertjan." wrote in messagenews:Xns93C7D810FC039eejj99@194.109.133.29...[color=blue]> Brian Burgess wrote on 29 jul 2003 in> microsoft.public.inetserver.asp.general:[color=green]> > Hey I got a cool way from Walter Zackery/Michael Harris in the VBScript> > group...> >> > For Count = 1 to 5> > Do> > If Count = 3 Then Exit Do> > MsgBox Count> > Exit Do:Loop> > Next> >> > Cool eh? a Do Loop wrapper ..[/color]>> Silly American word "cool", and wrong too:>> If Count=1 the do-loop will trigger indefinitly,> outputting messageboxes galore,> never even reaching count=2>> The "Exit do:" as a label is also nonsense,> "Exit do" does not even use/need a label.>> --> Evertjan.> The Netherlands.> (Please change the x'es to dots in my emailaddress)[/color]

Dan Brussee
Guest
n/a Posts
July 19th, 200506:05 AM #7
Re: For Next iterations
In article <#DTZTjgVDHA.2224@TK2MSFTNGP09.phx.gbl>, Join Bytes!says...[color=blue]> That's what I was thinking when I first saw it, but I think the colon is> being used as a statement separator.> as in>> For Count = 1 to 5> Do> If Count=3 then Exit Do> MsgBox Count> Exit Do> Loop> Next>> I think that's what they were going for.>> Furthermore, what's wrong with "cool?" I also enjoy saying "sit on it" and> I'm not American.>[/color]As others have said, this will loop indefinitely, plus you should notput a MsgBox command in ANY ASP code - EVER.A better way might be (also as mentioned before)For Count = 1 to 5If Count <> 3 then' Do something when Count is not 3End IfNext--Remove NOT from email address to reply. AntiSpam in action.

Brian Burgess
Guest
n/a Posts
July 19th, 200506:05 AM #8
Re: For Next iterations
well, pardon my silliness.. however, what I have shown is workingcorrectly. I dont think it is a label in this case.. in fact I dontbelieve labels work at all in script, but not sure if I remember thatcorrectly anyway. Here I think the colon is interpreted as something likea new line.So in this case, the Do only executes once for each iteration of the Forloop no matter what, and the If clause telling it if it can exit earlier.Anyway, I thought it was elegant.Thanks for the help..-BB"Evertjan." wrote in messagenews:Xns93C7D810FC039eejj99@194.109.133.29...[color=blue]> Brian Burgess wrote on 29 jul 2003 in> microsoft.public.inetserver.asp.general:[color=green]> > Hey I got a cool way from Walter Zackery/Michael Harris in the VBScript> > group...> >> > For Count = 1 to 5> > Do> > If Count = 3 Then Exit Do> > MsgBox Count> > Exit Do:Loop> > Next> >> > Cool eh? a Do Loop wrapper ..[/color]>> Silly American word "cool", and wrong too:>> If Count=1 the do-loop will trigger indefinitly,> outputting messageboxes galore,> never even reaching count=2>> The "Exit do:" as a label is also nonsense,> "Exit do" does not even use/need a label.>> --> Evertjan.> The Netherlands.> (Please change the x'es to dots in my emailaddress)[/color]

Brian Burgess
Guest
n/a Posts
July 19th, 200506:06 AM #9
Re: For Next iterations
I needed a way to immediately go to the next iteration of the For(based onan If clause) without exiting the For altogether.I have been able to use the MsgBox when the ASP writes out an HTML '/script'element by the way .. wanna see?-BB"Tom B" wrote in messagenews:O1x$FPgVDHA.2328@TK2MSFTNGP12.phx.gbl...[color=blue]> I'm sure I don't see the point. The following does exactly the same[/color]thing,[color=blue]> is easier to read and understand by others and is logical.>> For Count = 1 to 5> If count <> 3 then> 'blah blah blah -- can't use a Msgbox in ASP/VBScript> end if> Next>>> "Brian Burgess" wrote in message> news:%238110HgVDHA.2544@tk2msftngp13.phx.gbl...[color=green]> > Hey I got a cool way from Walter Zackery/Michael Harris in the VBScript> > group...> >> > For Count = 1 to 5> > Do> > If Count = 3 Then Exit Do> > MsgBox Count> > Exit Do:Loop> > Next> >> > Cool eh? a Do Loop wrapper ..> >> > -BB> >> >> > "Brian Burgess" wrote in message> > news:uj6AYAaVDHA.1480@tk2msftngp13.phx.gbl...[color=darkred]> > > Ah cool. That points me in the right direction...> > >> > > Kinda makes me feel stupid .. but it works .. :-P> > >> > > thanks> > >> > > -BB> > >> > >> > > "Evertjan." wrote in message> > > news:Xns93C759FC8ED8Ceejj99@194.109.133.29...> > > > Brian Burgess wrote on 29 jul 2003 in> > > > microsoft.public.inetserver.asp.general:> > > >> > > > > Is there any 'trick' anyone knows to control a For Next to pass to[/color][/color]> the[color=green][color=darkred]> > > > > next iteration in ASP VBScript? ..Similar to the 'continue'[/color][/color]> keyword[color=green][color=darkred]> > > > > of C and C++?> > > > >> > > >> > > > For i=1 to 100> > > > continue=false> > > > ' do things> > > > if i=17 then continue=true> > > > if not continue then> > > > ' do things> > > > end if> > > > Next> > > >> > > > can be done simpler.> > > >> > > > --> > > > Evertjan.> > > > The Netherlands.> > > > (Please change the x'es to dots in my emailaddress)> > >> > >[/color]> >> >[/color]>>[/color]

Brian Burgess
Guest
n/a Posts
July 19th, 200506:06 AM #10
Re: For Next iterations
I have shown in a previous message how/why this is working. But I have aquestion concerning MsgBox. In this case it is only demo code of course,but I do have some code that makes an HTML '/script' element which in turnuses MsgBox. Is this bad as well? And if so, why?Thanks..-BB"Dan Brussee" wrote in messagenews:MPG.19909958ff4cce4e9897b6@news-server.nc.rr.com...[color=blue]> In article <#DTZTjgVDHA.2224@TK2MSFTNGP09.phx.gbl>, Join Bytes!> says...[color=green]> > That's what I was thinking when I first saw it, but I think the colon is> > being used as a statement separator.> > as in> >> > For Count = 1 to 5> > Do> > If Count=3 then Exit Do> > MsgBox Count> > Exit Do> > Loop> > Next> >> > I think that's what they were going for.> >> > Furthermore, what's wrong with "cool?" I also enjoy saying "sit on it"[/color][/color]and[color=blue][color=green]> > I'm not American.> >[/color]>> As others have said, this will loop indefinitely, plus you should not> put a MsgBox command in ANY ASP code - EVER.>> A better way might be (also as mentioned before)>> For Count = 1 to 5> If Count <> 3 then> ' Do something when Count is not 3> End If> Next>>>> -->> Remove NOT from email address to reply. AntiSpam in action.[/color]

Brian Burgess
Guest
n/a Posts
July 19th, 200506:06 AM #11
Re: For Next iterations
Ah cool!Yes understood. This is for PocketPC devices which ONLY have PocketIEpresently but only supports jscript (on the client). So MsgBox does notwork.... Though it did one time .. very odd.-BB"Evertjan." wrote in messagenews:Xns93C7E0593E4F3eejj99@194.109.133.29...[color=blue]> Brian Burgess wrote on 29 jul 2003 in> microsoft.public.inetserver.asp.general:>[color=green]> > But I have a> > question concerning MsgBox. In this case it is only demo code of> > course, but I do have some code that makes an HTML '/script' element> > which in turn uses MsgBox. Is this bad as well? And if so, why?> >[/color]>> In Clientside vbscript it is not bad at all.>> [Keeping in mind that this vbscript only works in IE]>> --> Evertjan.> The Netherlands.> (Please change the x'es to dots in my emailaddress)[/color]

No comments: