For Programmers: Free Programming Magazines  


Home > Archive > Tcl > October 2005 > Re: How to make a procedure call from another procedure









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: How to make a procedure call from another procedure
miguel sofer

2005-10-27, 7:02 pm

My guess is: you are not having problems with calling the procedure,
but rather with variable scoping. Calling the procedure works fine, as
explained by suchenwi in his reply.

(What follows is written with the best intentions - it is not a rant by
any means. Happy to have newcomers!)

In order to help us help you, you should provide a small demo script
instead of saying "I tried writing ...", as there are too many ways in
which that could have failed. Notice how suchenwi did not just tell you
how to do it, but provided a small demo script?

We also need to know what happened exactly, rather than just "this does
not call ...". Is there an error return? What does it say?

Your message would have been much easier to understand if you had added
at the end (I'm inventing/guessing):

<guess>
What I did is:

% proc a {} {puts "This is proc a"}
% set procName a
a
% proc b {} {$procName}
% b
can't read "procName": no such variable

</guess>

Presented with this, we would know that the problem is with variable
scoping (there is no variable named procName within b's body, even
though there is a global variable by that name) and target our replies
accordingly.

HTH
Miguel

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com