I'm having a problem getting this to work..
I got 3 files,
start.C - Where i got my main() function
Menu.C & Menu.h - Where I'm trying to use hash_map
start.C
#include <iostream>
#include "Menu.h"
using namespace std;
int main() { /* test code here */ return 0; }
Menu.h ... (1 Reply)
Each thread has a copy of auto variables within a function, but variables
declared as static within a function are common to all threads. To circumvent
this can static variables be placed outside the function. If so, will the
scope of the variable be file only or will it be extern, and will each... (7 Replies)
My awk script searches for specified patterns in a text file and stores these values into mem variables.
Once this is done I want to Insert these values into a table.
How can I avail of the variable values outside the scope of awk script....
One method that I have tried is to write the... (7 Replies)
Heres an example.....
<~/abc>$ cat textfile
line 1
line 2
line 3
line 4
line 5
<~/abc>$ cat try.sh
#/bin/ksh
for runs in 1 2 3
do
A=$runs
echo "Inside A : $A"
done
echo "Outside A : $A" <- works fine (1 Reply)
I call my script with two parameters
myscript.sh aaa bbb
What is the way to access $1 and $2 values inside a function? I call the function like this
myfuntion $1 $1
but inside of the function, $1 and $2 are empty. Any suggestions? thank you in advanced. (1 Reply)
If I set a variable within a while-read loop, sometimes it's local to the loop, sometimes it's global, depending on how the loop is set up. I'm testing this on a Debian Lenny system using both bash and dash with the same results.
For example:
# Pipe command into while-read loop
count=
ls -1... (2 Replies)
Hi,
I want to know about the variable scope in shell script.
How can we use the script argument inside the function?
fn () {
echo $1 ## I want this argument should be the main script argument and not the funtion argument.
}
also are there any local,global types in shell script?
if... (3 Replies)
Friends,
I am using ksh under SunoS. This is what I have
In file1.sh
NOW=$(date +"%b-%d-%y")
LOGFILE="./log-$NOW.log"
I will be using this file through file1.sh as log file.
I have another script file2.sh which is being called inside my file1.sh. I would like to use the same log... (6 Replies)
Discussion started by: dahlia84
6 Replies
LEARN ABOUT REDHAT
scope
scope(n) [incr Tcl] scope(n)
NAME
scope - capture the namespace context for a variable
SYNOPSIS
scope name
DESCRIPTION
Creates a scoped value for the specified name, which must be a variable name. If the name is an instance variable, then the scope command
returns a string of the following form: @itcl object varName This is recognized in any context as an instance variable belonging to object.
So with itcl3.0 and beyond, it is possible to use instance variables in conjunction with widgets. For example, if you have an object with
a private variable x, and you can use x in conjunction with the -textvariable option of an entry widget. Before itcl3.0, only common vari-
ables could be used in this manner.
If the name is not an instance variable, then it must be a common variable or a global variable. In that case, the scope command returns
the fully qualified name of the variable, e.g., ::foo::bar::x.
If the name is not recognized as a variable, the scope command returns an error.
Ordinary variable names refer to variables in the global namespace. A scoped value captures a variable name together with its namespace
context in a way that allows it to be referenced properly later. It is needed, for example, to wrap up variable names when a Tk widget is
used within a namespace: namespace foo {
private variable mode 1
radiobutton .rb1 -text "Mode #1" -variable [scope mode] -value 1
pack .rb1
radiobutton .rb2 -text "Mode #2" -variable [scope mode] -value 2
pack .rb2 } Radiobuttons .rb1 and .rb2 interact via the variable "mode" contained in the namespace "foo". The scope command guarantees
this by returning the fully qualified variable name ::foo::mode.
You should never use the @itcl syntax directly. For example, it is a bad idea to write code like this: set {@itcl ::fred x} 3 puts "value
= ${@itcl ::fred x}" Instead, you should always use the scope command to generate the variable name dynamically. Then, you can pass that
name to a widget or to any other bit of code in your program.
KEYWORDS
code, namespace, variable
itcl scope(n)