Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8
  1. #1
    New Coder
    Join Date
    Mar 2006
    Location
    Australia
    Posts
    43
    Thanks
    0
    Thanked 0 Times in 0 Posts

    insert a file timestamp

    I would like to use ASP to put a 'last revised' date on the bottom of each of my web pages. This can be done using a webbot in Frontpage - is there a simple ASP method to do the same thing?
    pp
    -------------------------------------
    "Laziness is the mother of invention" - Thomas Edison (not really)

  • #2
    Senior Coder
    Join Date
    Nov 2002
    Location
    North-East, UK
    Posts
    1,265
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I can't think of an easy way in ASP.

    You can use the FSO
    http://www.w3schools.com/asp/asp_ref_file.asp

    But it means that for every ASP file you load you will have to run this code to grab the name of the file and then use FSO to grab it and then output the variable.

  • #3
    New Coder
    Join Date
    Mar 2006
    Location
    Australia
    Posts
    43
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks degsy, that almost gets me there. I don't mind running the script on each page, but I would like a way to automatically feed the name of the currently loaded file to the GetFile method, so I don't have to have a separate script for each page that loads. Is there a way to do this? I'm using this script from the ASP tutorial site you linked me to:
    Code:
    <%
    Dim fs,f
    Set fs=Server.CreateObject("Scripting.FileSystemObject")
    Set f=fs.GetFile("c:\test.txt")
    Response.Write("File created: " & f.DateCreated)
    set f=nothing
    set fs=nothing
    %>
    So on that third line, I want to substitute a function that returns the current page's file name rather than manually entering it
    pp
    -------------------------------------
    "Laziness is the mother of invention" - Thomas Edison (not really)

  • #4
    Regular Coder
    Join Date
    Apr 2005
    Location
    Lisbon, CT
    Posts
    339
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I don't want to butt in here however if I understand you right I think this might help you out. Just put the call into your code just before the getfile call
    currPage = WhatPage()
    and then substitute currPage in where you now have c:\test.txt

    Code:
      
      Function WhatPage()
         WhatPage = Request.ServerVariables("URL")
      
         x = InStrRev(WhatPage,"/",-1)
    
         If x > 0 Then
            WhatPage = Mid(WhatPage,x+1)
         End If
      End Function
    If this isn't what you want then sorry for taking up your time.

    BaldEagle

  • #5
    New Coder
    Join Date
    Mar 2006
    Location
    Australia
    Posts
    43
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Yep Baldeagle, that's just what I was after. Thanks so much for your help. Knew it had to be simple...
    pp
    -------------------------------------
    "Laziness is the mother of invention" - Thomas Edison (not really)

  • #6
    New Coder
    Join Date
    Mar 2006
    Location
    Australia
    Posts
    43
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Well actually, Baldeagle, your function didn't quite work because the server needed the physical path of the file. But this seems to work:
    Code:
    Dim fs,f
    Set fs=Server.CreateObject("Scripting.FileSystemObject")
    currFile=Request.ServerVariables("APPL_PHYSICAL_PATH") & Mid(Replace(Request.ServerVariables("PATH_INFO"),"/","\"),2)
    Set f=fs.GetFile(currFile)
    Response.Write("Last revised: " & f.DateLastModified)
    set f=nothing
    set fs=nothing
    Haven't tried it on the live server yet, but fingers crossed!
    pp
    -------------------------------------
    "Laziness is the mother of invention" - Thomas Edison (not really)

  • #7
    Senior Coder
    Join Date
    Jun 2002
    Location
    Zwolle, The Netherlands
    Posts
    1,120
    Thanks
    2
    Thanked 31 Times in 31 Posts
    you could also use ServerVariables("SCRIPT_NAME") to get the filename instead of parsing the url....
    I am the luckiest man in the world

  • #8
    Regular Coder
    Join Date
    Apr 2005
    Location
    Lisbon, CT
    Posts
    339
    Thanks
    0
    Thanked 0 Times in 0 Posts
    My bad on the function. It worked locally for me but I was not caring about the full path.

    BaldEagle

    {edit} Roelf makes a good point. I didn't use it because I have never used it before and was unsure from the description exactly what would be returned. As he said you can eliminate the parsing junk.
    Last edited by BaldEagle; 04-13-2006 at 06:59 PM.


  •  

    Posting Permissions

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