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.

simple database script

Old posts that have not been replied to for several years.
Locked
P
Pitchat
Op
Posts: 122
Joined: Tue Feb 18, 2003 11:24 pm
Location: Hebertville Quebec Canada
Contact:

simple database script

Post by Pitchat »

hi

ive try a couple of database scripts and did not find what i want ( my needs are really simple) after a couple of try on my own with big failure and reading the faq on how to work with files , i am to the point of asking ( again ... sic) your help

what i want to di is simple

in .dcc type .addcommand ( nick) ( #channelname) ( anothernick)

those infos will be in a txt file and can be display in partyline with a commande like .listmycommand

of course the possibility to delete some infos with .delmycommand ( nick) (#channelname) (anothernick) should be present

i dont know how to start it properly

thanks for any advice
User avatar
^DooM^
Owner
Posts: 772
Joined: Tue Aug 26, 2003 5:40 pm
Location: IronForge
Contact:

Post by ^DooM^ »

Start off here. Click Me
The lifecycle of a noob is complex. Fledgling noobs gestate inside biometric pods. Once a budding noob has matured thru gestation they climb out of their pod, sit down at a PC, ask a bunch of questions that are clearly in the FAQ, The Noob is born
O
Ofloo
Owner
Posts: 953
Joined: Tue May 13, 2003 1:37 am
Location: Belguim
Contact:

Post by Ofloo »

Code: Select all

set datafile "storage.dat"

proc adding_something {hand idx arg} {
  global datafile
  if {[llength $arg] != 3} {
    putdcc $idx "Syntax error to many or not enough args."
  } else {
    if {![catch {open $datafile a+} af]} {
      puts $af "\{[lindex [split $arg] 0]\} \{[lindex [split $arg] 1]\} \{[lindex [split $arg] 2]\}"
      close $af
      putdcc $idx "Successfully added $arg to db."
    } else {
  	  putdcc $idx "Failed to open $datafile."
    }
  } 
}

proc delete_something {hand idx arg} {
  global datafile
  if {[llength $arg] != 3} {
    putdcc $idx "Syntax error to many or not enough args."
  } else {
    if {![catch {open $datafile a+} af]} {
      set rd [read $af]
      close $af
      if {![catch {open $datafile w} wf]} {
        foreach {a b c} [split $rd \n] {
          if {![string equal -nocase [lindex [split $arg] 0] $a] && ![string equal -nocase [lindex [split $arg] 1] $b] && ![string equal -nocase [lindex [split $arg] 2] $c] && ![string equal {} $a]} {
            puts $wf "\{$a\} \{$b\} \{$c\}"
          }
        }
        close $wf
        putdcc $idx "Successfully removed $arg from db."
      } else {
      	putdcc $idx "Failed to open $datafile for writting."
      }
    } else {
    	putdcc $idx "Failed to open $datafile."
    }
  }
}

proc list_database {hand idx arg} {
  global datafile
  if {[llength $arg] != 0} {
    putdcc $idx "To many args"
  } else {
  	if {![catch {open $datafile r} rf]} {
      foreach {a b c} [split [read $rf] \n] {
        putdcc $idx "Nick: $a Chan: $b AltNick: $c."
      }
      close $rf
    } else {
    	putdcc $idx "Couldn't open $datafile for reading."
    }
  }
}


bind dcc o|o add adding_something
bind dcc o|o del delete_something
bind dcc o|o list list_database
i know i know i was bored .. :p but he is willing to learn ;)

not tested tho..
XplaiN but think of me as stupid
P
Pitchat
Op
Posts: 122
Joined: Tue Feb 18, 2003 11:24 pm
Location: Hebertville Quebec Canada
Contact:

Post by Pitchat »

thanks to both of you

even if ofloo give me 99.9% of what i need , i always appreciate people who can make me aware of sources to lern more thanks for the link to the guide it will be useful
Locked