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)
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)
hi,
i am a newbie unix administrator. i want to set a variable, let's say :
alias cls 'clear'
But i am not going to add this line in the .login file for every home directory of my 500+ users.
pls tell me where should i put this line in, so that all users can use this variable after... (4 Replies)
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)
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)
Hi All,
I know to set global variable i can use export .. But take the situation like below ..
I want to set a variable in one script and access that in second script
i have done like this .. It is not working
one.sh
#!/usr/bin/ksh
echo $RISSHI
export RISSHI=1
two.sh... (3 Replies)
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)
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)
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)
I am using functions in a script and for some strange reason the EXPORT command doesnt seem to be making my variables global.
Anyone got any ideas?
I am using one function to pass some output top another using the pipe command, eg
Function 1 | Function 2
Function 2 reads the value... (3 Replies)
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)
Hi every one.. I'm new to shell scripting... I would like to assign a single array element to a variable... Is it possible to do it....
Could any body help me.... (3 Replies)
Is there anyway in which i can set a permanent global variable in unix, which when initialised with a value and modified during any shell script, would retain its value even if i logout and login
I dont know whether i am being able to express my need clearly but basically what i want is a... (3 Replies)
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)
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)