Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
Tutorialspoint

sample

tcl

tclsh

puts"hello world"
wish



#Open the Trace files set file1 [open out.tr w] set winfile [open WinFile w] $ns trace-all $file1 #Define a ‘finish’ procedure proc finish {} { global ns file1 $ns flush-trace close $file1 exec nam out.nam & exit 0 } set n1 [$ns node] set

tcl

puts "Hello World!"
#Open the Trace files
set file1 [open out.tr w] set winfile [open WinFile w] $ns trace-all $file1
#Define a ‘finish’ procedure
proc finish {} {
global ns file1
$ns flush-trace
close $file1
exec nam out.nam &
exit 0
}
set n1 [$ns node] set n2 [$ns node] set lan [$ns newLan “$n1 $n2” 1Mb 40ms LL Queue/DropTail MAC/Csma/Cd
Channel] set tcp [new Agent/TCP/Newreno] $ns attach-agent $n1 $tcp
set sink [new Agent/TCPSink/DelAck] $ns attach-agent $n2 $sink
$ns connect $tcp $sink
$tcp set fid_ 1
$tcp set window_ 65536
$tcp set packetSize_ 1024

#Setup a FTP over TCP connection
set ftp [new Application/FTP] $ftp attach-agent $tcp
$ftp set type_ FTP

proc get_throughput { tcp } {
#now calculate the average throughtput (in Mb/s)
puts “[expr [$tcp set ndatapack_]*8.0/1000/124]Mb/s”
}
$ns at 1.0 “$ftp start”
$ns at 124.0 “$ftp stop”
$ns at 124 “get_throughput $tcp”
$ns at 125.0 “finish”
$ns run

ash7

tcl

proc genrand {max num} {
set result [list] for {set i 0} {$i < $num} {incr i} {
lappend result [expr {int($max * rand())}] }
return $result
}
proc generation {name gen} {
puts “0eneration: $gen0
}
proc evaluate {name entity} {
global goal
set result [expr {100 * 10}] for {set i 0} {$i < 10} {incr i} {
incr result [expr {−1 * abs([lindex $goal $i] − [lindex $entity $i])}] }
return $result
}
proc seed {name entity} {
set seed [genrand 100 10] return $seed
}
proc adapt {name entity} {
return $entity
}
proc mutate {name entity} {
lset entity [genrand 10 1] [genrand 100 1] return $entity
}
proc crossover {name entity1 entity2} {
set cross [genrand 10 1] set child1 [concat [lrange $entity1 0 $cross−1] [lrange $entity2 $cross end]] set child2 [concat [lrange $entity2 0 $cross−1] [lrange $entity1 $cross end]] return [list $child1 $child2] }

Execute Tcl Online

tcl

#Create a simulator object
set ns [new Simulator]

#Open the nam trace file
set nf [open out.nam w]s 
$ns namtrace-all $nf

#Define a 'finish' procedure
proc finish {} {
    global ns nf
    $ns flush-trace
    #Close the trace file
    close $nf
    #Executenam on the trace file
    exec nam out.nam &
    exit0
}


#Create five nodes
set n0 [$ns node]
set n1 [$ns node]
set n2 [$ns node]
set n3 [$ns node]
set n4 [$ns node]
set n5 [$ns node]


#Change the shape of center node in a star topology
$n0 shape square

#Create links between the nodes
$ns duplex-link $n0 $n1 1Mb 10ms DropTail
$ns duplex-link $n0 $n2 1Mb 10ms DropTail
$ns duplex-link $n0 $n3 1Mb 10ms DropTail
$ns duplex-link $n0 $n4 1Mb 10ms DropTail
$ns duplex-link $n0 $n5 1Mb 10ms DropTail

$ns duplex-link-op $n0 $n5 orient right

#Create a TCP agent and attach it to node n0
set tcp0 [new Agent/TCP]
$tcp0 set class_ 1
$ns attach-agent $n1 $tcp0
#Create a TCP Sink agent (a traffic sink) for TCP and attach it to node n3
set sink0 [new Agent/TCPSink]
$ns attach-agent $n3 $sink0
#Connect the traffic sources with the traffic sink
$ns connect $tcp0 $sink0

#Create a TCP agent and attach it to node n0
set tcp1 [new Agent/TCP]
$tcp1 set class_ 1
$ns attach-agent $n2 $tcp1
#Create a TCP Sink agent (a traffic sink) for TCP and attach it to node n5
set sink1 [new Agent/TCPSink]
$ns attach-agent $n5 $sink1
#Connect the traffic sources with the traffic sink
$ns connect $tcp1 $sink1


# Create a CBR traffic source and attach it to tcp0
set cbr0 [new Application/Traffic/CBR]
$cbr0 set packetSize_ 500
$cbr0 set interval_ 0.01
$cbr0 attach-agent $tcp0

#Schedule events for the CBR agents
$ns at 0.5 "$cbr0 start"
$ns at 4.5 "$cbr0 stop"


#Call the finish procedure after 5 seconds of simulation time
$ns at 5.0 "finish"

#Run the simulation
$ns run

prad

tcl

#!/usr/bin/tclsh

puts "Hello, World!"

$ tclsh test.tcl

Execute Tcl Online

tcl

#!/usr/bin/perl 
use warnings; 
use strict; 
use Tk;    # Appel du module Tk 
  
# Programme principal 
# Création de la fenêtre 
my $fenetre = new MainWindow( 
  -title      => 'Première fenêtre Tk', 
  -background => 'white', 
); 
  
# Taille minimale de ma fenêtre 
$fenetre->minsize( 300, 100 ); 
  
my $message_accueil = "Bonjour tout le monde\n\nWelcome dans le monde magnifique de Perl/Tk\n\n";

# Affichage d'un texte 
my $label_accueil = $fenetre->Label( 
  -text       => $message_accueil, 
  -background => 'white', 
)->pack(); 
  
# Affichage d'un bouton pour fermer la fenêtre 
my $bouton = $fenetre->Button( 
  -text    => 'Ferme la fenêtre', 
  -command => sub { exit; }, 
)->pack(); 
  
MainLoop;    # Obligatoire

after vwait

tcl

proc run { name } {
  while { true } {
    puts "$name"
    set x 0; after 1000 { set x 1; }; vwait x
  }
}

after 1000 run 1
after 2000 run 2
after 3000 run 3
after 4000 run 4
after 5000 run 5
after 6000 run 6
after 7000 run 7
after 8000 run 8

vwait forever

jhdveb

tcl

#!/usr/bin/tclsh

set a 3
puts $a

tcl code

tcl

puts [info tcl]
puts [package require TclOO]

wdwqd

tcl

#!/usr/bin/tclsh

set languages(0) Tcl
set languages(1) "C Language"
puts  [array size languages]

Previous 1 ... 5 6 7 8 9 10 11 ... 17 Next
Advertisements
Loading...

We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.