Sync/Load code:
Code: Select all
proc sync {} {
global head tail delim djlist datafile cmdlist website public_channel p$
if { [file exists $datafile] } {
set FD [open $datafile r]
set djlist ""
while { ![eof $FD] } {
gets $FD line
set index [string first ":" $line ]
set name [string range $line 0 [expr {$index - 1}]]
set value [string range $line [expr {$index + 1}] end ]
switch -exact $name {
"head" {
set head $value
}
"tail" {
set tail $value
}
"delim" {
set delim $value
}
"dj" {
lappend djlist $value
}
"cmdlist" {
set cmdlist $value
}
"website" {
set website $value
}
"public_channel" {
set public_channel $value
}
"private_channel" {
set private_channel $value
}
"shoutcast" {
set shoutcast $value
}
"shoutport" {
set shoutport $value
}
"shoutpass" {
set shoutpass $value
}
"topicmask" {
set topicmask $value
}
"stream" {
set stream $value
}
"rules" {
set rules $value
}
"autodj" {
set autodj $value
}
"greet1" {
set greet1 $value
}
"greet2" {
set greet2 $value
}
"greet3" {
set greet3 $value
}
"ads" {
set ads $value
}
"friends" {
set friends $value
}
"schedules" {
set schedules $value
}
}
}
close $FD
}
}
Flush/Save code:
Code: Select all
proc battle:flush {} {
global head tail delim djlist datafile cmdlist website public_channel pr$
set FD [open $datafile w]
puts $FD "cmdlist:$cmdlist"
puts $FD "head:$head"
puts $FD "tail:$tail"
puts $FD "delim:$delim"
puts $FD "website:$website"
puts $FD "topicmask:$topicmask"
puts $FD "shoutcast:$shoutcast"
puts $FD "shoutport:$shoutport"
puts $FD "shoutpass:$shoutpass"
puts $FD "public_channel:$public_channel"
puts $FD "private_channel:$private_channel"
puts $FD "stream:$stream"
puts $FD "rules:$rules"
puts $FD "autodj:$autodj"
puts $FD "greet1:$greet1"
puts $FD "greet2:$greet2"
puts $FD "greet3:$greet3"
puts $FD "ads:$ads"
puts $FD "friends:$friends"
puts $FD "schedules:$schedules"
foreach dj $djlist {
puts $FD "dj:$dj"
}
close $FD
}