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.

[RESOLVED] How to call a proc within a proc

Help for those learning Tcl or writing their own scripts.
Post Reply
L
Landslyde
Halfop
Posts: 46
Joined: Thu May 01, 2014 6:01 pm

[RESOLVED] How to call a proc within a proc

Post by Landslyde »

I have three procs.

Code: Select all

proc one {nick uhost handle channel args} { 
    some code
}
proc two {} { 
    some code
    one
}
proc three {nick uhost handle channel args} { 
    some code
    one
}
I want to recall proc one after proc two and proc three run their course. The way I have it (without the inner code of the procs shown here) is not working. What's the right way to do this?
Last edited by Landslyde on Mon Apr 24, 2017 11:18 pm, edited 1 time in total.
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

First off avoid using args as it has a special meaning.

If the functions (proc) aren't binded or called anywhere outside another function (proc) I don't see how this would work.

Basically add one at the end of the code you got to call it when the tcl file is executed (read).
Once the game is over, the king and the pawn go back in the same box.
w
willyw
Revered One
Posts: 1203
Joined: Thu Jan 15, 2009 12:55 am

Re: How to call a proc within a proc

Post by willyw »

"is not working"
It would help if you would show us the error message that you are seeing in the partyline.

In the meantime, I suspect that it will have to do with the wrong number or arguments.

Think of the proc that you have named "one" as that you have created a new tcl command, named "one". You can call it and use it. However, by the design of it, "one" wants to be passed five command line arguments.

In proc two, you will have to re-think that - so that you have something to pass to "one" when you call it.
You can hard code it, if that will fit your needs.

In proc three, it looks like the usage would be:
one $nick $uhost $handle $chan $text

(I agree with caesar. args is special. I don't even use "arg", even though that is not special.... it just looks close to the human eye. )

Big note ! :
With the very limited sample code we are working with here - aren't we creating an infinite loop? Have another look, and think about it.

I hope I have not misled you - I just woke up and am not firing on all cylinders yet.
For a fun (and popular) Trivia game, visit us at: irc.librairc.net #science-fiction . Over 300K Q & A to play in BogusTrivia !
L
Landslyde
Halfop
Posts: 46
Joined: Thu May 01, 2014 6:01 pm

Post by Landslyde »

caesar and willyw:

This is an issue i'm having with a prior post: http://forum.egghelp.org/viewtopic.php?t=20324

This is a game script. The user calls the game with !word

If no one guess the puzzle, the game ends.

If the puzzle is guessed, the game also ends.

I have the code in that post. I want to be able to automatically call the proc pub_word after either of the above two events happen, rather than have the user continuously keep starting a game by using the !word. That's what they all want. But I cant make ti happen at all.

Any help wld be greatly appreciated.
Post Reply