Connecting Tech Pros Worldwide Forums | Help | Site Map

if...if...else if...multi conditional statements problem

Patrice
Guest
 
Posts: n/a
#1: Jul 19 '05
Hi,
I need to do multi-conditional statements like below, but this error is
displayed :
Expected 'End'
/myFilepath, line x
else response.write(arrCorpo(sparam,sdiv)) end if

I don't understand why this 'Expected 'End'' error is called!
Here is my code:
<%

sdiv=request("div")

sparam=request("param")

snat=request("nat")

%>

<%

Function loopDatas(arrayName)

nRowCount = ubound(arrayName, 2)

For n=0 to nRowCount

response.write(arrayName(1,n)&"<BR>")

Next

End Function

%>


<%

if(sdiv=3) then

if snat="" then response.write(corpclientsmaintext)

else if (snat=1 or snat=2) then

response.write("<table
width='200'><tr><td>"&corpclientsgov&"<br>"&corpcl ientsfi&"<br>"&corpclients
lcorp&"<br>"&corpclientslfirms&"<br>"&corpclientsa firms&"<br></td><td>")

call loopDatas(arrCorpoType)

response.write("</td></tr></table>")

end if

else response.write(arrCorpo(sparam,sdiv))

end if

%>



Can someone help me?

Thanks in advance

Patrice



Ray at
Guest
 
Posts: n/a
#2: Jul 19 '05

re: if...if...else if...multi conditional statements problem


You have:

[color=blue]
> if(sdiv=3) then
>
> if snat="" then response.write(corpclientsmaintext)
>
> else if (snat=1 or snat=2) then
>
>[color=green]
> > end if[/color]
>
> else response.write(arrCorpo(sparam,sdiv))
>
> end if[/color]

If condition Then
If condition Then '''do something
Else
If condition Then
''something
End If
Else <--- ???
End If

Tab your code nicely. Don't mixup ElseIf with Else and If as two separate
words.

Ray at work




"Patrice" <manitoo@videotron.ca> wrote in message
news:leZ7c.83648$ZY6.1226196@wagner.videotron.net. ..[color=blue]
> Hi,
> I need to do multi-conditional statements like below, but this error is
> displayed :
> Expected 'End'
> /myFilepath, line x
> else response.write(arrCorpo(sparam,sdiv)) end if
>
> I don't understand why this 'Expected 'End'' error is called!
> Here is my code:
> <%
>
> sdiv=request("div")
>
> sparam=request("param")
>
> snat=request("nat")
>
> %>
>
> <%
>
> Function loopDatas(arrayName)
>
> nRowCount = ubound(arrayName, 2)
>
> For n=0 to nRowCount
>
> response.write(arrayName(1,n)&"<BR>")
>
> Next
>
> End Function
>
> %>
>
>
> <%
>
> if(sdiv=3) then
>
> if snat="" then response.write(corpclientsmaintext)
>
> else if (snat=1 or snat=2) then
>
> response.write("<table
>[/color]
width='200'><tr><td>"&corpclientsgov&"<br>"&corpcl ientsfi&"<br>"&corpclients[color=blue]
> lcorp&"<br>"&corpclientslfirms&"<br>"&corpclientsa firms&"<br></td><td>")
>
> call loopDatas(arrCorpoType)
>
> response.write("</td></tr></table>")
>
> end if
>
> else response.write(arrCorpo(sparam,sdiv))
>
> end if
>
> %>
>
>
>
> Can someone help me?
>
> Thanks in advance
>
> Patrice
>
>[/color]


Phill. W
Guest
 
Posts: n/a
#3: Jul 19 '05

re: if...if...else if...multi conditional statements problem


Patrice,

With a bit of cleaning up, I /think/ this is what you wanted

if ( sdiv = 3 ) then
if snat="" then
response.write(corpclientsmaintext)
else
if ( snat = 1 or snat = 2 ) then
response.write( . . .
call loopDatas(arrCorpoType)
response.write("</td></tr></table>")
end if
end if
else
response.write(arrCorpo(sparam,sdiv))
end if

You've been caught out by VB[Script]'s one-line form of "If" :

If condition Then action

Written this way, there's no "End If" and you /can't/ [easily] use an
"Else" with it, either. My Advice: avoid it.

HTH,
Phill W.

"Patrice" <manitoo@videotron.ca> wrote in message
news:leZ7c.83648$ZY6.1226196@wagner.videotron.net. ..[color=blue]
> Hi,
> I need to do multi-conditional statements like below, but this error is
> displayed :
> Expected 'End'
> /myFilepath, line x
> else response.write(arrCorpo(sparam,sdiv)) end if
>
> I don't understand why this 'Expected 'End'' error is called!
> Here is my code:[/color]


Evertjan.
Guest
 
Posts: n/a
#4: Jul 19 '05

re: if...if...else if...multi conditional statements problem


Patrice wrote on 23 mrt 2004 in microsoft.public.inetserver.asp.general:[color=blue]
> if(sdiv=3) then
>
> if snat="" then response.write(corpclientsmaintext)
>
> else if (snat=1 or snat=2) then
>
> response.write("<table
> width='200'><tr><td>"&corpclientsgov&"<br>"&corpcl ientsfi&"<br>"&corpcl
> ients
> lcorp&"<br>"&corpclientslfirms&"<br>"&corpclientsa firms&"<br></td><td>"
> )
>
> call loopDatas(arrCorpoType)
>
> response.write("</td></tr></table>")
>
> end if
>
> else response.write(arrCorpo(sparam,sdiv))
>
> end if
>[/color]


You are doing this:

============================
if condition then
if condition then statement
else if condition then
statements
end if
else statement
end if
============================

This is not legal vbs code

there are two forms of if:

1 the single row:

if boolean then statement else statement

2 the multirow:

if boolean then
statement
elseif boolean then 'elsif without space
statement
else
statement
end if

in a "multi row if"
nothing can follow "then" or "else" on the same line !!!

I suppose what you want to do is:

============================
if boolean then
if boolean then statement
else
if boolean then
statements
end if
else
statement
end if
============================

but that is NOT legal either,
because now you still have an orfaned second else.

So this is legal code:

============================
if boolean then
if boolean then statement
elseif boolean then
statements
else
statement
end if
============================

btw:
booleans and the respons.write parameter do not need () in vbs:

if a=3 then

respons.write "my Text"

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Closed Thread