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.

how to append ??

Old posts that have not been replied to for several years.
Locked
O
Ofloo
Owner
Posts: 953
Joined: Tue May 13, 2003 1:37 am
Location: Belguim
Contact:

how to append ??

Post by Ofloo »

This i got so far but it only works once i need to append new line everytime i perform the command ... ?? ? ?

Code: Select all

bind pub - !ban send_ban

set f [open "test.txt" "w"]

proc send_ban {nick uhost hand chan arg} { 
global ban send_ban f
puts $f "IP0=-[lindex $arg 0]"
close $f
} 
after that i get this error ?? and instead of IP0 it should count but don't know yet how to do that i figured if i knew how to use this first ...

[04:56] Tcl error [send_ban]: can not find channel named "file10101648"

PS this works only once but after rehashing it works again, but i need to rehash everytime i wana use this .... ? and it over writes the first line it doesn't append ...?
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

First move the set f [open "test.txt" "w"] inside the proc, second, to append use "a" not "w". That error means he can't close a file that is not opened, or something like this anyway.
Once the game is over, the king and the pawn go back in the same box.
O
Ofloo
Owner
Posts: 953
Joined: Tue May 13, 2003 1:37 am
Location: Belguim
Contact:

Post by Ofloo »

hmm doesn't seem to work and for the counter i found this but that one only counts until one ... it appends but still need to rehash before i can add a second line .. the counter works but only when i append ? so if i would like to over write it it doesn't work .. and when i append it only counts to 2 witch is normal cause it keeps on reading the first line so i suppose it has to close the file before it can write to it or am i wrong .. (tryed but doesn't work either .. ?)

Code: Select all

bind pub - !ban send_ban

set fw [open "test.txt" "a+"]
set fc [open "count.txt" "w+"]

proc send_ban {nick uhost hand chan arg} { 
global ban send_ban fw fc
set line1 [gets $fc]
set lr1 [expr $line1 + 1]
puts $fc $lr1
puts $fw "IP$lr1=-[lindex $arg 0]"
close $fw
close $fc
}  
I know i need to flush channel id but how ?? so my main problem is flussing the channel id witch is $fw $fc i gues, and the counter doesn't count for some reason, i have tryed for the counter a a+ w w+ r r+ and nonew line
i think i need the w cause it needs to overwrite it but with all the other flags it does something different sometimes it adds it vertical somethimes it adds it horizontal .. but not overwrite and when it is supposed to it only does it once .. ???
O
Ofloo
Owner
Posts: 953
Joined: Tue May 13, 2003 1:37 am
Location: Belguim
Contact:

Post by Ofloo »

i have solved the rehash problem but the counter .. ?

i had to put the set open ... into the proc
O
Ofloo
Owner
Posts: 953
Joined: Tue May 13, 2003 1:37 am
Location: Belguim
Contact:

Post by Ofloo »

ok made it now any suggetions about the code cause it might look little messy ... ?

Code: Select all

proc send_ban {nick uhost hand chan arg} { 
global ban send_ban 
set fw [open "test.txt" "a"] 
set fc [open "count.txt" "r"]
set nr "[read $fc]"
set count [expr $nr + 1] 
puts $fw "IP$count=-[lindex $arg 0]"
set fd [open "count.txt" "w"]
puts -nonewline $fd $count 
close $fw
close $fc
close $fd
}
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

Wel, yes. You open the cout.txt file for reading, the a few line later you open it for writing and you close it only one time. First close it for reading then open it for writing.
Once the game is over, the king and the pawn go back in the same box.
O
Ofloo
Owner
Posts: 953
Joined: Tue May 13, 2003 1:37 am
Location: Belguim
Contact:

Post by Ofloo »

huh look again i close it 2 times only for reading i set fc and for writing i set fd ??? ;) hehe or am i mestaking cause i am not that good that this stuff .. :/
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

Oups, yes.. haven't noticed the second close. Anyway, first close it for reading, the open and close for writing. Also, you can open it with r+ for the reading and the writing.
Once the game is over, the king and the pawn go back in the same box.
O
Ofloo
Owner
Posts: 953
Joined: Tue May 13, 2003 1:37 am
Location: Belguim
Contact:

Post by Ofloo »

tryed that but that didn't work... this seems to work so that is why i wondert
Locked