Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

global(3tcl) [debian man page]

global(3tcl)						       Tcl Built-In Commands						      global(3tcl)

__________________________________________________________________________________________________________________________________________________

NAME
global - Access global variables SYNOPSIS
global varname ?varname ...? _________________________________________________________________ DESCRIPTION
This command has no effect unless executed in the context of a proc body. If the global command is executed in the context of a proc body, it creates local variables linked to the corresponding global variables (though these linked variables, like those created by upvar, are not included in the list returned by info locals). If varname contains namespace qualifiers, the local variable's name is the unqualified name of the global variable, as determined by the namespace tail command. varname is always treated as the name of a variable, not an array element. An error is returned if the name looks like an array element, such as a(b). EXAMPLES
This procedure sets the namespace variable ::a::x proc reset {} { global a::x set x 0 } This procedure accumulates the strings passed to it in a global buffer, separated by newlines. It is useful for situations when you want to build a message piece-by-piece (as if with puts) but send that full message in a single piece (e.g. over a connection opened with socket or as part of a counted HTTP response). proc accum {string} { global accumulator append accumulator $string } SEE ALSO
namespace(3tcl), upvar(3tcl), variable(3tcl) KEYWORDS
global, namespace, procedure, variable Tcl global(3tcl)

Check Out this Related Man Page

global(n)						       Tcl Built-In Commands							 global(n)

__________________________________________________________________________________________________________________________________________________

NAME
global - Access global variables SYNOPSIS
global varname ?varname ...? _________________________________________________________________ DESCRIPTION
This command has no effect unless executed in the context of a proc body. If the global command is executed in the context of a proc body, it creates local variables linked to the corresponding global variables (though these linked variables, like those created by upvar, are not included in the list returned by info locals). If varname contains namespace qualifiers, the local variable's name is the unqualified name of the global variable, as determined by the namespace tail command. varname is always treated as the name of a variable, not an array element. An error is returned if the name looks like an array element, such as a(b). EXAMPLES
This procedure sets the namespace variable ::a::x proc reset {} { global a::x set x 0 } This procedure accumulates the strings passed to it in a global buffer, separated by newlines. It is useful for situations when you want to build a message piece-by-piece (as if with puts) but send that full message in a single piece (e.g. over a connection opened with socket or as part of a counted HTTP response). proc accum {string} { global accumulator append accumulator $string } SEE ALSO
namespace(n), upvar(n), variable(n) KEYWORDS
global, namespace, procedure, variable Tcl global(n)
Man Page

15 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Global variable becomes local

I have encountered a very weird behavior of a global variable in Korn Shell in AIX: A function f1 in my script pipes the output of the function f2 to a program. A variable defined as global using typeset gets its value in f2. That value is not seen in f1. If I remove the pipe ksh recognizes the... (2 Replies)
Discussion started by: odashe318
2 Replies

2. Shell Programming and Scripting

perl global variables

Can someone give me "the lecture" on why you shouldn't make all your varables global when programming in perl. I have been doing this but I have heard that it is not a good practice. (3 Replies)
Discussion started by: reggiej
3 Replies

3. Shell Programming and Scripting

Problem with global and local variables

Guys, how can I define global variables in sorlaris...cause I lose the values outside the scope. Rite now wat I do is,I redirect variable value to a file n then get it back outside the function...:o....theres obviously a better way of doing this...I now this is a basic question....but please... (2 Replies)
Discussion started by: qzv2jm
2 Replies

4. Shell Programming and Scripting

global variable not being set

In ksh I thought a global variable was any variable in a script or function that did not have the typeset command. I have a global in my calling script which I increment in a function, but the value does not change in the calling script. Here is the code: function f_open_log { typeset -r... (5 Replies)
Discussion started by: robotball
5 Replies

5. Shell Programming and Scripting

Passing global variable to a function which is called by another function

Hi , I have three funcions f1, f2 and f3 . f1 calls f2 and f2 calls f3 . I have a global variable "period" which i want to pass to f3 . Can i pass the variable directly in the definition of f3 ? Pls help . sars (4 Replies)
Discussion started by: sars
4 Replies

6. Shell Programming and Scripting

$$ means?

hey, what's $$varname in a script? I used to see $varname only. search on google didn't help. thanks. (4 Replies)
Discussion started by: patiobarbecue
4 Replies

7. Programming

buffer over flow detected

Hi, my program stops with a buffer overflow error, but i can't understand the problem. I have a file like: int array; //global variable void func(){ int i; for(i=0;i<n;i++)array=-1; ... } I had the error when i added the array initialization. the file is a part of a C project. What... (1 Reply)
Discussion started by: littleboyblu
1 Replies

8. Programming

global variables and dynamic allocation

Hi, is it possible in C to allocate dynamically a global variable?? (3 Replies)
Discussion started by: littleboyblu
3 Replies

9. Shell Programming and Scripting

Function ignoring global variables

Hi there. I'm writing a function to which I want to pass a global variable. For some reason, it's ignoring the variable. #!/bin/bash ##################################### #Variable Declaration ##################################### CURPATH=`dirname $0` DEEP=$CURPATH/depth.txt export... (4 Replies)
Discussion started by: mikesimone
4 Replies

10. Shell Programming and Scripting

Handling string

I have to source a file "varname" the content of varname file is like this: #ani ani1 = abc_ani ani2 = def_ani #sham sham1 = abc_sham sham2 = abc_sham Now i need to extract any line containing "ani: in it. And then store the extracted info in a file. (3 Replies)
Discussion started by: animesharma
3 Replies

11. UNIX for Advanced & Expert Users

Unix linked-list placement

Hi, I am programming in kernel, and I want to use a double linked list that holds infos that every process could access and modify THIS list. So, I suppose it is a 'global' variable since every process(thread) can reach it, I am wondering where to put it? by changing some of the kernel files? (1 Reply)
Discussion started by: louisTan
1 Replies

12. Shell Programming and Scripting

How to use variables in 'sed' append command?

HELLO!! I'm trying to pass a variable with in the 'sed' command (which would add some piece of code to file at a particular line). We can use sed '{line-number}a\ alfjaljf\ aslfjsfsjafl\ adlfjaf\' file.txt If file.txt is Now, I would like to add the parameter 'lmn' after... (1 Reply)
Discussion started by: mjavalkar
1 Replies

13. UNIX for Advanced & Expert Users

"exec" with "read"

Hi guys... I have been doing binary experiments yet again and came across a superb piece of code... I extracted a very small piece and re-wrote to suit my needs:- #!/bin/bash --posix # bash-hexdump # Open the file $1 to be read with an fd 3. exec 3<"$1" saveIFS="$IFS" IFS=""... (9 Replies)
Discussion started by: wisecracker
9 Replies

14. UNIX for Beginners Questions & Answers

Add global variable to jil autosys

I am new to autosys. I want to add a global variable to a jil file named PJ.jil. I also want to add a watch_file command to filename PJ.jil and AY.jil. The watch_file command checks every five minutes if the jobs have completed. For example. AY.jil needs to wait until all the jobs in PJ.jil have... (0 Replies)
Discussion started by: dellanicholson
0 Replies

15. UNIX for Beginners Questions & Answers

Autosys adding global variable in a jil

I have created two jil files name AY.jil and PY.jil. I have three issues which are as follows: 1. how do you add a global variable value from a shell script program to a jil file? 2. PY.jil needs to check every five minutes on the completion of the AY.jil jobs and AY.jil needs to... (1 Reply)
Discussion started by: dellanicholson
1 Replies