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.

figuring out a loop

Old posts that have not been replied to for several years.
W
Weirdo
Master
Posts: 265
Joined: Sat Apr 27, 2002 8:00 pm
Location: Manchester, England

figuring out a loop

Post by Weirdo »

Code: Select all

proc pubnotice {} {
	global chanl network notice
	set active "1"
	while {$active != 1} {
		putlog "Notice Applied to $chanl(main)"
		timer 1 [putserv "Notice $chanl(main) :$notice(public)]
	}
}
Well this is the bit of code i having problems with. Doesnt seem to be running at all from what i can tell. Any ideas on how i can get it working. Thankfully, no TCL errors, so bot still running with it :)
t
tainted
Master
Posts: 239
Joined: Sun May 12, 2002 8:00 pm
Location: chicago
Contact:

Post by tainted »

Its been one of those really really long nights for me, but I would have to say its not working because you are setting the var to 1, then having the script compare it to 1. If it is NOT 1, then it continues.. So, it just returns.
W
Weirdo
Master
Posts: 265
Joined: Sat Apr 27, 2002 8:00 pm
Location: Manchester, England

Post by Weirdo »

does it need to be triggered by something, or will it just run if the script is running as it is. I havent got the procedure linked to anything.

chanded the != to == and it isnt producing anything
W
Weirdo
Master
Posts: 265
Joined: Sat Apr 27, 2002 8:00 pm
Location: Manchester, England

Post by Weirdo »

figged out i was missing out a " as well :P

still nothing tho

If i remove it from the procedure, it crashes the bot when it runs on bootup
User avatar
Papillon
Owner
Posts: 724
Joined: Fri Feb 15, 2002 8:00 pm
Location: *.no

Post by Papillon »

Code: Select all

bind time - * pubnotice
proc pubnotice {min hour day moth year} { 
   global chanl network notice 
   putlog "Notice Applied to $chanl(main)" 
   putserv "Notice $chanl(main) :$notice(public)"
}

this sends a notice to $chanl(main) every min...
Elen sila lúmenn' omentielvo
W
Weirdo
Master
Posts: 265
Joined: Sat Apr 27, 2002 8:00 pm
Location: Manchester, England

Post by Weirdo »

any chance of increasing it to 15 mins?
p
ppslim
Revered One
Posts: 3914
Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England

Post by ppslim »

make the line after the global line the following

Code: Select all

if {[expr $min ^ 15]} { return }
This works, by dividing the current mins by 15. If there is a remainder in the division, then don't operate.
W
Weirdo
Master
Posts: 265
Joined: Sat Apr 27, 2002 8:00 pm
Location: Manchester, England

Post by Weirdo »

thank you, give it a try. Wish me luck on the move :)
User avatar
strikelight
Owner
Posts: 708
Joined: Mon Oct 07, 2002 10:39 am
Contact:

Post by strikelight »

ppslim wrote:make the line after the global line the following

Code: Select all

if {[expr $min ^ 15]} { return }
This works, by dividing the current mins by 15. If there is a remainder in the division, then don't operate.
I believe ppslim meant:

Code: Select all

if {[expr $min % 15]} { return }
But the expr isn't really needed, if you wanted to, you could save space by just using: (atleast in tcl7.6 and above)

Code: Select all

if {$min%15} { return }
W
Weirdo
Master
Posts: 265
Joined: Sat Apr 27, 2002 8:00 pm
Location: Manchester, England

Post by Weirdo »

#Ill give it a go, at the moment, i getting

[04:08:00] <Natsuki-Chan> [04:08] Tcl error [time:pubnotice]: expected integer but got "08" (looks like invalid octal number)
[04:09:00] <Natsuki-Chan> [04:09] Tcl error [time:pubnotice]: expected integer but got "09" (looks like invalid octal number)

those
W
Weirdo
Master
Posts: 265
Joined: Sat Apr 27, 2002 8:00 pm
Location: Manchester, England

Post by Weirdo »

[11:08:00] <Natsuki-Chan> [11:08] Tcl error [time:pubnotice]: can't use invalid octal number as operand of "%"
[11:09:00] <Natsuki-Chan> [11:09] Tcl error [time:pubnotice]: can't use invalid octal number as operand of "%"

now getting these :(
p
ppslim
Revered One
Posts: 3914
Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England

Post by ppslim »

Never post when you are very tired. I forgot about thboth of these.

99% of the time, I am on a system, where I can make small tests using tclsh.

Change $min in the if statement to

Code: Select all

[string trimleft $min 0]
W
Weirdo
Master
Posts: 265
Joined: Sat Apr 27, 2002 8:00 pm
Location: Manchester, England

Post by Weirdo »

ok, changed, ill see how it goes :)
W
Weirdo
Master
Posts: 265
Joined: Sat Apr 27, 2002 8:00 pm
Location: Manchester, England

Post by Weirdo »

[12:00:00] <Natsuki-Chan> [12:00] Tcl error [time:pubnotice]: syntax error in expression " ^ 3": unexpected operator ^

[12:03:00] <Natsuki-Chan> [12:03] Tcl error [time:pubnotice]: can't read "nick": no such variable << I fixed this one :)
p
ppslim
Revered One
Posts: 3914
Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England

Post by ppslim »

Stupid old me.

Go back to the plain $min version.

The string trim, is removing both 00's when the hour strikes.

Code: Select all

if {![string index $min 0]} { set min [string index $min 1] }
Use this line, before it checks the reaminder.
Locked