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.

Changing contents of a file (.ini file with info to change)

Old posts that have not been replied to for several years.
Locked
Z
Zygomaticum

Post by Zygomaticum »

I'm working on a script which shows info from a site when typing the trigger for info. You can also add a site, using the addsite trigger. When doing this, all the value-fields in the .ini file will be set to ??? for that site. With an other trigger, you should be able to change this values (like the name, i'm working on that now).

What i got now is:

Code: Select all

proc pub_addname {nick uhost hand chan arg} {
  if {[string tolower $chan] == "#<chan>" } {
    set site "-[string tolower [lindex $arg 0]]-"
    set name [lrange $arg 1 end]
    set file1r [open "sites.ini" r+]
    set file2 [read $file1r]
    foreach line [split $file2 "n"] {
      if { [string tolower $line] == $site } {
        putserv "PRIVMSG #<chan> :site found"
        set found 1
      } else { if {$found != 1 } { putserv "PRIVMSG #<chan> :site not found" } }
      if { $found == 1 && $nameset != 1 } {
        if { [lsearch -exact $line "name"] != 1 } {
          putserv "PRIVMSG #<chan> :name field found"
          set nameset 1
        }
      }
    }
    close $file1r
    close $file2
  }
}
i've tried some [censored] with strings, files and other things but it didn't work.

the name field in the .ini file is in the format:
name=<name> (??? by default)
the name of the site is in the format:
-<sitename>-
after -<sitename>-, all the fields for that site are shown, each at a new line.

Does anyone know how i can change the value from ??? to the given name, or from the old name to the new name??
Thx alot, i've been trying for hours but it still won't work :sad:

Greejtz, Zygo.

<font size=-1>[ This Message was edited by: Zygomaticum on 2002-03-01 13:09 ]</font>
Z
Zygomaticum

Post by Zygomaticum »

come on, someone must know this.
Z
Zygomaticum

Post by Zygomaticum »

now i got it almost working, after adding something, he only puts the last few chars of $line in the string when reaching the next line, in stead of the whole string. For chek of $line, the bot says $line in the chan and it's correct.

Greejtz, Zygo.
P
Petersen
Owner
Posts: 685
Joined: Thu Sep 27, 2001 8:00 pm
Location: Blackpool, UK

Post by Petersen »

the way to do it is to store all the variables in memory in arrays. write them out to file in tcl format, and source that file on reload. saves messing around with file search routines and is more efficient (unless of course the list is gonna get huge and start hogging memory). however, if you do output in to file tcl format, be sure to escape command characters (eg [, , {, } and ]) so that they're not executed when its sourced
Z
Zygomaticum

Post by Zygomaticum »

isn't there a code (<nr>) to show things like [ into a string? (like 03 and so on..)

greejtz, Zygo.
W
Wcc
Master
Posts: 278
Joined: Sun Oct 28, 2001 8:00 pm
Location: USA
Contact:

Post by Wcc »

http://www.asciitable.com

Look under the oct column.
Locked