On *:Start: {
var %x = $lines(database.txt)
while (%x) {
ignore $gettok($read(database.txt,%x),5,32)
dec %x
}
}
dialog database {
title "The Only"
size -1 -1 64 116
option dbu
combo 1, 2 2 60 90, size
button "Add", 2, 11 94 15 8
button "Del", 3, 38 94 15 8
button "Close", 4, 4 106 55 8
}
On *:Dialog:database:init:0: {
if ($lines(database.txt) >= 1) { .play -s database.txt 10 }
}
On *:Dialog:database:sclick:2: {
if ($did(1)) {
if ($read(database.txt,w,did -a database 1 $did($dname,1))) { echo -a $did(1) already exists. | halt }
did -a $dname 1 $did(1)
write database.txt did -a database 1 $did($dname,1)
echo -a Added $+($did($dname,1),.)
}
}
On *:Dialog:database:sclick:3: {
if ($did(1).sel) {
did -d $dname 1 $did(1).sel
write -dw $+("*,$did(1).sel,*") database.txt
echo -a Deleted $+($did($dname,1),.)
}
}
On *:Dialog:database:sclick:4: {
dialog -x database database
}