For Next iterations

Discussion in 'ASP General' started by Brian Burgess, Jul 29, 2003.

  1. Hi all,

    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++?

    Thanks in advance..

    -BB
     
    Brian Burgess, Jul 29, 2003
    #1
    1. Advertising

  2. 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 the
    > > next iteration in ASP VBScript? ..Similar to the 'continue' keyword
    > > 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)
     
    Brian Burgess, Jul 29, 2003
    #2
    1. Advertising

  3. 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:...
    > 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 the
    > > > next iteration in ASP VBScript? ..Similar to the 'continue' keyword
    > > > 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)

    >
    >
     
    Brian Burgess, Jul 29, 2003
    #3
  4. Brian Burgess

    Tom B Guest

    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 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:%...
    > 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:...
    > > 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

    the
    > > > > next iteration in ASP VBScript? ..Similar to the 'continue'

    keyword
    > > > > 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)

    > >
    > >

    >
    >
     
    Tom B, Jul 29, 2003
    #4
  5. Brian Burgess

    Evertjan. Guest

    Brian Burgess wrote on 29 jul 2003 in
    microsoft.public.inetserver.asp.general:
    > 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 ..


    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)
     
    Evertjan., Jul 29, 2003
    #5
  6. Brian Burgess

    Tom B Guest

    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.


    "Evertjan." <> wrote in message
    news:Xns93C7D810FC039eejj99@194.109.133.29...
    > Brian Burgess wrote on 29 jul 2003 in
    > microsoft.public.inetserver.asp.general:
    > > 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 ..

    >
    > 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)
     
    Tom B, Jul 29, 2003
    #6
  7. well, pardon my silliness.. however, what I have shown is working
    correctly. I dont think it is a label in this case.. in fact I dont
    believe labels work at all in script, but not sure if I remember that
    correctly anyway. Here I think the colon is interpreted as something like
    a new line.
    So in this case, the Do only executes once for each iteration of the For
    loop 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 message
    news:Xns93C7D810FC039eejj99@194.109.133.29...
    > Brian Burgess wrote on 29 jul 2003 in
    > microsoft.public.inetserver.asp.general:
    > > 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 ..

    >
    > 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)
     
    Brian Burgess, Jul 29, 2003
    #7
  8. Brian Burgess

    Dan Brussee Guest

    In article <#>,
    says...
    > 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.
    >


    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.
     
    Dan Brussee, Jul 29, 2003
    #8
  9. I needed a way to immediately go to the next iteration of the For(based on
    an 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 message
    news:O1x$...
    > 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 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:%...
    > > 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:...
    > > > 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

    > the
    > > > > > next iteration in ASP VBScript? ..Similar to the 'continue'

    > keyword
    > > > > > 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)
    > > >
    > > >

    > >
    > >

    >
    >
     
    Brian Burgess, Jul 29, 2003
    #9
  10. I have shown in a previous message how/why this is working. 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?

    Thanks..

    -BB


    "Dan Brussee" <> wrote in message
    news:...
    > In article <#>,
    > says...
    > > 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.
    > >

    >
    > 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.
     
    Brian Burgess, Jul 29, 2003
    #10
  11. Ah cool!

    Yes understood. This is for PocketPC devices which ONLY have PocketIE
    presently but only supports jscript (on the client). So MsgBox does not
    work.

    ... Though it did one time .. very odd.

    -BB


    "Evertjan." <> wrote in message
    news:Xns93C7E0593E4F3eejj99@194.109.133.29...
    > Brian Burgess wrote on 29 jul 2003 in
    > microsoft.public.inetserver.asp.general:
    >
    > > 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?
    > >

    >
    > 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)
     
    Brian Burgess, Jul 29, 2003
    #11
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Gordon Macleod

    Struts iterations

    Gordon Macleod, Jul 21, 2003, in forum: Java
    Replies:
    0
    Views:
    445
    Gordon Macleod
    Jul 21, 2003
  2. Infiniti

    Do something every x iterations

    Infiniti, Jul 7, 2003, in forum: XML
    Replies:
    6
    Views:
    1,010
    Marrow
    Jul 8, 2003
  3. hilz
    Replies:
    5
    Views:
    552
    Joe Kesselman
    Feb 16, 2006
  4. Derek Basch

    Counting iterations

    Derek Basch, Apr 8, 2005, in forum: Python
    Replies:
    11
    Views:
    595
    Andrew Dalke
    Apr 11, 2005
  5. Deniz Bahar
    Replies:
    2
    Views:
    514
    Andrey Tarasevich
    Mar 9, 2005
Loading...

Share This Page