Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Syntax Error on small ASP script 2

Status
Not open for further replies.

Jimuniguy

Technical User
Mar 6, 2002
363
GB
Hi,

Need this script to work:
Code:
<%
dim total
total = 20 + %><!-- #include file=&quot;tSize.ASP&quot; --><%
response.write(total)
%>

However, it comes up with syntax error. The number generated in tsize.asp is a number which uses response.write.

Why wont it work for?

Cheers

James
 
You will need to place the result in an ASP variable instead. Maybe if you used:

Code:
<!-- #include file=&quot;tSize.asp&quot; -->
<%
total = 20 + someFunction()
%>

someFunction would be a function in tSize.asp
Code:
Function someFunction()
  ...function code here
  ...function code here
  ...function code here
  someFunction = result
End Function
Tony
reddot.gif WIDTH=400 HEIGHT=2 VSPACE=3

 
Tony,

How could I do this then?

In tsize, it queries the Querystring using if and ifelse and writes a number using the response.write feature. How could I put that into a function?

The joy of it all, is that this is already inside another asp page.

Cheers

James
 
Hi,

Nope, the page uses no cookies or javascript.

Cheers

James
 
A session is not cookie or a javascript its almost exactly like a string, accept it lasts the whole time the user is on your site and browsing...
 
Hi,

We I was reading up on ASP, i thought that a session variable actually writes a cookie?

Its ok, I have thought of away around it.

Cheers

James
 
Hi,

Grr i thought it might work, but its not, its missing an identifier:

Code:
<%
dim me

me = Request.QueryString(&quot;tSize&quot;)
If me >0 then m = Request.QueryString(&quot;tSize&quot;)
Else me = 20

dim total
total = 20 + me
response.write(total)
%>
 
Your going to get yourself in trouble using &quot;me&quot; as a variable..

<%
dim StrTsize, strTotal

StrTsize= Request.QueryString(&quot;tSize&quot;)
If StrTsize > 0 then StrTsize = Request.QueryString(&quot;tSize&quot;)
Else
StrTsize = 20
End if

strTotal = 20 + StrTsize
response.write(strTotal)
%>

ps. in your code you put &quot;m&quot; instead of me.. even though you shouldn't use me, you should always put like strStringName or something to that affect... and dim all your variables at the top of the page.

You also forgot End if at the end of your if statement
 
Hi,

Fester - comes back as a expected Identifer
Snowboarder - comes back with syntanx error.

Proberley this will help in your workings out:

The tsize is not yet in the query string, it gets added in later after a choice is made by the user. I was hoping that by saying if me was a number, then use it, if me vaule does not exist (cos its not in the query string just yet) then use the value 20

Does that help?

Cheers

James
 
snowboardr is right - correctly named variables are a lifesaver when they start to accumulate.

try this now:

<%
dim intMe, intTotal

If Request.QueryString(&quot;tSize&quot;) <> &quot;&quot; Then
intMe = CInt(Request.QueryString(&quot;tSize&quot;))
Else
intMe = 20
End If

intTotal = 20 + intMe

Response.Write intTotal
%>


Tony
reddot.gif WIDTH=400 HEIGHT=2 VSPACE=3

 
Hi,

Bingo,

Cheers Guys, thanks for putting up with me!

Have a good weekend

James
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top