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.
Re: procedure in tcl language

$argv 0 is getting the filename Its getting command line arguments..

So $argv is for the command tclsh fatal_necessary.tcl filename. The zero in $argv 0 is for getting the 'filename' in command line. But how can the 'filename' be the zeroth element? It shoud be the 1st element in the command line. Is not it?

Regards
 

Re: procedure in tcl language

Hai sun_ray,

The index of the array element normally starts with '0'

Its array concept........ So it is 0 the next element will be '1'.
 

Re: procedure in tcl language

Hi

Can you please provide a C shell script that can separate the necessary and fatal as done by this tcl scripts?
 

Re: procedure in tcl language

Hai sun_ray,

sorry I am not having exposure in c shell.. if u want this in perl or skill language i can do it.....
 

Re: procedure in tcl language

Hai sun_ray,

sorry I am not having exposure in c shell.. if u want this in perl or skill language i can do it.....

Can you write in Shell scripting language?

Is it that in the file that contains the script the procedure should be first described and then the procedure should be called in the lines after the description of the procedure? In that case is it that script command execute sequentially?


In which field and company do you work in?

Regards
 
Last edited:

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 - - -

Physical Design engineer in an MNC
 
foreach line ( "`cat input`" )


What is input here? Is 'input', the name of the file that is being read? What will be the command to run the above script?


Is it that scripting has some basic ideas irrespective of the scripting language and that should be learned to be good script writer? Can you please help me with tips to be a good script writer? I want to use both tcl and shell.
 

Hai sunray,

Input is the "filename"

EX;- save the above code in a file named new.csh

run as

csh new.csh
 

Vijay

You did not answer following if my queries

1. Is it that in the file that contains the script the procedure should be first described and then the procedure should be called in the lines after the description of the procedure? In that case is it that script command execute sequentially?

2. Is it that scripting has some basic ideas irrespective of the scripting language and that should be learned to be good script writer? Can you please help me with tips to be a good script writer? I want to use both tcl and shell.

Regards
 

Hai sunray,

1. As i said earlier i am not familar in c shell.. but the above c shell code executed line by line.. and u can make it to procedure and just recall it.. that it.. surely it will execute sequentially..

2. Scripting is easier if u know the syntax and fundamentally we should know concepts like function, array, file concept..

Yes surely i will help u..
 

Ho Vijay

1. I wanted to know about a procedure in tcl and not in shell. Please reply with respect to to tcl for any procedure and not only the script that you wrote.

Thanks for your positive reply in helping me. Please let me know the first basic steps or tasks I should accomplish at the beginning to start with scripting in tcl, shell, perl.
 

Hai sun ray,

1. procedure is easy.. just we need to define and then we need to call

There are different way to define and call procedure

procedure with arguments
procedure without arguments
procedure with return type

etc..,

Based on your needs we can go ahead

First step try working with basic tcl programs like

read and write file
pattern matching concept
function
 

Hai sun ray,

1. procedure is easy.. just we need to define and then we need to call

There are different way to define and call procedure

procedure with arguments
procedure without arguments
procedure with return type

etc..,

My question was different. My question was whether tcl scripts are executed sequentially line by line or not. Suppose I have a tcl script such that the entire script is just inside a file. Now in that file I have called a procedure at line number 46 in that file and I defined/described that procedure at line no. 100. Will it work?


Can you recommend some good website /book to learn tcl well. You take me as a beginner in tcl. Do not you think learning reading/writing file in tcl will be the first step I should take or something else I should read.

Regards
 

hai sunray,

tcl scripts r executed line by line by line ...

so surely we can do like that... surely procedure will be called.. but we can simply define all procedure before the operation code..

so that we can call whereever we want..



some Valuable tcl sites

https://vismod.media.mit.edu/tech-reports/TR-495/node21.html


https://www.isi.edu/nsnam/ns/tutorial/nsscript1.html


file concept and pattern matching is the most important task.. I would prefer u to learn this first and then go ahead with procedure..
 
Last edited by a moderator:

hai sunray,

tcl scripts r executed line by line by line ...

so surely we can do like that... surely procedure will be called.. but we can simply define all procedure before the operation code..

so that we can call whenever we want..

But I defined a procedure in line no. 100 and called it at line no. 46 and found it is not being called. So procedure will have to be defined before line no. 46. Is not it?

What do you mean by operation code?

file concept and pattern matching is the most important task.. I would prefer u to learn this first and then go ahead with procedure..

I do not want to go to procedure. I want to start from beginning. You take me as if I do not know tcl procedure and anything of tcl. Then you advise. Do not you think I should first learn how to write a comment in tcl, what is the basic construct of tcl like concept of list, about lsearch etc. I want you to take me as a person who has never written a script neither in tcl, perl, UNIX etc and do not know scripting at all.
 

it sounds good if u call before line 46.

operation code means first code for operating the task

k but in my meantime i can do it for u..

but u try learning some concepts if u are having any doubt feel free to ask doubt........

lsearch all will come under list concept

list and array are quite similar
 

it sounds good if u call before line 46.

I think somehow you missed what I am asking. Let me ask the question again

Question:Suppose I have a tcl script such that the entire script is just inside a file. Now in that file I have called a procedure at line number 46 in that file and I defined/described that procedure at line no. 100. Will it work?


The reason I ask this question because in a file which has the entire script, I described/defined a procedure in line no. 100 and called it at line no. 46 and found it is not being called.
 

Hai sunray

I haven't mentioned like that way in any of my code,

I will define procedure before i call.

Define procedure before is one of the best call..

and May be it has way to declare after...,

But my question is

what is the disadvantage of defining the procedure before..???

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

if u said answers for this i can able to say an optional way for this.
 
Last edited:

Hai sunray

I haven't mentioned like that way in any of my code,

I will define procedure before i call.

Define procedure before is one of the best call..

and May be it has way to declare after...,

But my question is

what is the disadvantage of declaring the procedure before..???

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

if u said answers for this i can able to say an optional way for this.

I think you have not still got the question.

Let me write that I did not state I defined the procedure in line 40. I called the procedure at line 40. The procedure has been described and defined at line number 100. So basically you are calling the procedure and then you are describing the procedure. Is it acceptable and work?

Let me create an example. Suppose proc is a procedure with argument 'a'. So in the script file the following call exist at line no. 40:

line no. 40: proc $a

Now this proc is described/defined as follows at line no 100.

line no. 100: proc(a) {

Contents of the procedure
}

Hope it clarifies the question


I did it and found it was not working.
 

Hai sun ray,

I got ur question..

can u please review my previous post[edited to be more understandable] and answer..

i havent found anyway for calling procedure before defining in tcl.. but i did like this in other languages.. but tcl I havent tried...

please answer to the above post?? it will give some idea why and wats the need??
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top