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.

[SOLVED] Need help with file handling - thanks nml375!

Help for those learning Tcl or writing their own scripts.
z
zerodtk
Voice
Posts: 20
Joined: Wed Mar 25, 2009 6:06 pm

Post by zerodtk »

heya, hope you don't mind one more question...
how can i make it ignore its own url?
something like
*szabadka.org*

thanks in advance
z
zerodtk
Voice
Posts: 20
Joined: Wed Mar 25, 2009 6:06 pm

Post by zerodtk »

what about this one
came from Ofloo

Code: Select all

proc isdupe {url} {
	if {![catch {open $catch:path r} rf]} {
	set r 0
	while {![eof $rf]} {
	if {[string match -nocase *${url}* [gets $rf]]} {
	set r 1
	break
	}
	 }
	 close $rf } }
and adding it where it catches the urls

Code: Select all

proc catch_url_pubm {nick host hand chan arg} {
  if {[regexp -nocase {(http://[^\s]+)} $arg -> url]} {
	if {[isdupe $url]} {return}
and the error i get is

Code: Select all

[18:14:41] [(Angela]: [18:12] Tcl error [catch_url_pubm]: expected boolean value but got ""
[18:14:44] [(Angela]: Currently: expected boolean value but got ""
[18:14:44] [(Angela]: Currently: while executing
[18:14:44] [(Angela]: Currently: "if {[isdupe $url]} {return}"
[18:14:44] [(Angela]: Currently: (procedure "catch_url_pubm" line 3)
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

the isdupe proc is missing a line stating "return $r" at the end. Also, the catch:path variable is not linked to globalspace, and is not defined, so this will cause an error (caught though).
I'd suggest something like this:

Code: Select all

proc isdupe {url} {
  set r 0
  if {![catch {open "scripts/urllogger.txt" r} rf]} {
    while {![eof $rf]} {
      if {[string match -nocase *${url}* [gets $rf]]} {
        set r 1
        break
      }
    }
    close $rf
  }
  return $r
}
NML_375
z
zerodtk
Voice
Posts: 20
Joined: Wed Mar 25, 2009 6:06 pm

Post by zerodtk »

thanks, the error is now gone...
so i just need to change ${url} to what i want to be ignored?

something like

Code: Select all

proc isdupe {url} {
  set r 0
  if {![catch {open "/home/zerodtk/public_html/log/index.php" r} rf]} {
    while {![eof $rf]} {
      if {[string match -nocase *szabadka* [gets $rf]]} {
        set r 1
        break
      }
    }
    close $rf
  }
  return $r
}
z
zerodtk
Voice
Posts: 20
Joined: Wed Mar 25, 2009 6:06 pm

Post by zerodtk »

hahahaha the solution was in front of my eyes!
:DDD thanks for your help :))

Code: Select all

proc isdupe {url} {
  set r 0
  if {![catch {open "scripts/ignored.txt" r} rf]} {
    while {![eof $rf]} {
      if {[string match -nocase *${url}* [gets $rf]]} {
        set r 1
        break
      }
    }
    close $rf
  }
  return $r
}
and the ignored urls goes to the ignored.txt lol
thanks much for helping me out:)
Post Reply