egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

When do I put "return 0"?

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help
View previous topic :: View next topic  
Author Message
daigo
Voice


Joined: 27 Jun 2014
Posts: 37

PostPosted: Sat Jul 26, 2014 6:35 pm    Post subject: When do I put "return 0"? Reply with quote

For example:

Code:
proc give {nick host hand chan arg} {
  global givechan

  if {$chan eq $::givechan} {
  puthelp "PRIVMSG $givechan :Here is $arg for you"
  }

  return 0
}


VS.

Code:
proc give {nick host hand chan arg} {
  global givechan

  if {$chan eq $::givechan} {
  puthelp "PRIVMSG $givechan :Here is $arg for you"

  return 0
  }
}


VS.


Code:
proc give {nick host hand chan arg} {
  global givechan

  if {$chan eq $::givechan} {
  puthelp "PRIVMSG $givechan :Here is $arg for you"

  return 0
  }

return 0
}


etc.

Where is/are the proper place(s) to put a "return 0"?
Back to top
View user's profile Send private message
Get_A_Fix
Master


Joined: 07 May 2005
Posts: 206
Location: New Zealand

PostPosted: Sat Jul 26, 2014 7:18 pm    Post subject: Reply with quote

Firstly, you have to understand that by declaring the global variable within the procedure, you do not then need to use the global variable in the manner you're calling it.

For example
Code:

  global givechan

   if {$chan eq $::givechan} {


You had already declared global givechan. This means that you just have to do

Code:

if {$chan eq $givechan} {


If you do NOT declare the 'global variable' in the proc, then you would use the $::method

Secondly, for return, check this out. It can be a bit confusing, but a lot of the time it's best to just test it yourself, being on partyline with debug. If you add debugging code, it makes it even better so you can see everything that's going on when triggered.
_________________
We explore.. and you call us criminals. We seek after knowledge.. and you call us criminals. We exist without skin color, without nationality, without religious bias.. and you call us criminals.
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
willyw
Revered One


Joined: 15 Jan 2009
Posts: 1175

PostPosted: Sun Jul 27, 2014 9:03 am    Post subject: Re: When do I put "return 0"? Reply with quote

daigo wrote:

...
Where is/are the proper place(s) to put a "return 0"?


That could depend on what you want to happen.

You'll get a better feel for it, if as Get_A_Fix suggested, you experiment with it.

In addition the the page that he gave you to read, here's some more good info on the subject, found here:
http://www.eggheads.org/support/egghtml/1.6.21/tcl-commands.html#bindb


I hope this helps.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber