[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [ns] help





Chen Wen-Jen wrote:

> hello...
> attached file is my script.
> Why I always get this error messgae?
>
> ns: record: can't read "dest(1)": no such variable
>     while executing
> "$dest($i) set bytes_"
>     (procedure "record" line 10)
>     invoked from within
> "record"
>
> Could anybody help me? thanks in advance...
>
>                      Jay...

You had some problems with the syntax. They are fixed in the following version of
your record procedure:

proc record {} {
    global dest bw_f ns

    set next_time 0.1
    set now_time [$ns now]
    for {set i 1} {$i < 65} {incr i} {
        set by($i) [$dest($i) set bytes_]
    }

    set byall 0
    for {set i 1} {$i < 65} {incr i} {
        set byall [expr $byall + $by($i)]
    }
    puts $bw_f "$now_time [expr $byall/$next_time*8/1000000]"

    for {set i 1} {$i < 65} {incr i} {
        $dest($i) set bytes_ 0
    }
    $ns at [expr $now_time + $next_time] "record"
}

-- Felix Hernandez