Functions ... again

Results 1 to 4 of 4

Thread: Functions ... again

  1. #1
    KEith Myers Guest

    Default Functions ... again

    Srry,<BR><BR>I forgot to include the code earlier :<BR>&#060;SCRIPT LANGUAGE="JSCRIPT" RUNAT="SERVER"&#062;<BR>function image_display(Value) {<BR> tools= Server.CreateObject("scripting.FilesystemObject"); <BR> id = Value + ".jpg";<BR> location = Server.Mappath("images/products/");<BR> location = location + id;<BR> if (tools.FileExists(location))<BR> {<BR> image_display = "images/products" + Value + ".jpg"<BR> }<BR> else<BR> {<BR> image_display = "images/products/noimage.jpg" <BR> }<BR><BR> tools = "nothing";<BR> Value = 0;<BR> Response.Write (image_display);<BR> } <BR>&#060;/SCRIPT&#062;<BR><BR>This function is called several times from an ASP page, yet it only works the first time, anyone got any clues, please let me know.<BR><BR>Cheers,<BR><BR>Keith

  2. #2
    Arky Guest

    Default RE: Functions ... again

    May not be the problem, but you never know:<BR><BR>i destroy objects using,<BR><BR>tools = null;<BR><BR>not the vb tools = nothing

  3. #3
    Chad LaFarge Guest

    Default RE: Functions ... again

    I set to nothing... but in your code, you set to "nothing" (a string).<BR><BR>Might try removing the quotes.

  4. #4
    Richard A. Lowe Guest

    Default Works this way...

    I don&#039t know exactly what was going on... some wierd stuff. It&#039s not really a good idea to use a variable the same name as your function, I don&#039t think.<BR><BR>Anyway, this works and is more concise:<BR><BR>&lt;SCRIPT LANGUAGE="JSCRIPT" RUNAT="SERVER"&gt;<BR>function image_display(Value) {<BR>&nbsp;&nbsp;&nbsp;&nbsp;fso = Server.CreateObject("Scripting.FilesystemObject"); <BR>&nbsp;&nbsp;&nbsp;&nbsp;Value = "images/products/" + Value + ".jpg";<BR>&nbsp;&nbsp;&nbsp;&nbsp;if (fso.FileExists(Server.MapPath(Value)))<BR>&nbsp;& nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Response. Write(Value);<BR>&nbsp;&nbsp;&nbsp;&nbsp;else<BR>& nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Res ponse.Write("images/products/noimage.jpg");<BR>&nbsp;&nbsp;&nbsp;&nbsp;fso = null;<BR>&nbsp;&nbsp;&nbsp;&nbsp;return true;<BR>}<BR>&lt;/SCRIPT&gt;

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts