+ Post New Thread
Results 1 to 5 of 5
Scripts Thread, Script to write the date to a text file in Coding and Web Development; We have the Lifechannel system here. Its quite boring to log in daily and change the date in the ticker. ...
  1. #1
    Gibbo's Avatar
    Join Date
    Feb 2008
    Location
    Cheshire
    Posts
    891
    Thank Post
    206
    Thanked 343 Times in 238 Posts
    Rep Power
    92

    Script to write the date to a text file

    We have the Lifechannel system here. Its quite boring to log in daily and change the date in the ticker.

    Noseying around the file structure, we see that the text comes from a file called ticker.txt

    How easy would it be to write a batch file that's called at, say, 6am every day that overwrites the existing ticker.txt with a fresh one that says "Welcome to our school. Today is <today's date>"?

    TIA

  2. #2

    glennda's Avatar
    Join Date
    Jun 2009
    Location
    Sussex
    Posts
    7,786
    Thank Post
    272
    Thanked 1,129 Times in 1,025 Posts
    Rep Power
    348
    I use a html webpage with java script - not sure if the system will let you do that - code below.

    HTML Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>Time and date</title>
    </head>
    
    <body>
    <font face=Verdana size =6.8>
    <SCRIPT LANGUAGE="JavaScript">
    <!-- Begin
    
    // Get today's current date.
    var now = new Date();
    
    // Array list of days.
    var days = new Array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday');
    
    // Array list of months.
    var months = new Array('January','February','March','April','May','June','July','August','September','October','November','December');
    
    // Calculate the number of the current day in the week.
    var date = ((now.getDate()<10) ? "0" : "")+ now.getDate();
    
    // Calculate four digit year.
    function fourdigits(number)	{
    	return (number < 1000) ? number + 1900 : number;
    								}
    
    // Join it all together
    today =  days[now.getDay()] + ", " +
             months[now.getMonth()]+ " " +
             date + ", " +
             (fourdigits(now.getYear())) ;
    
    // Print out the data.
    document.write(today);
    
    //  End -->
    </script>
    </body>
    </html>

  3. Thanks to glennda from:

    Gibbo (15th September 2010)

  4. #3

    LosOjos's Avatar
    Join Date
    Dec 2009
    Location
    West Midlands
    Posts
    5,432
    Thank Post
    1,432
    Thanked 1,160 Times in 794 Posts
    Rep Power
    705
    Create a batch file (.bat) that contains something along the lines of:

    Code:
    echo Welcome to our school. Today is %date% > C:\your\path\ticker.txt

    NOTE: That will overwrite the file so that it will only contain that line, so bare that in mind before you try it

  5. Thanks to LosOjos from:

    Gibbo (15th September 2010)

  6. #4
    Gibbo's Avatar
    Join Date
    Feb 2008
    Location
    Cheshire
    Posts
    891
    Thank Post
    206
    Thanked 343 Times in 238 Posts
    Rep Power
    92
    Thanks everyone, far simpler than I imagined!

  7. #5
    Gibbo's Avatar
    Join Date
    Feb 2008
    Location
    Cheshire
    Posts
    891
    Thank Post
    206
    Thanked 343 Times in 238 Posts
    Rep Power
    92
    Had some great fun developing this today. Here's our current release:

    Code:
    'Open up the path to save the information into a text file
    Dim Stuff, myFSO, WriteStuff, dateStamp
    dateStamp = Date()
    
    Const ForWriting = 2
    
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    Set objFile = objFSO.OpenTextFile("E:\media\ticker\ticker.txt", ForWriting)
    
    ' Blank the text file before creating todays data
    objFile.Write ""
    objFile.Close
    
    'Get todays date
    DIM iDay
    iDay = DatePart("w", Date())
    
    SELECT CASE iDay
    Case "1" strDayName = "Sunday"
    Case "2" strDayName = "Monday"
    Case "3" strDayName = "Tuesday"
    Case "4" strDayName = "Wednesday"
    Case "5" strDayName = "Thursday"
    Case "6" strDayName = "Friday"
    Case "7" strDayName = "Saturday"
    END SELECT
    
    'Write information to Text File
    Stuff = "Good morning and welcome to our school. Today is "
    localDate = FormatDateTime(date(), 1)
    joinedup = Stuff + strDayName + " " + localdate + "."
    
    Set myFSO = CreateObject("Scripting.FileSystemObject")
    Set WriteStuff = myFSO.OpenTextFile("E:\media\ticker\ticker.txt", 8, True)
    'WriteStuff.WriteLine(Stuff)
    'WriteStuff.WriteLine(localdate)
    WriteStuff.WriteLine(joinedup)
    WriteStuff.Close
    SET WriteStuff = NOTHING
    SET myFSO = NOTHING
    Assuming anyone else with Lifechannel has their system set up the same way this should work.

SHARE:
+ Post New Thread

Similar Threads

  1. [MS Office - 2010] Convert text column of dates to date values
    By jc1875 in forum Office Software
    Replies: 0
    Last Post: 17th June 2010, 09:51 AM
  2. Replies: 16
    Last Post: 25th February 2010, 08:59 AM
  3. Sanako common file store : write but not read
    By cjohnsonuk in forum Windows Server 2008
    Replies: 0
    Last Post: 7th July 2009, 01:23 PM
  4. Replies: 5
    Last Post: 4th June 2007, 09:10 PM
  5. Replies: 16
    Last Post: 10th February 2006, 07:27 AM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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