Tcl and OTcl Tutorial For NS2 - Procedures - In the past, when I started to start blogging, many thoughts disturbed me. I want to have a blog with a nice and interesting look. I am constantly looking for basic tutorials from some web and blogs on the internet. And thankfully, one by one I started to do it, and of course have to go through some confusion process first, but the most important of a blog that is content, yes on the blog
Innaz Review we will discuss a lot of information about gadgets that are very in need by you, now we will discuss first about Tcl and OTcl Tutorial For NS2 - Procedures please refer to the information we will convey until completion:
Articles :
Tcl and OTcl Tutorial For NS2 - Procedures
full Link :
Tcl and OTcl Tutorial For NS2 - Procedures
You can also see our article on:
Tcl and OTcl Tutorial For NS2 - Procedures
Procedures
Procedures are an essential component of Tcl and can be used to make programming ns simpler. As in any functional programming language, procedures can be used for repetitive tasks, or simply to logically break down the tasks in the program.Procedures are defined in Tcl as follows:proc proc1 {} {
puts "in procedure proc1"
}
This defines a procedure that takes no parameters and prints out "in procedure proc1". To call this procedureproc1
can be used.A procedure with parameters can be defined as follows:proc proc2 {parameter1} {
puts "the value of parameter1 is $parameter1"
}
This procedure can be invoked as follows:proc2 10
A procedure that returns a value can be defined as follows:proc proc3 {min max} {
set randomvar [rand $min $max]
return $randomvar
}
This procedure generates a random variable and returns it to the calling function. This can be invoked as followsset randomvar [proc3 0 1]
to obtain a uniform random value between 0 and 1.Sometimes it is necessary within a procedure to reference a variable that has global scope. This is the purpose of the global keyword. So, for example, in an ns script, the simulator object typically is called ns, and typically has global scope. So, it could be referenced in a procedure as follows:proc proc4 {} {
global ns
$ns at 10.0 "exit 0"
}
A logical way to break down an ns script can be as follows:set ns [new Simulator]
create_topology
create_agents
create_sources
create_recorders
$ns run
where create_topology, create_agents, create_sources and create_recorders are all procedures.
so much information Tcl and OTcl Tutorial For NS2 - Procedures
hopefully Tcl and OTcl Tutorial For NS2 - Procedures information can provide benefits for you in determining the gadgets that fit your needs in daily life.
you just read Tcl and OTcl Tutorial For NS2 - Procedures if you feel this information is useful and want to bookmark or share it please use link https://innaz2.blogspot.com/2012/12/tcl-and-otcl-tutorial-for-ns2-procedures.html if you want more information please search on other pages this blog.
Tag :
Tags :
0 komentar:
Posting Komentar