Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > include page based on week of year.

Reply
Thread Tools

include page based on week of year.

 
 
.:mmac:.
Guest
Posts: n/a
 
      01-13-2005
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?


 
Reply With Quote
 
 
 
 
Chris Hohmann
Guest
Posts: n/a
 
      01-13-2005
".:mmac:." <lost@sea> wrote in message
news:%23JFhvSZ%(E-Mail Removed)...
> 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/librar...ctdatepart.asp


 
Reply With Quote
 
 
 
 
McKirahan
Guest
Posts: n/a
 
      01-13-2005
".:mmac:." <lost@sea> wrote in message
news:#JFhvSZ#(E-Mail Removed)...
> 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?



 
Reply With Quote
 
Mark Schupp
Guest
Posts: n/a
 
      01-13-2005
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%(E-Mail Removed)...
> 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?
>
>



 
Reply With Quote
 
McKirahan
Guest
Posts: n/a
 
      01-13-2005
"McKirahan" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> ".:mmac:." <lost@sea> wrote in message
> news:#JFhvSZ#(E-Mail Removed)...
> > 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


 
Reply With Quote
 
McKirahan
Guest
Posts: n/a
 
      01-13-2005
[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
%>


 
Reply With Quote
 
mmac
Guest
Posts: n/a
 
      01-13-2005

"McKirahan" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> ".:mmac:." <lost@sea> wrote in message
> news:#JFhvSZ#(E-Mail Removed)...
>> 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


 
Reply With Quote
 
McKirahan
Guest
Posts: n/a
 
      01-13-2005
"mmac" <(E-Mail Removed)> wrote in message
news:uKXK7Vb#(E-Mail Removed)...
>
> > 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")


 
Reply With Quote
 
.:mmac:.
Guest
Posts: n/a
 
      01-16-2005
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
>
>



 
Reply With Quote
 
.:mmac:.
Guest
Posts: n/a
 
      01-16-2005
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" <(E-Mail Removed)> wrote in message
news:eWrVxGa%(E-Mail Removed)...
> 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%(E-Mail Removed)...
>> 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?
>>
>>

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
What license/copyright text to include and where to include it whenselling a commercial Python based application? Malcolm Greene Python 1 04-16-2010 10:45 PM
Re: What license/copyright text to include and where to include itwhen selling a commercial Python based application? python@bdurham.com Python 0 04-14-2010 03:33 PM
/* #include <someyhing.h> */ => include it or do not include it?That is the question .... Andreas Bogenberger C Programming 3 02-22-2008 10:53 AM
ASP.NET: Day / Work Week / Week / Month web calendar control with view like MS Outlook ASP .Net 3 12-22-2003 10:42 PM
ASP.NET: Day / Work Week / Week / Month web calendar control with view like MS Outlook ASP .Net Building Controls 3 12-22-2003 10:42 PM



Advertisments