- Aug
- 258
- 4
I'm not a web-designer, but sometimes I wanna create html-tables with tcc.
Here I show you how I do it.
If anyone has a better idea or technique, please let me know.
Also suggestions and critique is appeciated ;)
regards
Frank
Here I show you how I do it.
If anyone has a better idea or technique, please let me know.
Also suggestions and critique is appeciated ;)
Code:
@echo off
setlocal
set fontsize=-1
set outfile=disk-report.html
setdos /x-6
set fh=%@fileopen[%outfile,write,t]
set rc=%@filewrite[%fh,<html>]
set rc=%@filewrite[%fh,<body>]
set rc=%@filewrite[%fh,<h2>Disk Usage on %computername</h2>]
set rc=%@filewrite[%fh,<h4>as of: %_isodate, %_time</h4>]
set rc=%@filewrite[%fh,<table border="1" cellspacing="10" cellpadding="20">]
set rc=%@filewrite[%fh,<tr><th>Disk</th>]
set rc=%@filewrite[%fh,<th>Disk Name</th>]
set rc=%@filewrite[%fh,<th>Capacity</th>]
set rc=%@filewrite[%fh,<th>Space Used</th>]
set rc=%@filewrite[%fh,<th>Space Free</th>]
set rc=%@filewrite[%fh,<th>Pct in Use</th></tr>]
set rc=%@filewrite[%fh,<tbody align="center">]
setdos /x0
do drive in /l %_drives
iff %@ready[%drive] eq 1 .and. %@remote[%drive] eq 0 then
set disklabel=%@label[%drive]
set disktotal=%@comma[%@disktotal[%drive,M]]
set diskused=%@comma[%@diskused[%drive,M]]
set diskfree=%@comma[%@diskfree[%drive,M]]
set diskpctused=%@eval[ 100-(%diskfree / %disktotal*100=0) ]
setdos /x-6
set rc=%@filewrite[%fh,<tr><td><font size="%fontsize">%drive</font></td> %=
<td><font size="%fontsize">%disklabel</font></td> %=
<td><font size="%fontsize">%disktotal</font></td> %=
<td><font size="%fontsize">%diskused</font></td> %=
<td><font size="%fontsize">%diskfree</font></td> %=
<td><font size="%fontsize">%[diskpctused]%%</font></td></tr>]
setdos /x0
endiff
enddo
setdos /x-6
set rc=%@filewrite[%fh,</tbody>]
set rc=%@filewrite[%fh,</table>]
set rc=%@filewrite[%fh,<p><br>© Frank</p>]
set rc=%@filewrite[%fh,</body>]
set rc=%@filewrite[%fh,</html>]
setdos /x0
set rc=%@fileclose[%fh]
start %outfile
endlocal
quit
regards
Frank