05-30-2020, 06:49 +0200
Forum: Overvieweggdrophelp
How to call a proc from another proc
AuthorPost
Nathanpk  10-01-2012, 07:41   | Need help!
Member since 10/2012
2 Posts
Hi,
I am new to TCL and I would like to know whether proc can be called from another proc or not. Please guide me on this.

Is it possible to have a script like the one below? If not, what should be the alternative to call a function inside another proc?

Proc Example_1 {..} {..
...
..
.
}

proc Example_2 {..} {
Example_1 ...
}

Thanks!
superlinux  04-04-2013, 17:47   Homepage
Mr.

Avatar

Member since 04/2013
2 Posts
Location: Sayda, Lebanon
It's so easy and simple. Here is an example:
Imagine that you first walked (this is the 1st function/procedure).
Then, as you are walking you want to keep eating (eating here is the 2nd function/procedure).

The order of the definition of the procedure  whatever  the programming language would be is very important.

Here is the example solved:
                                                                                                                              
01
02
03
04
05
06
07
08
09
10
11
proc eating { } {
    puts "I am still eating"
}

proc walking { } {

    puts "walking"
    while {true} {  #warning this means calling [eating] repeatedly forever
        eating
    }
}


have a look at this topic too
http://tclhelp.net/unb/315

Advanced options for this topic:

Ignore this topic (Do not list this topic in the "unread topics" search. You are currently not ignoring this topic.)
Hide this topic (Hidden topics are not displayed in the topics list. This topic is currently not hidden.)
Go to forum

Unclassified NewsBoard 1.5.3-d | © 2003-4 by Yves Goergen | Time: 154.5 msec, CPU time: 65.1 msec, 33 Database queries in 115.5 msec | 3.5 kB (13.1 kB) | Timezone: +0200