Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

What is the syntax of calling a procedure in TCL?

Status
Not open for further replies.
what is the disadvantage of defining the procedure before..???

what is the advantage of defining procedure at line 100 and calling at line 40??

The advantage is, you can keep all your procedures of a script at the end of the file. You call the procedures whenever you want then in the script. It looks more structured to do in that way.
 

Hai sunray,

The same thing u can do by defining procedures before call..

rather than spending time in this.. move forward with other topics..

because customer will not ask that u need to define the procedure at the end and there is no rule that should be at end..

Normally while using tcl in some other tools ex:- soc encounter

we used to have a tcl file containing all the procedures we source this file in the beginning itself.

then we call the operation code.. In this case defining the procedure after will not work..

Dont stuck with this move forward.
 

Hai sunray,
I referred some site and did it.. enjoy

foreach line ( "`cat input`" )
if("$line" =~ *fatal*)then
echo $line >> fatal;
else if("$line" =~ *necessary*)then
echo $line >> necessary;
endif
end

- - - Updated - - -

Actually I want to make the above script a part of another bigger main script so that this script can generate two different files out of one input file. This input file will be located at a path different than the location from where the bigger main script is being fired. Can you please modify accordingly so that input file location can be any other location other than the current run directory. By input file I mean the file from which two files named fatal and necessary being generated.

Regards
 

foreach line ( "`cat /export/cshell_code/folder/subfoldername/input`" )
if("$line" =~ *fatal*)then
echo $line >> fatal;
else if("$line" =~ *necessary*)then
echo $line >> necessary;
endif
end

Mention the path name as i mentioned
 

foreach line ( "`cat /export/cshell_code/folder/subfoldername/input`" )
if("$line" =~ *fatal*)then
echo $line >> fatal;
else if("$line" =~ *necessary*)then
echo $line >> necessary;
endif
end

Mention the path name as i mentioned

I wrote this script in a file named as.scr and have made as.scr executable. So when I write the command as

as.scr

I get the following error
syntax error near unexpected token `('

When I wrote the following command csh as.scr, then I got the error AS FOLLOWS:
cat: /export/cshell_code/folder/subfoldername/input: No such file or directory.

- - - Updated - - -


Vijay

I have another question as follows

I have two variables A and B both having some values. Now one of the directories has the name in such a way that the name is $A_$B. Now I want to mention one path where $A_$B are sub directory? I specified the name of this sub directory in the path as $A_$B. But I am getting an Error stating no variable named $A_. So to conclude the script while running taking A_ as a variable instead of A which I want. How can I solve this issue? It is needed for me to define the path with the sub directory defined with the help of A and B variables as stated above.
 

Hai sun ray,

I tried with my script and its working fine..

i herewith attached for ur reference..

Have u specified the correct path

else post the script i will find the bug

View attachment cshell_code.tar.gz

- - - Updated - - -

In tcl

while calling the variable declare as

${A}_${B}..
 

In tcl

while calling the variable declare as

${A}_${B}..

What about in C SHELL script?

What will be the same command in tcl and also in UNIX if A and B are environment variables?
What is the command to list the contents of the two variables A and B in tcl? Will the following command work? If not, please let me know the syntax.

list { $A $B}
 

Can do the Same in cshell script..

In c shell u can call like this

setenv cvar C
echo $cvar
echo "${cvar}_"



in tcl if A and B are environmental variable

we can use {} to indicate the start and end of variable so that we can separate other things

EX:- _

puts "${env(A)}_"
puts "${env(B)}_"

It will work fine..
 

Can do the Same in cshell script..

In c shell u can call like this

setenv cvar C
echo $cvar
echo "${cvar}_"



in tcl if A and B are environmental variable

we can use {} to indicate the start and end of variable so that we can separate other things

EX:- _

puts "${env(A)}_"
puts "${env(B)}_"

It will work fine..

I asked the questions in the same context of name of a directory. So please reply how I can name the directory for which you wrote for tcl the syntax is ${A}_${B}.

You are now writing probably individual printing with puts.

I have another question

What is the command to list the contents of the two variables A and B in tcl? Will the following command work? If not, please let me know the syntax.
list { $A $B}
 

Hai sunray,

Please review my previous post i have said same

I asked the questions in the same context of name of a directory. So please reply how I can name the directory for which you wrote for tcl the syntax is ${A}_${B}.

is same so answer is

${A}_${B}

What is the command to list the contents of the two variables A and B in tcl? Will the following command work? If not, please let me know the syntax.
list { $A $B}

answer is
puts "$a $b"
 

Hai sunray,

Please review my previous post i have said same

I asked the questions in the same context of name of a directory. So please reply how I can name the directory for which you wrote for tcl the syntax is ${A}_${B}.

is same so answer is

${A}_${B}


Do you want to mean that in UNIX the syntax is ${A}_${B}?

What is the command to list the contents of the two variables A and B in tcl? Will the following command work? If not, please let me know the syntax.
list { $A $B}

answer is
puts "$a $b"

How can I collect the list in a variable. Will the following command correct in tcl to collect the list in a variable named C?

set C [puts "$a $b"]

Will the {} work instead of ""? In that case will the following command work to collect the list in variable C
set C [puts {$a $b}]


REGARDS
 

I dont know about in unix

Also please make ur question more clear regarding tcl..I am finding little hard to grab ur quesiton

is $a and $b are separate variables or it is separate list??

also whether u need both variable values in another variable??

or two list to another list??
 

I dont know about in unix

Also please make ur question more clear regarding tcl..

I wanted the answer for UNIX also.

is $a and $b are separate variables or it is separate list??

a and b are separate variables and not separate lists.

also whether u need both variable values in another variable??

or two list to another list??

I want to make a list of the contents of the two variables named a and b. I also want the list to have a name.

Please let me know if it is not still clear.
 

Hsi sunray,

set x 1
set y 2
set c [list $x $y]

Here c is a list contains the value of two seperate variables..
 

Hsi sunray,

set x 1
set y 2
set c [list $x $y]

Here c is a list contains the value of two seperate variables..

What about the answer of other questions?
 

sure..


can u please repeat the question clearly...
 

- - - Updated - - -

sure..


can u please repeat the question clearly...

I have two variables A and B both having some values. Now one of the directories has the name in such a way that the name of the directory is $A_$B. Now in the script, I want to mention one path where $A_$B is a sub directory. I specified the name of this sub directory in the path as $A_$B. But I am getting an Error stating no variable named $A_. So it can be concluded seeing the error that the script while running is taking A_ as a variable instead of A which I want to take as the variable in that path in the script. How can I solve this issue? It is needed for me to define the path with the sub directory defined with the help of A and B variables as stated above. Please provide me the syntax both in tcl and CSHELL. Please also provide me the syntax of this both in CSHELL and tcl if A and B are environment variable.
 
Last edited:

Hi sunray

Let me explain this clearly

assume that my environmental variable

a has value cshell
b has value code

I need to mention a path like

/export/cshell_code/folder/subfoldername/input

Example :-

In cshell u can call environmental variable as below

foreach line ( "`cat /export/${a}_${b}/folder/subfoldername/input`" )
if("$line" =~ *fatal*)then
echo $line >> fatal;
else if("$line" =~ *necessary*)then
echo $line >> necessary;
endif
end

In tcl u can call environmental variable as below

set file1 [open "/export/${env(a)}_${env(b)}/folder/subfoldername/input" r]
set file_fatal [open "./fatal" w]
set file_necessary [open "./necessary" w]
while {[gets $file1 line] >= 0} {
if { [regexp {fatal} $line] } {
puts $file_fatal $line
}
if { [regexp {necessary} $line] } {
puts $file_necessary $line
}
}
close $file1
close $file_fatal
close $file_necessary


I think this will me more understandable for u.. concept with example that u need..
 
Hi

Is it possible in tcl to collect the options of the main command as $1, $2, $3 etc and use them accordingly inside the script?

Regards
 

Hai sunray.,

We can send using command line arguments in tcl................
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top