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.

When do I put "return 0"?

Help for those learning Tcl or writing their own scripts.
Post Reply
d
daigo
Voice
Posts: 37
Joined: Fri Jun 27, 2014 8:02 pm

When do I put "return 0"?

Post by daigo »

For example:

Code: Select all

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: Select all

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: Select all

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"?
User avatar
Get_A_Fix
Master
Posts: 206
Joined: Sat May 07, 2005 6:11 pm
Location: New Zealand

Post by Get_A_Fix »

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: Select all

  global givechan 

   if {$chan eq $::givechan} { 
You had already declared global givechan. This means that you just have to do

Code: Select all

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.
w
willyw
Revered One
Posts: 1199
Joined: Thu Jan 15, 2009 12:55 am

Re: When do I put "return 0"?

Post by willyw »

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 ... html#bindb


I hope this helps.
Post Reply