Do inside an if-statement?

S

Sune

Hi,
I need to do a loop with some criterias that depends on an earlier database
query. I tried to do it this way, but it seems not to accept that the do
is inside the if:


if not objrs.EOF then
Do until updatearray(0) < objrs("updated")
else
Do While not fso.AtEndOfStream
end if
Blabla my repeating script here...
Loop


I'm getting this error:


Microsoft VBScript compilation error '800a03fb'
Expected 'Loop'
/x.asp, line 46
else
^


It seems somehow that the do is "stronger" than the if statement, as it didn't
even help doing it this way:

if not objrs.EOF then Do until updatearray(0) < objrs("updated")
if objrs.EOF then Do While not fso.AtEndOfStream

What can i do then? The script inside is 10-20 lines, so it would be stupid
copying it to each its do if anything else can be done.
Thank you
 
H

Hal Rosser

Sune said:
Hi,
I need to do a loop with some criterias that depends on an earlier database
query. I tried to do it this way, but it seems not to accept that the do
is inside the if:


if not objrs.EOF then
Do until updatearray(0) < objrs("updated")
'*****stuff to do '****ADD THESE 2 LINES
Loop
else
Do While not fso.AtEndOfStream
'**** stuff to do in the loop '****ADD THESE 2 LINES
Loop

'****** delete this part
Blabla my repeating script here...
Loop


I'm getting this error:


Microsoft VBScript compilation error '800a03fb'
Expected 'Loop'
/x.asp, line 46
else
^


It seems somehow that the do is "stronger" than the if statement, as it didn't
even help doing it this way:

if not objrs.EOF then Do until updatearray(0) < objrs("updated")
if objrs.EOF then Do While not fso.AtEndOfStream

What can i do then? The script inside is 10-20 lines, so it would be stupid
copying it to each its do if anything else can be done.
Thank you
You can put a loop in an if statement
and you can put an if statement in a loop
whichever you do - you can't do half-way
Either nest it completely - or not at all before the "end if" or the "else"
statement
 
S

Sune

You can put a loop in an if statement
and you can put an if statement in a loop
whichever you do - you can't do half-way
Either nest it completely - or not at all before the "end if" or the
"else"
statement
Thank you very much, your help is appreciated - got it working now.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top