...

View Full Version : Compilation error??



Speedy
12-21-2003, 03:53 AM
Hi,

I get this erroe mess:

Compilation Error in Microsoft VBScript (0x800A03F6)
'End' is Expected
/main.asp Line 337

Line 337:



<%End If%>


and here's all the code I think is relevant:



<%If Request.QueryString("cat") = "" Or Request.QueryString("cat") = "om" Then
If Request.QueryString("ucat") = "presentation" Then%>

Presentation

<%ElseIf Request.QueryString("ucat") = "styrelsen" Then%>

Styrelsen

<%ElseIf Request.QueryString("ucat") = "historia" Then%>

Historia

<%ElseIf Request.QueryString("ucat") = "meriter" Then%>

Meriter

<%ElseIf Request.QueryString("ucat") = "mastare" Then%>

Mästare genom åren

<%ElseIf Request.QueryString("ucat") = "banor" Then%>

Våra banor

<%End If
ElseIf Request.QueryString("cat") = "medlem" Then
If Request.QueryString("ucat") = "attvara" Then%>

Att vara medlem

<%ElseIf Request.QueryString("ucat") = "bli" Then%>

Bli medlem

<%ElseIf Request.QueryString("ucat") = "paragrafer" Then%>

Rättigheter & skyldigheter

<%ElseIf Request.QueryString("ucat") = "arrangemang" Then%>

Medlemsarrangemang

<%End If
ElseIf Request.QueryString("cat") = "tavling" Then
If Request.QueryString("ucat") = "info" Then%>

Tävlingsregler & info för ickemedlemmar

<%ElseIf Request.QueryString("ucat") = "schema" Then%>

Spelschema

<%ElseIf Request.QueryString("ucat") = "resultat" Then%>

Resultatbörs

<%ElseIf Request.QueryString("ucat") = "lagspel" Then%>

Lagspel (Div 3, Stockholmsserien Lag 1, ??Stockholmsserien Lag 2??)

<%End If
ElseIf Request.QueryString("cat") = "lankar" Then
If Request.QueryString("ucat") = "sverige" Then%>

Svenska länkar

<%ElseIf Request.QueryString("ucat") = "utland" Then%>

Utländska länkar

<%ElseIf Request.QueryString("ucat") = "butiker" Then%>

Webb butiker

<%ElseIf Request.QueryString("ucat") = "annat" Then%>

Övriga länkar (puttabra)

<%End If
ElseIf Request.QueryString("cat") = "forum" Then
If Request.QueryString("ucat") = "forum" Then%>

Forum

<%End If
ElseIf Request.QueryString("cat") = "kontakt" Then
If Request.QueryString("ucat") = "klubben" Then%>

Kontakta klubben (Adress, Telefon, PG, Org.nr)

<%ElseIf Request.QueryString("ucat") = "styrelsen" Then%>

Styrelsen

<%ElseIf Request.QueryString("ucat") = "ungledare" Then%>

Ungdomsledare

<%End If%> <-- LINE 337


Does anyone see what I'm missing??

All help appreciated, thanks
/Speedy

Speedy
12-21-2003, 04:31 AM
I've solved it!

I had to add a few extra <%End If%>'s.
I'm way to tired to be coding right now (4:30AM) zzzzzzz

/Speedy

Roy Sinclair
12-22-2003, 10:05 PM
Using indentation makes finding problems like this much easier.

oracleguy
12-23-2003, 12:31 AM
Originally posted by Roy Sinclair
Using indentation makes finding problems like this much easier.

Quite so, and since you are only writing one word out, it would be better to just use Response.Write instead of switching in and out of the <% ... %> tags.

Oakendin
12-23-2003, 07:28 PM
a else if after a end if works? I quess I should try the code out, but I can't imagine doing it.

Code is question (modified from above):


<%
If Request("foo") = "foo" Then
Response.write ("foo")
Elseif Request("foobar") = "foobar" Then
Response.write ("foobar")
End If
Else If Request("wtf") = "wtf" Then
Response.write ("wtf")
End If
%>

miranda
12-23-2003, 09:32 PM
if you look closely at Speedy's code you will see that the very first If/Else statement is never closed with an End If, instead he nested If/Else statements inside the first If/Else statement. it was the second level If/Else that he was closing. As Oracleguy posted, using indentation would have eliminated this problem. The code Oakendin is showing will throw an error.

Speedy
12-24-2003, 02:43 AM
What's Indentation?

/Speedy

raf
12-24-2003, 03:07 AM
Originally posted by Speedy
What's Indentation?

/Speedy
Indentation?


well, you could say that that
is me
and me also
etc etc
but not me


(it's adding spaces in front of new lines after an if or else clause etc and the oposite if you closed a clause.)
So you then need to end at the left border if all clauses or closed, end you can immedeately see which clause or lopp or ... starts and ends where.

If you use a good editor, the you'll automaticaly indent and 'outdent' on new lines after a control of flow statement

whammy
12-25-2003, 05:01 AM
Oh man... speedy, for humankind's sake, and your own - not to mention any developers that might have to work on your code in the future, please indent your code. :eek:

Something like:


If a = b Then
'do something
Else
If b = c Then
'do something else
If c = d Then
'do something else entirely
End If
End If
End If

Otherwise you run into the problem you just ran into. Some experience with JavaScript, C++, C or any other strict programming language will cure you of that problem. I'd suggest taking the webmonkey tutorials on javascript and making some mock forms for practice, validating them using javascript. :)

I don't mean to offend by the above message, but I sometimes have to fix old websites where people didn't indent their code, and in order to figure it out, I spend 20-30 minutes just indenting and formatting code so it's readable. Not indenting your code is a great way to avoid making friends of fellow programmers. :p

whammy
12-25-2003, 05:07 AM
I should also point out that proper indentation makes troubleshooting your own code much easier. :)

Roy Sinclair
12-27-2003, 08:34 PM
Originally posted by whammy
I should also point out that proper indentation makes troubleshooting your own code much easier. :)

Er, that was my point :D

Speedy
12-28-2003, 01:05 AM
Yeah Roy I saw you said it first :thumbsup:

I also wanna say I use to indent my code but sometimes
it doesn't get right in the forums cause Dreamweavers auto
indentation really su**s everywhere but in Dreamweaver
itself.

I just didn't know what the word indent meant...I'm just a swede who doesn't know every single english word :o

/Speedy

Roy Sinclair
12-28-2003, 02:54 AM
When I first started coding (as a job) I used coding forms and pencils (a good old Pentel .05 :) ) which then had to be keypunched, then I'd check the cards, make any corrections using another coding form and finally submit the program for compilation. I used few lines of code which meant minimal indentation and variable names that were as short as possible.

After a couple years we got individual CRTs (dumb terminals) and even though I could only see 24 lines of the program at a time on the CRT I quickly found that indentation and long very descriptive variable names were so valuable that all my earlier programming efforts were embarassing to work on (and would get reformatted as the first step of any work on them).

I can still read code that's poorly formatted because I come across it all the time but well formatted code (even when it uses a slightly different standard for formatting than I prefer) is always a lot nicer to work with.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum