include page based on week of year.

Discussion in 'ASP General' started by .:mmac:., Jan 13, 2005.

  1. .:mmac:.

    .:mmac:. Guest

    I have to update a page every week. I get the page ahead of time so I used
    the "scheduled includes" webbot in Frontpage only to find that I would have
    to refresh the page every week to have it work. That is silly, it should run
    by itself. so...
    I asked the question in the FP group and I was offered this pseudocode
    to do it by month which would work if it's possible to do it by week without
    writing 52 seperate lines, one for each week which would change each year
    and have to be rewritten each year.

    <% If Now()>date("1/3/2005") then %>
    <!-- #include file="includes/mar.asp" -->
    <% elseif Now()>date("1/2/2005") then %>
    <!-- #include file="includes/feb.asp" -->
    <% else %>
    <!-- #include file="includes/jan.asp" -->
    <% endif %>

    Now the goal for me would be something that would calculate which week of
    the year (any year) it is.
    i.e. Jan 1-7 = w1.htm , Jan 8-15= w2.htm etc. and return a Wx.htm for each
    week.
    That way all I have to do is save a wx.htm file where x= week of year.
    so ... how can I caclulate what week of the year it is?
    .:mmac:., Jan 13, 2005
    #1
    1. Advertising

  2. ".:mmac:." <lost@sea> wrote in message
    news:%23JFhvSZ%...
    > I have to update a page every week. I get the page ahead of time so I used
    > the "scheduled includes" webbot in Frontpage only to find that I would

    have
    > to refresh the page every week to have it work. That is silly, it should

    run
    > by itself. so...
    > I asked the question in the FP group and I was offered this pseudocode
    > to do it by month which would work if it's possible to do it by week

    without
    > writing 52 seperate lines, one for each week which would change each year
    > and have to be rewritten each year.
    >
    > <% If Now()>date("1/3/2005") then %>
    > <!-- #include file="includes/mar.asp" -->
    > <% elseif Now()>date("1/2/2005") then %>
    > <!-- #include file="includes/feb.asp" -->
    > <% else %>
    > <!-- #include file="includes/jan.asp" -->
    > <% endif %>
    >
    > Now the goal for me would be something that would calculate which week of
    > the year (any year) it is.
    > i.e. Jan 1-7 = w1.htm , Jan 8-15= w2.htm etc. and return a Wx.htm for

    each
    > week.
    > That way all I have to do is save a wx.htm file where x= week of year.
    > so ... how can I caclulate what week of the year it is?
    >
    >

    Use the DatePart function. Here's the online documentation:
    http://www.msdn.microsoft.com/library/en-us/script56/html/vsfctdatepart.asp
    Chris Hohmann, Jan 13, 2005
    #2
    1. Advertising

  3. .:mmac:.

    McKirahan Guest

    ".:mmac:." <lost@sea> wrote in message
    news:#JFhvSZ#...
    > I have to update a page every week. I get the page ahead of time so I used
    > the "scheduled includes" webbot in Frontpage only to find that I would

    have
    > to refresh the page every week to have it work. That is silly, it should

    run
    > by itself. so...
    > I asked the question in the FP group and I was offered this pseudocode
    > to do it by month which would work if it's possible to do it by week

    without
    > writing 52 seperate lines, one for each week which would change each year
    > and have to be rewritten each year.
    >
    > <% If Now()>date("1/3/2005") then %>
    > <!-- #include file="includes/mar.asp" -->
    > <% elseif Now()>date("1/2/2005") then %>
    > <!-- #include file="includes/feb.asp" -->
    > <% else %>
    > <!-- #include file="includes/jan.asp" -->
    > <% endif %>
    >
    > Now the goal for me would be something that would calculate which week of
    > the year (any year) it is.
    > i.e. Jan 1-7 = w1.htm , Jan 8-15= w2.htm etc. and return a Wx.htm for

    each
    > week.
    > That way all I have to do is save a wx.htm file where x= week of year.
    > so ... how can I caclulate what week of the year it is?



    Will January 1 - 7 always be Week 1?

    Will Week 53 always consist of just one or two days?
    McKirahan, Jan 13, 2005
    #3
  4. .:mmac:.

    Mark Schupp Guest

    Are the includes just generating static HTML (as is hinted in the later part
    of the post)?

    If so use script to compute the name of the file based on the date and use
    the filesystem object to read the contents, then write it out to the client
    (may be able to use server.execute as well). If the included html is the
    same for all pages then you might even want to cache it in an application
    variable and only read the file on the first day of the week.

    --
    Mark Schupp
    Head of Development
    Integrity eLearning
    www.ielearning.com


    ".:mmac:." <lost@sea> wrote in message
    news:%23JFhvSZ%...
    > I have to update a page every week. I get the page ahead of time so I used
    > the "scheduled includes" webbot in Frontpage only to find that I would

    have
    > to refresh the page every week to have it work. That is silly, it should

    run
    > by itself. so...
    > I asked the question in the FP group and I was offered this pseudocode
    > to do it by month which would work if it's possible to do it by week

    without
    > writing 52 seperate lines, one for each week which would change each year
    > and have to be rewritten each year.
    >
    > <% If Now()>date("1/3/2005") then %>
    > <!-- #include file="includes/mar.asp" -->
    > <% elseif Now()>date("1/2/2005") then %>
    > <!-- #include file="includes/feb.asp" -->
    > <% else %>
    > <!-- #include file="includes/jan.asp" -->
    > <% endif %>
    >
    > Now the goal for me would be something that would calculate which week of
    > the year (any year) it is.
    > i.e. Jan 1-7 = w1.htm , Jan 8-15= w2.htm etc. and return a Wx.htm for

    each
    > week.
    > That way all I have to do is save a wx.htm file where x= week of year.
    > so ... how can I caclulate what week of the year it is?
    >
    >
    Mark Schupp, Jan 13, 2005
    #4
  5. .:mmac:.

    McKirahan Guest

    "McKirahan" <> wrote in message
    news:...
    > ".:mmac:." <lost@sea> wrote in message
    > news:#JFhvSZ#...
    > > I have to update a page every week. I get the page ahead of time so I

    used
    > > the "scheduled includes" webbot in Frontpage only to find that I would

    > have
    > > to refresh the page every week to have it work. That is silly, it should

    > run
    > > by itself. so...
    > > I asked the question in the FP group and I was offered this

    pseudocode
    > > to do it by month which would work if it's possible to do it by week

    > without
    > > writing 52 seperate lines, one for each week which would change each

    year
    > > and have to be rewritten each year.
    > >
    > > <% If Now()>date("1/3/2005") then %>
    > > <!-- #include file="includes/mar.asp" -->
    > > <% elseif Now()>date("1/2/2005") then %>
    > > <!-- #include file="includes/feb.asp" -->
    > > <% else %>
    > > <!-- #include file="includes/jan.asp" -->
    > > <% endif %>
    > >
    > > Now the goal for me would be something that would calculate which week

    of
    > > the year (any year) it is.
    > > i.e. Jan 1-7 = w1.htm , Jan 8-15= w2.htm etc. and return a Wx.htm for

    > each
    > > week.
    > > That way all I have to do is save a wx.htm file where x= week of year.
    > > so ... how can I caclulate what week of the year it is?

    >
    >
    > Will January 1 - 7 always be Week 1?
    >
    > Will Week 53 always consist of just one or two days?


    This will generate an "include file" statement.

    <%
    Dim incl
    incl = "<!--#include file=" & Chr(34) & "w##.htm" & Chr(34) & "-->"
    Dim week
    week = Replace(incl,"##",Int((DatePart("y",Date())+6)/7))
    Response.Write week & vbCrLf
    %>

    However, AFAIK, you can't generate an "include file" from within ASP then
    have it do its thing.

    "... server side include files are inserted into their holding file before
    any of the holding file is ... processed by ASP..." --
    http://www.codefixer.com/tutorials/dynamic_includes.asp
    McKirahan, Jan 13, 2005
    #5
  6. .:mmac:.

    McKirahan Guest

    [snip]

    However, instead of generating an "include file", you could just open the
    file via FSO:

    <% Option Explicit
    '*
    Dim strOTF
    strOTF = Request.ServerVariables("PATH_TRANSLATED")
    strOTF = Left(strOTF,InStrRev(strOTF,"\"))
    strOTF = strOTF & "w" & Int((DatePart("y",Date())+6)/7) & ".htm"
    '*
    Dim objFSO
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    If objFSO.FilExists(strOTF) Then
    Dim objOTF
    Set objOTF = objFSO.OpenTextFile(strOTF,1)
    strOTF = objOTF.ReadAll()
    Set objOTF = Nothing
    End If
    Set objFSO = Nothing
    '*
    Response.Write strOTF
    %>
    McKirahan, Jan 13, 2005
    #6
  7. .:mmac:.

    mmac Guest

    "McKirahan" <> wrote in message
    news:...
    > ".:mmac:." <lost@sea> wrote in message
    > news:#JFhvSZ#...
    >> I have to update a page every week. I get the page ahead of time so I
    >> used
    >> the "scheduled includes" webbot in Frontpage only to find that I would

    > have
    >> to refresh the page every week to have it work. That is silly, it should

    > run
    >> by itself. so...
    >> I asked the question in the FP group and I was offered this
    >> pseudocode
    >> to do it by month which would work if it's possible to do it by week

    > without
    >> writing 52 seperate lines, one for each week which would change each year
    >> and have to be rewritten each year.
    >>
    >> <% If Now()>date("1/3/2005") then %>
    >> <!-- #include file="includes/mar.asp" -->
    >> <% elseif Now()>date("1/2/2005") then %>
    >> <!-- #include file="includes/feb.asp" -->
    >> <% else %>
    >> <!-- #include file="includes/jan.asp" -->
    >> <% endif %>
    >>
    >> Now the goal for me would be something that would calculate which week of
    >> the year (any year) it is.
    >> i.e. Jan 1-7 = w1.htm , Jan 8-15= w2.htm etc. and return a Wx.htm for

    > each
    >> week.
    >> That way all I have to do is save a wx.htm file where x= week of year.
    >> so ... how can I caclulate what week of the year it is?

    >
    >
    > Will January 1 - 7 always be Week 1?
    >
    > Will Week 53 always consist of just one or two days?


    yes , for this application it will.
    week 53 would be bundled into week 52
    mmac, Jan 13, 2005
    #7
  8. .:mmac:.

    McKirahan Guest

    "mmac" <> wrote in message
    news:uKXK7Vb#...
    >
    > > Will January 1 - 7 always be Week 1?
    > >
    > > Will Week 53 always consist of just one or two days?

    >
    > yes , for this application it will.
    > week 53 would be bundled into week 52


    [snip]

    Then insert this line just before "Dim objFSO" in the solution I posted
    earlier:

    strOTF = Replace(strOTF,"\w53.htm","\w52.htm")
    McKirahan, Jan 13, 2005
    #8
  9. .:mmac:.

    .:mmac:. Guest

    I tried the example you gave and it generates the following line this week :
    <!--#include file="w3.htm"-->
    which looks great but yet there is nothing included in the page?!
    the page is an ASP page but the included page is htm so the warning about
    dynamic include wouldn't apply right?
    What did I miss?
    I am going to try your other (FSO) example next but this was so easy I don't
    see what I could have missed.
    Help?



    >> > I have to update a page every week. I get the page ahead of time so I

    > used
    >> > the "scheduled includes" webbot in Frontpage only to find that I would

    >> have
    >> > to refresh the page every week to have it work. That is silly, it
    >> > should

    >> run
    >> > by itself. so...
    >> > I asked the question in the FP group and I was offered this

    > pseudocode
    >> > to do it by month which would work if it's possible to do it by week

    >> without
    >> > writing 52 seperate lines, one for each week which would change each

    > year
    >> > and have to be rewritten each year.
    >> >
    >> > <% If Now()>date("1/3/2005") then %>
    >> > <!-- #include file="includes/mar.asp" -->
    >> > <% elseif Now()>date("1/2/2005") then %>
    >> > <!-- #include file="includes/feb.asp" -->
    >> > <% else %>
    >> > <!-- #include file="includes/jan.asp" -->
    >> > <% endif %>
    >> >
    >> > Now the goal for me would be something that would calculate which week

    > of
    >> > the year (any year) it is.
    >> > i.e. Jan 1-7 = w1.htm , Jan 8-15= w2.htm etc. and return a Wx.htm for

    >> each
    >> > week.
    >> > That way all I have to do is save a wx.htm file where x= week of year.
    >> > so ... how can I caclulate what week of the year it is?

    >>
    >>
    >> Will January 1 - 7 always be Week 1?
    >>
    >> Will Week 53 always consist of just one or two days?

    >
    > This will generate an "include file" statement.
    >
    > <%
    > Dim incl
    > incl = "<!--#include file=" & Chr(34) & "w##.htm" & Chr(34) & "-->"
    > Dim week
    > week = Replace(incl,"##",Int((DatePart("y",Date())+6)/7))
    > Response.Write week & vbCrLf
    > %>
    >
    > However, AFAIK, you can't generate an "include file" from within ASP then
    > have it do its thing.
    >
    > "... server side include files are inserted into their holding file before
    > any of the holding file is ... processed by ASP..." --
    > http://www.codefixer.com/tutorials/dynamic_includes.asp
    >
    >
    .:mmac:., Jan 16, 2005
    #9
  10. .:mmac:.

    .:mmac:. Guest

    The included file is a doc file, created by a secretary, converted to a .htm
    web page within Word and then dropped into a directory on the server and
    then it's my job to "include" it on the page. It isn't generated by any
    automated process.
    If I understand the question.
    The VB script solution is testing the limit of my knowledge but I am keeping
    up so far. :)

    "Mark Schupp" <> wrote in message
    news:eWrVxGa%...
    > Are the includes just generating static HTML (as is hinted in the later
    > part
    > of the post)?
    >
    > If so use script to compute the name of the file based on the date and use
    > the filesystem object to read the contents, then write it out to the
    > client
    > (may be able to use server.execute as well). If the included html is the
    > same for all pages then you might even want to cache it in an application
    > variable and only read the file on the first day of the week.
    >
    > --
    > Mark Schupp
    > Head of Development
    > Integrity eLearning
    > www.ielearning.com
    >
    >
    > ".:mmac:." <lost@sea> wrote in message
    > news:%23JFhvSZ%...
    >> I have to update a page every week. I get the page ahead of time so I
    >> used
    >> the "scheduled includes" webbot in Frontpage only to find that I would

    > have
    >> to refresh the page every week to have it work. That is silly, it should

    > run
    >> by itself. so...
    >> I asked the question in the FP group and I was offered this
    >> pseudocode
    >> to do it by month which would work if it's possible to do it by week

    > without
    >> writing 52 seperate lines, one for each week which would change each year
    >> and have to be rewritten each year.
    >>
    >> <% If Now()>date("1/3/2005") then %>
    >> <!-- #include file="includes/mar.asp" -->
    >> <% elseif Now()>date("1/2/2005") then %>
    >> <!-- #include file="includes/feb.asp" -->
    >> <% else %>
    >> <!-- #include file="includes/jan.asp" -->
    >> <% endif %>
    >>
    >> Now the goal for me would be something that would calculate which week of
    >> the year (any year) it is.
    >> i.e. Jan 1-7 = w1.htm , Jan 8-15= w2.htm etc. and return a Wx.htm for

    > each
    >> week.
    >> That way all I have to do is save a wx.htm file where x= week of year.
    >> so ... how can I caclulate what week of the year it is?
    >>
    >>

    >
    >
    .:mmac:., Jan 16, 2005
    #10
  11. .:mmac:.

    .:mmac:. Guest

    This script generated an error that looks familar to me as a silly mistake
    in my application of it but I can't recall what it was:
    Microsoft VBScript compilation error '800a0400'

    Expected statement

    /OYB/Test.asp, line 40

    Option Explicitand it points to the First "O" in Option
    "McKirahan" <> wrote in message
    news:...
    > "mmac" <> wrote in message
    > news:uKXK7Vb#...
    >>
    >> > Will January 1 - 7 always be Week 1?
    >> >
    >> > Will Week 53 always consist of just one or two days?

    >>
    >> yes , for this application it will.
    >> week 53 would be bundled into week 52

    >
    > [snip]
    >
    > Then insert this line just before "Dim objFSO" in the solution I posted
    > earlier:
    >
    > strOTF = Replace(strOTF,"\w53.htm","\w52.htm")
    >
    >
    .:mmac:., Jan 16, 2005
    #11
  12. .:mmac:.

    McKirahan Guest

    ".:mmac:." <> wrote in message
    news:OVy5ds$#...
    > This script generated an error that looks familar to me as a silly mistake
    > in my application of it but I can't recall what it was:
    > Microsoft VBScript compilation error '800a0400'
    >
    > Expected statement
    >
    > /OYB/Test.asp, line 40
    >
    > Option Explicitand it points to the First "O" in Option
    > "McKirahan" <> wrote in message
    > news:...
    > > "mmac" <> wrote in message
    > > news:uKXK7Vb#...
    > >>
    > >> > Will January 1 - 7 always be Week 1?
    > >> >
    > >> > Will Week 53 always consist of just one or two days?
    > >>
    > >> yes , for this application it will.
    > >> week 53 would be bundled into week 52

    > >
    > > [snip]
    > >
    > > Then insert this line just before "Dim objFSO" in the solution I posted
    > > earlier:
    > >
    > > strOTF = Replace(strOTF,"\w53.htm","\w52.htm")
    > >


    Oops, I used the wrong variable a I didn't test it; try this:

    Dim strHTM
    strHTM = "w" & Int((DatePart("y",Date())+6)/7) & ".htm"
    strHTM = Replace(strHTM,"w53.htm","w52.htm")
    McKirahan, Jan 16, 2005
    #12
  13. .:mmac:.

    .:mmac:. Guest

    Ummm... Where?
    It looks like you are replacing the strOTF with strHTM but the strOTF is
    used in more places. Should I replace all?
    Where precisely should I replace it? i.e. the Response.Write still writes
    the strOTF var.
    here is the script as it is now,
    <% Option Explicit
    '*
    Dim strOTF
    strOTF = Request.ServerVariables("PATH_TRANSLATED")
    strOTF = Left(strOTF,InStrRev(strOTF,"\"))
    strOTF = strOTF & "w" & Int((DatePart("y",Date())+6)/7) & ".htm"
    '*
    Dim objFSO
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    If objFSO.FilExists(strOTF) Then
    Dim objOTF
    Set objOTF = objFSO.OpenTextFile(strOTF,1)
    strOTF = objOTF.ReadAll()
    Set objOTF = Nothing
    End If
    Set objFSO = Nothing
    '*
    Response.Write strOTF
    %>

    BTW, there is no Line 40 on the page as written, the server must be
    recompiling something so I don't know where to look for Line 40 as refernced
    in the error message.

    >> This script generated an error that looks familar to me as a silly
    >> mistake
    >> in my application of it but I can't recall what it was:
    >> Microsoft VBScript compilation error '800a0400'
    >>
    >> Expected statement
    >>
    >> /OYB/Test.asp, line 40
    >>
    >> Option Explicitand it points to the First "O" in Option
    >> "McKirahan" <> wrote in message
    >> news:...
    >> > "mmac" <> wrote in message
    >> > news:uKXK7Vb#...
    >> >>
    >> >> > Will January 1 - 7 always be Week 1?
    >> >> >
    >> >> > Will Week 53 always consist of just one or two days?
    >> >>
    >> >> yes , for this application it will.
    >> >> week 53 would be bundled into week 52
    >> >
    >> > [snip]
    >> >
    >> > Then insert this line just before "Dim objFSO" in the solution I posted
    >> > earlier:
    >> >
    >> > strOTF = Replace(strOTF,"\w53.htm","\w52.htm")
    >> >

    >
    > Oops, I used the wrong variable a I didn't test it; try this:
    >
    > Dim strHTM
    > strHTM = "w" & Int((DatePart("y",Date())+6)/7) & ".htm"
    > strHTM = Replace(strHTM,"w53.htm","w52.htm")
    >
    >
    >
    .:mmac:., Jan 16, 2005
    #13
  14. .:mmac:.

    .:mmac:. Guest

    error still,

    Microsoft VBScript compilation error '800a0400'
    Expected statement
    /OYB/Test1.asp, line 39
    Option Explicit
    ^
    Also there is NO line 39 in the code, Thats annoying. It's like I'm not
    closing a tag.


    "McKirahan" <> wrote in message
    news:...
    > ".:mmac:." <lost@sea> wrote in message
    > news:ufP7FgB$...
    >> Ummm... Where?
    >> It looks like you are replacing the strOTF with strHTM but the strOTF is
    >> used in more places. Should I replace all?
    >> Where precisely should I replace it? i.e. the Response.Write still writes
    >> the strOTF var.
    >> here is the script as it is now,
    >> <% Option Explicit
    >> '*
    >> Dim strOTF
    >> strOTF = Request.ServerVariables("PATH_TRANSLATED")
    >> strOTF = Left(strOTF,InStrRev(strOTF,"\"))
    >> strOTF = strOTF & "w" & Int((DatePart("y",Date())+6)/7) & ".htm"
    >> '*
    >> Dim objFSO
    >> Set objFSO = CreateObject("Scripting.FileSystemObject")
    >> If objFSO.FilExists(strOTF) Then
    >> Dim objOTF
    >> Set objOTF = objFSO.OpenTextFile(strOTF,1)
    >> strOTF = objOTF.ReadAll()
    >> Set objOTF = Nothing
    >> End If
    >> Set objFSO = Nothing
    >> '*
    >> Response.Write strOTF
    >> %>
    >>
    >> BTW, there is no Line 40 on the page as written, the server must be
    >> recompiling something so I don't know where to look for Line 40 as

    > refernced
    >> in the error message.

    >
    > [snip]
    >
    > Sorry, about "strHTM"; I must have had it left over from something.
    >
    > The above is missing an "e" in "FileExists"; perhaps that's the error.
    >
    > Also, I'd forgottne about Server.MapPath() -- brain cramp.
    >
    > Try this and let me know.
    >
    > <% Option Explicit
    > '*
    > Dim strOTF
    > strOTF = "w" & Int((DatePart("y",Date())+6)/7) & ".htm"
    > strOTF = Replace(strOTF,"w53.htm","w52.htm")
    > strOTF = Server.MapPath(strOTF)
    > Response.Write strOTF & "<br>"
    > '* remove the above line after testing.
    > '*
    > Dim objFSO
    > Set objFSO = CreateObject("Scripting.FileSystemObject")
    > If objFSO.FileExists(strOTF) Then
    > Dim objOTF
    > Set objOTF = objFSO.OpenTextFile(strOTF,1)
    > strOTF = objOTF.ReadAll()
    > Set objOTF = Nothing
    > End If
    > Set objFSO = Nothing
    > '*
    > Response.Write strOTF
    > %>
    >
    >
    .:mmac:., Jan 17, 2005
    #14
  15. .:mmac:.

    .:mmac:. Guest

    One more note,
    If I comment out "Option Explicit" then I get the path to the file printed
    on the web page
    i.e. E:/www/domain.com/directory/w3.htm
    SO that looks like the script is doing the job but the presentation is
    wrong. Hmmm.

    "McKirahan" <> wrote in message
    news:...
    > ".:mmac:." <lost@sea> wrote in message
    > news:ufP7FgB$...
    >> Ummm... Where?
    >> It looks like you are replacing the strOTF with strHTM but the strOTF is
    >> used in more places. Should I replace all?
    >> Where precisely should I replace it? i.e. the Response.Write still writes
    >> the strOTF var.
    >> here is the script as it is now,
    >> <% Option Explicit
    >> '*
    >> Dim strOTF
    >> strOTF = Request.ServerVariables("PATH_TRANSLATED")
    >> strOTF = Left(strOTF,InStrRev(strOTF,"\"))
    >> strOTF = strOTF & "w" & Int((DatePart("y",Date())+6)/7) & ".htm"
    >> '*
    >> Dim objFSO
    >> Set objFSO = CreateObject("Scripting.FileSystemObject")
    >> If objFSO.FilExists(strOTF) Then
    >> Dim objOTF
    >> Set objOTF = objFSO.OpenTextFile(strOTF,1)
    >> strOTF = objOTF.ReadAll()
    >> Set objOTF = Nothing
    >> End If
    >> Set objFSO = Nothing
    >> '*
    >> Response.Write strOTF
    >> %>
    >>
    >> BTW, there is no Line 40 on the page as written, the server must be
    >> recompiling something so I don't know where to look for Line 40 as

    > refernced
    >> in the error message.

    >
    > [snip]
    >
    > Sorry, about "strHTM"; I must have had it left over from something.
    >
    > The above is missing an "e" in "FileExists"; perhaps that's the error.
    >
    > Also, I'd forgottne about Server.MapPath() -- brain cramp.
    >
    > Try this and let me know.
    >
    > <% Option Explicit
    > '*
    > Dim strOTF
    > strOTF = "w" & Int((DatePart("y",Date())+6)/7) & ".htm"
    > strOTF = Replace(strOTF,"w53.htm","w52.htm")
    > strOTF = Server.MapPath(strOTF)
    > Response.Write strOTF & "<br>"
    > '* remove the above line after testing.
    > '*
    > Dim objFSO
    > Set objFSO = CreateObject("Scripting.FileSystemObject")
    > If objFSO.FileExists(strOTF) Then
    > Dim objOTF
    > Set objOTF = objFSO.OpenTextFile(strOTF,1)
    > strOTF = objOTF.ReadAll()
    > Set objOTF = Nothing
    > End If
    > Set objFSO = Nothing
    > '*
    > Response.Write strOTF
    > %>
    >
    >
    .:mmac:., Jan 17, 2005
    #15
  16. .:mmac:.

    McKirahan Guest

    ".:mmac:." <lost@sea> wrote in message
    news:#i3AkCD$...
    > One more note,
    > If I comment out "Option Explicit" then I get the path to the file printed
    > on the web page
    > i.e. E:/www/domain.com/directory/w3.htm
    > SO that looks like the script is doing the job but the presentation is
    > wrong. Hmmm.
    >
    > "McKirahan" <> wrote in message
    > news:...


    [snip]

    > > Try this and let me know.
    > >
    > > <% Option Explicit
    > > '*
    > > Dim strOTF
    > > strOTF = "w" & Int((DatePart("y",Date())+6)/7) & ".htm"
    > > strOTF = Replace(strOTF,"w53.htm","w52.htm")
    > > strOTF = Server.MapPath(strOTF)
    > > Response.Write strOTF & "<br>"
    > > '* remove the above line after testing.
    > > '*
    > > Dim objFSO
    > > Set objFSO = CreateObject("Scripting.FileSystemObject")
    > > If objFSO.FileExists(strOTF) Then
    > > Dim objOTF
    > > Set objOTF = objFSO.OpenTextFile(strOTF,1)
    > > strOTF = objOTF.ReadAll()
    > > Set objOTF = Nothing
    > > End If
    > > Set objFSO = Nothing
    > > '*
    > > Response.Write strOTF
    > > %>


    Did you add any other code above my script?
    "Option Explicit" should be the first line in the script or try:

    <%@ Language="VBScript" %>
    <% Option Explicit


    The reason you see the path+filename is because of the first Response.Write
    (for testing).

    If the file doesn't exist then the script won't do anything more per:

    "If objFSO.FileExists(strOTF) Then"

    Does the file exist?

    Also, please try the latest version which uses "Server.MapPath()".
    McKirahan, Jan 17, 2005
    #16
  17. .:mmac:.

    Mark Schupp Guest

    The other respondents are working with you on the code to read and send the
    file contents. Just one note:

    If the html files are being created from word documents by word then they
    will contain a complete HTML document. If you include that in a page that
    also generates an HTML document then you will end up with duplicate <HTML>,
    </HTML>, <BODY>, </BODY> tags. This may confuse the browser. You will need
    to extract the data that you want to embed in your page from the HTML
    document that you read in.

    If you are only going to display the page as it was created by word then
    just do a response.redirect to it once you determine the path.

    --
    Mark Schupp
    Head of Development
    Integrity eLearning
    www.ielearning.com


    ".:mmac:." <> wrote in message
    news:ugVF1q$%...
    > The included file is a doc file, created by a secretary, converted to a

    ..htm
    > web page within Word and then dropped into a directory on the server and
    > then it's my job to "include" it on the page. It isn't generated by any
    > automated process.
    > If I understand the question.
    > The VB script solution is testing the limit of my knowledge but I am

    keeping
    > up so far. :)
    >
    > "Mark Schupp" <> wrote in message
    > news:eWrVxGa%...
    > > Are the includes just generating static HTML (as is hinted in the later
    > > part
    > > of the post)?
    > >
    > > If so use script to compute the name of the file based on the date and

    use
    > > the filesystem object to read the contents, then write it out to the
    > > client
    > > (may be able to use server.execute as well). If the included html is the
    > > same for all pages then you might even want to cache it in an

    application
    > > variable and only read the file on the first day of the week.
    > >
    > > --
    > > Mark Schupp
    > > Head of Development
    > > Integrity eLearning
    > > www.ielearning.com
    > >
    > >
    > > ".:mmac:." <lost@sea> wrote in message
    > > news:%23JFhvSZ%...
    > >> I have to update a page every week. I get the page ahead of time so I
    > >> used
    > >> the "scheduled includes" webbot in Frontpage only to find that I would

    > > have
    > >> to refresh the page every week to have it work. That is silly, it

    should
    > > run
    > >> by itself. so...
    > >> I asked the question in the FP group and I was offered this
    > >> pseudocode
    > >> to do it by month which would work if it's possible to do it by week

    > > without
    > >> writing 52 seperate lines, one for each week which would change each

    year
    > >> and have to be rewritten each year.
    > >>
    > >> <% If Now()>date("1/3/2005") then %>
    > >> <!-- #include file="includes/mar.asp" -->
    > >> <% elseif Now()>date("1/2/2005") then %>
    > >> <!-- #include file="includes/feb.asp" -->
    > >> <% else %>
    > >> <!-- #include file="includes/jan.asp" -->
    > >> <% endif %>
    > >>
    > >> Now the goal for me would be something that would calculate which week

    of
    > >> the year (any year) it is.
    > >> i.e. Jan 1-7 = w1.htm , Jan 8-15= w2.htm etc. and return a Wx.htm for

    > > each
    > >> week.
    > >> That way all I have to do is save a wx.htm file where x= week of year.
    > >> so ... how can I caclulate what week of the year it is?
    > >>
    > >>

    > >
    > >

    >
    >
    Mark Schupp, Jan 17, 2005
    #17
  18. .:mmac:.

    .:mmac:. Guest

    Thanks for your persistance with this.
    here is the whole page of code:

    <%@ Language="VBScript" %>
    <html><head>
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
    <meta name="GENERATOR" content="Microsoft FrontPage 6.0">
    <meta name="ProgId" content="FrontPage.Editor.Document">
    <title>Using FSO</title>
    <meta name="Microsoft Theme" content="111, default">
    <meta name="Microsoft Border" content="tlb, default">
    </head><body>

    <p>&nbsp;

    <% 'Option Explicit
    ' This Works!!! 1-17-05
    '*
    Dim strOTF
    strOTF = "Week" & Int((DatePart("y",Date())+6)/7) & ".htm"
    strOTF = Replace(strOTF,"Week53.htm","Week52.htm")
    strOTF = Server.MapPath(strOTF)
    ' Response.Write strOTF & "<br>"
    '* remove the above line after testing.
    '*
    Dim objFSO
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    If objFSO.FileExists(strOTF) Then
    Dim objOTF
    Set objOTF = objFSO.OpenTextFile(strOTF,1)
    strOTF = objOTF.ReadAll()
    Set objOTF = Nothing
    End If
    Set objFSO = Nothing
    '*
    Response.Write strOTF
    %>
    </p></body></html>


    If I comment out the "Option Explicit" as shown above, the page runs fine
    now, (not sure what changed, but it works, thank you. :~}but..

    If I don't comment out the "Option Explicit" I get this error:
    Microsoft VBScript compilation error '800a0400'
    Expected statement
    /OYB/Test1.asp, line 41
    Option Explicit
    ^
    Is this going to be a problem?



    "McKirahan" <> wrote in message
    news:p...
    > ".:mmac:." <lost@sea> wrote in message
    > news:#i3AkCD$...
    >> One more note,
    >> If I comment out "Option Explicit" then I get the path to the file
    >> printed
    >> on the web page
    >> i.e. E:/www/domain.com/directory/w3.htm
    >> SO that looks like the script is doing the job but the presentation is
    >> wrong. Hmmm.
    >>
    >> "McKirahan" <> wrote in message
    >> news:...

    >
    > [snip]
    >
    >> > Try this and let me know.
    >> >
    >> > <% Option Explicit
    >> > '*
    >> > Dim strOTF
    >> > strOTF = "w" & Int((DatePart("y",Date())+6)/7) & ".htm"
    >> > strOTF = Replace(strOTF,"w53.htm","w52.htm")
    >> > strOTF = Server.MapPath(strOTF)
    >> > Response.Write strOTF & "<br>"
    >> > '* remove the above line after testing.
    >> > '*
    >> > Dim objFSO
    >> > Set objFSO = CreateObject("Scripting.FileSystemObject")
    >> > If objFSO.FileExists(strOTF) Then
    >> > Dim objOTF
    >> > Set objOTF = objFSO.OpenTextFile(strOTF,1)
    >> > strOTF = objOTF.ReadAll()
    >> > Set objOTF = Nothing
    >> > End If
    >> > Set objFSO = Nothing
    >> > '*
    >> > Response.Write strOTF
    >> > %>

    >
    > Did you add any other code above my script?
    > "Option Explicit" should be the first line in the script or try:
    >
    > <%@ Language="VBScript" %>
    > <% Option Explicit
    >
    >
    > The reason you see the path+filename is because of the first
    > Response.Write
    > (for testing).
    >
    > If the file doesn't exist then the script won't do anything more per:
    >
    > "If objFSO.FileExists(strOTF) Then"
    >
    > Does the file exist?
    >
    > Also, please try the latest version which uses "Server.MapPath()".
    >
    >
    .:mmac:., Jan 17, 2005
    #18
  19. .:mmac:.

    McKirahan Guest

    ".:mmac:." <lost@sea> wrote in message
    news:#al7K$O$...
    > Thanks for your persistance with this.
    > here is the whole page of code:
    >
    > <%@ Language="VBScript" %>
    > <html><head>
    > <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
    > <meta name="GENERATOR" content="Microsoft FrontPage 6.0">
    > <meta name="ProgId" content="FrontPage.Editor.Document">
    > <title>Using FSO</title>
    > <meta name="Microsoft Theme" content="111, default">
    > <meta name="Microsoft Border" content="tlb, default">
    > </head><body>
    >
    > <p>&nbsp;
    >
    > <% 'Option Explicit
    > ' This Works!!! 1-17-05
    > '*
    > Dim strOTF
    > strOTF = "Week" & Int((DatePart("y",Date())+6)/7) & ".htm"
    > strOTF = Replace(strOTF,"Week53.htm","Week52.htm")
    > strOTF = Server.MapPath(strOTF)
    > ' Response.Write strOTF & "<br>"
    > '* remove the above line after testing.
    > '*
    > Dim objFSO
    > Set objFSO = CreateObject("Scripting.FileSystemObject")
    > If objFSO.FileExists(strOTF) Then
    > Dim objOTF
    > Set objOTF = objFSO.OpenTextFile(strOTF,1)
    > strOTF = objOTF.ReadAll()
    > Set objOTF = Nothing
    > End If
    > Set objFSO = Nothing
    > '*
    > Response.Write strOTF
    > %>
    > </p></body></html>
    >
    >
    > If I comment out the "Option Explicit" as shown above, the page runs fine
    > now, (not sure what changed, but it works, thank you. :~}but..
    >
    > If I don't comment out the "Option Explicit" I get this error:
    > Microsoft VBScript compilation error '800a0400'
    > Expected statement
    > /OYB/Test1.asp, line 41
    > Option Explicit
    > ^
    > Is this going to be a problem?


    [snip]

    "Option Explicit" is used to ensure that all variables are declared before
    they're used.

    If it only works without then remove it.

    I'd probably write it like the following:

    <%@ Language="VBScript" %>
    <% Option Explicit
    '*
    Dim strOTF
    strOTF = "Week" & Int((DatePart("y",Date())+6)/7) & ".htm"
    strOTF = Replace(strOTF,"Week53.htm","Week52.htm")
    strOTF = Server.MapPath(strOTF)
    '*
    Dim objFSO
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    If objFSO.FileExists(strOTF) Then
    Dim objOTF
    Set objOTF = objFSO.OpenTextFile(strOTF,1)
    strOTF = objOTF.ReadAll()
    Set objOTF = Nothing
    End If
    Set objFSO = Nothing
    %>
    <html>
    <head>
    <title>Using FSO</title>
    </head>
    <body>
    <p><%=strOTF%></p>
    </body>
    </html>
    McKirahan, Jan 18, 2005
    #19
  20. .:mmac:.

    .:mmac:. Guest

    I see... put it before all the HTML and then call the result?
    I moved it and now I can leave "Option Explicit" alone (uncommented) and it
    works perfect!
    Must be neccessary to put it above all the html processing?
    " <%=strOTF%> " is a powerful command! What is that? Does that mean to put
    the contents of "strOTF" here?
    However it works, this is great and has saved me a real nusiance every week.

    Thank You so much for your help.
    -mmac



    "McKirahan" <> wrote in message
    news:...
    > ".:mmac:." <lost@sea> wrote in message
    > news:#al7K$O$...
    >> Thanks for your persistance with this.
    >> here is the whole page of code:
    >>
    >> <%@ Language="VBScript" %>
    >> <html><head>
    >> <meta http-equiv="Content-Type" content="text/html;
    >> charset=windows-1252">
    >> <meta name="GENERATOR" content="Microsoft FrontPage 6.0">
    >> <meta name="ProgId" content="FrontPage.Editor.Document">
    >> <title>Using FSO</title>
    >> <meta name="Microsoft Theme" content="111, default">
    >> <meta name="Microsoft Border" content="tlb, default">
    >> </head><body>
    >>
    >> <p>&nbsp;
    >>
    >> <% 'Option Explicit
    >> ' This Works!!! 1-17-05
    >> '*
    >> Dim strOTF
    >> strOTF = "Week" & Int((DatePart("y",Date())+6)/7) & ".htm"
    >> strOTF = Replace(strOTF,"Week53.htm","Week52.htm")
    >> strOTF = Server.MapPath(strOTF)
    >> ' Response.Write strOTF & "<br>"
    >> '* remove the above line after testing.
    >> '*
    >> Dim objFSO
    >> Set objFSO = CreateObject("Scripting.FileSystemObject")
    >> If objFSO.FileExists(strOTF) Then
    >> Dim objOTF
    >> Set objOTF = objFSO.OpenTextFile(strOTF,1)
    >> strOTF = objOTF.ReadAll()
    >> Set objOTF = Nothing
    >> End If
    >> Set objFSO = Nothing
    >> '*
    >> Response.Write strOTF
    >> %>
    >> </p></body></html>
    >>
    >>
    >> If I comment out the "Option Explicit" as shown above, the page runs fine
    >> now, (not sure what changed, but it works, thank you. :~}but..
    >>
    >> If I don't comment out the "Option Explicit" I get this error:
    >> Microsoft VBScript compilation error '800a0400'
    >> Expected statement
    >> /OYB/Test1.asp, line 41
    >> Option Explicit
    >> ^
    >> Is this going to be a problem?

    >
    > [snip]
    >
    > "Option Explicit" is used to ensure that all variables are declared before
    > they're used.
    >
    > If it only works without then remove it.
    >
    > I'd probably write it like the following:
    >
    > <%@ Language="VBScript" %>
    > <% Option Explicit
    > '*
    > Dim strOTF
    > strOTF = "Week" & Int((DatePart("y",Date())+6)/7) & ".htm"
    > strOTF = Replace(strOTF,"Week53.htm","Week52.htm")
    > strOTF = Server.MapPath(strOTF)
    > '*
    > Dim objFSO
    > Set objFSO = CreateObject("Scripting.FileSystemObject")
    > If objFSO.FileExists(strOTF) Then
    > Dim objOTF
    > Set objOTF = objFSO.OpenTextFile(strOTF,1)
    > strOTF = objOTF.ReadAll()
    > Set objOTF = Nothing
    > End If
    > Set objFSO = Nothing
    > %>
    > <html>
    > <head>
    > <title>Using FSO</title>
    > </head>
    > <body>
    > <p><%=strOTF%></p>
    > </body>
    > </html>
    >
    >
    .:mmac:., Jan 18, 2005
    #20
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Guest
    Replies:
    3
    Views:
    1,839
    Alexandre
    Dec 22, 2003
  2. Otuatail

    Week of year to full Year

    Otuatail, Dec 8, 2003, in forum: HTML
    Replies:
    4
    Views:
    963
    Toby A Inkster
    Dec 8, 2003
  3. Guest
    Replies:
    3
    Views:
    522
    Alexandre
    Dec 22, 2003
  4. Guest
    Replies:
    3
    Views:
    1,087
    Alexandre
    Dec 22, 2003
  5. SimonC
    Replies:
    13
    Views:
    333
    Dr John Stockton
    Jan 4, 2005
Loading...

Share This Page