Daniel Nordh
Daniel Nordh

Reputation: 390

Classic ASP do while, move to next loop in advance

I was wondering if there is any way you can start over in a do until-loop earlier than its ordinary loop end point.

Non-working example to try and explain what I want:

do until RS.eof
  ...
amount = RS("product_amount")
response.write(amount)
if amount > 5 then
    rs.movenext
    loop
end if
  ...
rs.movenext
loop

The ...'s symbolizes more code.

And yes, I understand I can just put an if-tag around the bottom code to skip to the end loop, but I want to try and keep it as clean as possible without a lot of nested if-statements.

Upvotes: 1

Views: 5637

Answers (2)

DanB
DanB

Reputation: 2094

Just invert your condition. Do your stuff in the IF END IF code, and continue after if condition is false.

do until RS.eof
      ...
    amount = RS("product_amount")
    response.write(amount)
    if not (amount > 5) then
        ...
    end if

    rs.movenext
loop

Upvotes: 0

jmalatia
jmalatia

Reputation: 196

No. The only thing you can use is Exit Do which will exit the do entirely. You will have to rely on if...thens to keep things separated like you are currently doing.

Upvotes: 2

Related Questions