Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old July 19th, 2005, 07:28 AM
Frank
Guest
 
Posts: n/a
Default Function problems in ASP

I'm running the current function:

isbn="08307.25318"

function geturl(value)
image="http://www.gospellight.com/Merchant2/graphics/00000001/"
image=image & value & ".jpg"
response.write image
end function

geturl(isbn)

If I run this in an html page, it works fine, as in <% geturl(isbn) %>
and that is inserted into the html, it works.

However, if this is inserted into a line of asp code, it blows up on
me, prorobly because of the response.write inside of the function. If
I take out the response.write, it dosn't return any value at all. How
do I get it to return a value if I'm not using the response.write
object/method?
  #2  
Old July 19th, 2005, 07:28 AM
Chris Barber
Guest
 
Posts: n/a
Default Re: Function problems in ASP

function geturl(value)
image="http://www.gospellight.com/Merchant2/graphics/00000001/"
image=image & value & ".jpg"
geturl = image
end function

Or a slightly better coded version (with variable type suggestions):

'Function to return a modified image URL from the image name part and a
standard base path and extension.
Function GetURL(pstrValue)
Dim pstrImageURL
'Set the base path for the images.
pstrImageURL="http://www.gospellight.com/Merchant2/graphics/00000001/"
'Add the specific image name and extension.
pstrImageURL = pstrImageURL & pstrValue & ".jpg"
'Return the newly concatenated value.
GetURL = pstrImageURL
End Function

I suspect that you don't have 'Option Explicit' at the top of your ASP page
and are relying on implicit variable creation? That's pretty dangerous - you
should always have Option Explicit set and declare your variables to aid in
debugging.

Chris.

"Frank" <williamzim2000@yahoo.com> wrote in message
news:7383558c.0308070801.27eb9c9a@posting.google.c om...
I'm running the current function:

isbn="08307.25318"

function geturl(value)
image="http://www.gospellight.com/Merchant2/graphics/00000001/"
image=image & value & ".jpg"
response.write image
end function

geturl(isbn)

If I run this in an html page, it works fine, as in <% geturl(isbn) %>
and that is inserted into the html, it works.

However, if this is inserted into a line of asp code, it blows up on
me, prorobly because of the response.write inside of the function. If
I take out the response.write, it dosn't return any value at all. How
do I get it to return a value if I'm not using the response.write
object/method?


  #3  
Old July 19th, 2005, 07:28 AM
Evertjan.
Guest
 
Posts: n/a
Default Re: Function problems in ASP

Frank wrote on 07 aug 2003 in microsoft.public.inetserver.asp.general:
[color=blue]
> I'm running the current function:
>
> isbn="08307.25318"
>
> function geturl(value)
> image="http://www.gospellight.com/Merchant2/graphics/00000001/"
> image=image & value & ".jpg"
> response.write image
> end function
>
> geturl(isbn)
>
> If I run this in an html page, it works fine, as in <% geturl(isbn) %>
> and that is inserted into the html, it works.
>
> However, if this is inserted into a line of asp code, it blows up on
> me, prorobly because of the response.write inside of the function. If
> I take out the response.write, it dosn't return any value at all. How
> do I get it to return a value if I'm not using the response.write
> object/method?
>[/color]

<%
isbn="08307.25318"

function geturl(value)
image="http://www.gospellight.com/Merchant2/graphics/00000001/"
image=image & value & ".jpg"
geturl = image
end function
%>

And then do:

<img src="<% = geturl(isbn) %>">


Or

Response.write "<img src='" & geturl(isbn) & "'>"


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

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles