Includes redux & stupid mappath tricks...

Author Message
dannyboi

  • Total Posts : 2
  • Scores: 0
  • Reward points : 0
  • Joined: 4/12/2007
  • Status: offline
Includes redux & stupid mappath tricks... Thursday, April 12, 2007 12:06 PM (permalink)
0
hey vbs peops --
 
1st time poster, go gentle on me , im a vbs.com virgin.
 
I have a bunch of asp pages that all reuse the same class code from an include.  The files are located in various level dirs throughout the site.
 
mainFile.asp
{#include file="blah/blah/classX.asp"}
 
anotherFile.asp
{#include file="../../blah/blah/classX.asp"}
 
OneMoreFile.asp
{#include file="blah/classX.asp"}
 
 
 
I have the class file.
 
ClassX.asp
yadda, yadda, reuseable code
 
whenever I attempt to use the funct Mappath(".") from inside ClassX.asp to try to find out where the class file is physically located, it always returns the path to the main calling file, and never the path to the included classX.asp file.
 
How can I dynamically find the path to an includes file from inside the included code itself?
 
(I would like to have the class code reuseable across 15-20 different websites all with totally different directory structures and names.  I would prefer to release the code w/o having to hardcode paths into it.  If the class were "self detecting' of it's own dir location, my maintainence chores would be much easier.
 
Tnx for any hints,tips, or filthy little trix,
Dan
 
 
 
#1
    dm_4ever

    • Total Posts : 3687
    • Scores: 82
    • Reward points : 0
    • Joined: 6/29/2006
    • Location: Orange County, California
    • Status: offline
    RE: Includes redux & stupid mappath tricks... Friday, April 13, 2007 5:47 AM (permalink)
    dm_4ever

    My philosophy: K.I.S.S - Keep It Simple Stupid
    Read Me: http://www.visualbasicscript.com/m_24727/tm.htm
    Frequently Asked Stuff: http://www.visualbasicscript.com/m_47117/tm.htm
     
    #2
      dannyboi

      • Total Posts : 2
      • Scores: 0
      • Reward points : 0
      • Joined: 4/12/2007
      • Status: offline
      RE: Includes redux & stupid mappath tricks... Saturday, April 14, 2007 2:57 AM (permalink)
      0
      Thanks for the reply, dm.

      I might not have been too clear.  The problem I'm having is that anytime I call Mappath(".") within my class code it returns the location of the calling scripts, and  not the location of the class file itself.  (when the class is called as an include.)

      '{sample code from the class}
      Private Sub Class_Initialize()
      ThisClassPath =  Server.MapPath(".")
      End class

      '{the var ThisClassPath ends up holding the Path to the calling script, not the class it's called from}

      Are you suggesting using the global.asa file as a place to simply hard code the exact path/name to my class file?    I don't see how using global.asa is gonna help make the class code "self aware" of it's own location.   And, I can hard code the location right into the class itself easily enough, but that's exactly what Im trying to avoid doing.  

      Hopefully, I'm just totally missing your point.

      Thanks again for making a suggestion. Much Appreciated.
      Dan
      <message edited by dannyboi on Saturday, April 14, 2007 3:04 AM>
       
      #3

        Online Bookmarks Sharing: Share/Bookmark

        Jump to:

        Current active users

        There are 0 members and 1 guests.

        Icon Legend and Permission

        • New Messages
        • No New Messages
        • Hot Topic w/ New Messages
        • Hot Topic w/o New Messages
        • Locked w/ New Messages
        • Locked w/o New Messages
        • Read Message
        • Post New Thread
        • Reply to message
        • Post New Poll
        • Submit Vote
        • Post reward post
        • Delete my own posts
        • Delete my own threads
        • Rate post

        2000-2012 ASPPlayground.NET Forum Version 3.9