syntax error from function in include file


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: syntax error from function in include file

Hybrid View

  1. #1
    Join Date
    Mar 2009
    Posts
    2

    syntax error from function in include file

    Hi, good programmer but complete noob to ASP/VBscript here, with what must be a painfully obvious noob question...

    If I define a function (using sample code from here on devx.com):

    <%
    function WriteToFile(FileName, Contents, Append)
    ...
    end function
    %>

    inline in any of several .asp files, it works fine. But if I define the exact same function inside a separate .asp include file and include the file in those original .asp files, I get a syntax error:

    Microsoft VBScript compilation error '800a03ea'

    Syntax error

    /fsglobals.asp, line 7

    function WriteToFile(FileName, Contents, Append)
    ^

    Why? Searching the web I find plenty of sites talking about the benefits of defining ASP functions inside include files, but no amount of searching on this forum or on the web has turned up a useful example or a hint as to why this isn't working as expected.

    Thanks hugely for any help.

  2. #2
    Join Date
    Mar 2009
    Posts
    2
    Of course, as soon as I post, I figure it out. I found a question on another site about a similar problem, and though the ultimate cause was different, the main clue there was that the problem wasn't due to the include file or the function, but something before it or, more precisely, where exactly the include took place. I was dealing with someone else's code that had a for loop start in an include file and complete inline (grumble, grumble), so I didn't realize I was trying to do my include inside a loop. (I didn't realize that would be a no-no either, given that the include wasn't within <&#37; %> VBscript delimiters, but it does make sense.) Simply getting the include out of the loop did the trick.

Similar Threads

  1. Replies: 2
    Last Post: 12-29-2008, 11:40 AM
  2. Replies: 4
    Last Post: 08-28-2008, 05:42 PM
  3. Replies: 2
    Last Post: 01-02-2003, 02:32 PM
  4. Getting a GUI to function
    By Eric in forum Java
    Replies: 1
    Last Post: 11-27-2001, 06:53 AM
  5. calling ping thru vb
    By Michael Shutt in forum VB Classic
    Replies: 6
    Last Post: 04-05-2001, 02:25 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center