Page 1 of 1

document write from txt file into page???

Posted: Mon 06 Oct 2014 4:45 am
by ace2
I've been playing around with this, i echo the time into a text file and add to document.write to put it into the site.
It's a little messy what i'm doing, so i'm trying to fix it up a little...
So to explain, my camera switches on and echos the time to lapseon.txt using the CMD below

Code: Select all

if %Hour%==0 set "Hour=12"
set "Allm=%Hour%.%Min%"
echo document.write('%Allm% AM');> lapseon.txt
(manually having to add the AM/PM stamp)
this outputs like this in the text file

Code: Select all

document.write('8.20 AM');
On the web site i add this

Code: Select all

<script type="text/javascript" src="lapseon.txt"></script></abbr></td>
Now i can't find a simple command to output time with AM/PM but I found a powershell method that does it, but only the time to file.

Code: Select all

$a.ToShortTimeString() > C:\Cumulus\lapseon.txt
which gives 2:25 PM (as an example)

Does anyone have a method to add the contains of a txt file into website????

Re: document write from txt file into page???

Posted: Mon 06 Oct 2014 6:25 am
by sfws
In pure HTML e.g.

Code: Select all

<object data="filename.txt" type="text/plain" width="150" height="8">

Re: document write from txt file into page???

Posted: Mon 06 Oct 2014 6:44 am
by ace2
sfws wrote:In pure HTML e.g.

Code: Select all

<object data="filename.txt" type="text/plain" width="150" height="8">
I should have added, to go into a table.
http://www.users.on.net/~ace2/status.htm
So not sure that code would work....

Re: document write from txt file into page???

Posted: Tue 07 Oct 2014 11:49 am
by ace2
No one has a solution???

What about it in cmd show time as 12 hour format with am/pm, then I could echo that to the text file like I'm doing...

Re: document write from txt file into page???

Posted: Wed 08 Oct 2014 4:34 am
by ace2
the powershell command is in fact

Code: Select all

$a = Get-Date
$a.ToShortTimeString()

Re: document write from txt file into page???

Posted: Wed 08 Oct 2014 5:38 am
by ace2
Well, i haven't found a better solution to adding a raw txt file into page with out using frames or attempting to resize into a table.
My basic cmd echo to file was ok, but, now i've mixed some powershell into it to write the txt with the difference the AM PM is not manually written.

Code: Select all

$a = Get-Date
$Docu = "document.write('"
$time = $a.ToShortTimeString()
$docend = "');"
$docu + $time + $docend | Out-File C:\Cumulus\scripts\lapseresult.txt
outputs

Code: Select all

document.write('8.10 PM');
to the txt file....

crude but works.....