| View previous topic :: View next topic |
| Author |
Message |
Nara Halfop
Joined: 23 Jul 2006 Posts: 40
|
Posted: Mon Jan 01, 2007 7:31 pm Post subject: Database question? |
|
|
I currently use a text file that is named as a .dat to store my eggdrop's custom settings and variables, which is loaded and saved on each load. However, it wipes like weekly to bi-weekly. I think it may have something to do with the way I sync or it could be the file system. Yes, mIRC colour codes are stored within the file if that means anything.
Sync/Load code:
| Code: | 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: | 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
} |
Basically: I want to solve the problem of it wiping itself. I'm more convinced its the linux file system not liking the colour codes or something though, as both of my backup files got wiped too. |
|
| Back to top |
|
 |
Sir_Fz Revered One

Joined: 27 Apr 2003 Posts: 3793 Location: Lebanon
|
Posted: Mon Jan 01, 2007 7:36 pm Post subject: |
|
|
Why don't you save them in the form:
| Quote: | set var1 bla
set var2 blo
... |
and simply source the file. _________________ Follow me on GitHub
- Opposing
Public Tcl scripts |
|
| Back to top |
|
 |
Nara Halfop
Joined: 23 Jul 2006 Posts: 40
|
Posted: Tue Jan 02, 2007 12:31 am Post subject: |
|
|
| Because I never knew you could do that. So, just put them in a blank file, name it .tcl, and load it before the script in the eggdrop configuration? |
|
| Back to top |
|
 |
Sir_Fz Revered One

Joined: 27 Apr 2003 Posts: 3793 Location: Lebanon
|
Posted: Tue Jan 02, 2007 7:16 am Post subject: |
|
|
Yes, or you can load it inside the script before the code starts (i.e. add source scripts/variables.tcl before starting the code).
PS: It doesn't have to be a .tcl file, that's just a standard. _________________ Follow me on GitHub
- Opposing
Public Tcl scripts |
|
| Back to top |
|
 |
metroid Owner
Joined: 16 Jun 2004 Posts: 771
|
Posted: Wed Jan 03, 2007 12:28 pm Post subject: |
|
|
source can load any file, it just won't react too well on non-tcl code.
you can give it any extension you want, or no extension at all. |
|
| Back to top |
|
 |
|