This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

read scorefile and make html

Old posts that have not been replied to for several years.
Locked
T
TammeN
Voice
Posts: 4
Joined: Fri Dec 24, 2004 12:39 am
Location: Belgium

read scorefile and make html

Post by TammeN »

Hit here,

please can someone help me a little script?!

i have a game script that write de score file like this:

nick1 1000
nick2 850
nick3 500
...

i want to ouput the scorefile in a html file with position number, nick and score

Code: Select all

<table border="0">
    <tr><td>1.</td><td>nick1</td><td>1000</td></tr>
    <tr><td>2.</td><td>nick2</td><td>850</td></tr>
    <tr><td>3.</td><td>nick3</td><td>500</td></tr>
</table>
this with a update of 90 seconds.

scorefile location
/home/pergy/atira/score/
html location
/home/pergy/WWW/atira/

Thnx
User avatar
demond
Revered One
Posts: 3073
Joined: Sat Jun 12, 2004 9:58 am
Location: San Francisco, CA
Contact:

Post by demond »

Code: Select all

set sfile "/home/pergy/atira/score/sfile.txt"
set hfile "/home/pergy/WWW/atira/hfile.html"

proc update {} {
  set in [open $::sfile]
  set out [open $::hfile w]
  puts $out "<table border=\"0\">"
  set i 0
  while {![eof $in] && [set line [gets $in]] != ""} {
    scan $line "%s %d" nick score
    puts $out "<tr><td>[incr i].</td><td>$nick</td><td>$score</td></tr>"
  }
  puts $out "</table>"
  close $in; close $out
  utimer 90 update
}

update
Locked