-
Of course I can...! no worries there!

The problem with your code is in the "record" procedure
and specifically at the "global" command, which brings
into local scope the array "sink".

In particular, the error that you are making is that you are trying
to bring in local scope only one element of the array, i.e. sink(1)
which is not acceptable as a variable for tcl (although it is in reality
but with arrays it does not work this way).

In order for the code to work you are going to have to bring in local
scope the whole array and not only a single element.

I mean that the only thing you have to do is to change the command
from "global sink(1)" to "global sink" and you are good to go.

Have a nice weekend....;-)

-Fk

On 9/29/06, Renata Vidal <[EMAIL PROTECTED]> wrote:
>
> Filippos,
>
> Can you help me?
>
> ---------- Forwarded message ----------
> From: Renata Vidal <[EMAIL PROTECTED]>
> Date: Sep 28, 2006 2:47 PM
> Subject: LossMonitor - can't read, no such variable
> To: ns-users <ns-users@isi.edu>
>
>
> Hi,
>
> I was trying to use the LossMonitor, but I see the message:
> ns: record: can't read "sink(1)": no such variable
>     while executing
> "$sink(1) set bytes_"
>     (procedure "record" line 12)
>     invoked from within "record"
>
> This a piece of my code, I don't know whats is wrong:
>
> (..)
> set sink($i) [new Agent/LossMonitor]
> $ns attach-agent $s($i) $tcp($i)
> $ns attach-agent $r($i) $sink($i)
> $ns connect $tcp($i) $sink($i)
> (..)
> proc record {} {
> puts stderr "recording"
> global sink(1) f0
> set ns [Simulator instance]
> set time 0.5
> set bw0 [$sink(1) set bytes_]
> set now [$ns now]
> puts $f0 "$now [expr $bw0]"
> $ns at [expr $now+$time] "record"
> }
>
> Any Clue?
>
> --
> Renata Vidal
> "Triste é o destino de quem tenta vencer as batalhas e ter sucesso nos
> ataques sem cultivar o espírito da iniciativa (A Arte da Guerra – SUN
> TSU – pg 102)"
>
>
> --
> Renata Vidal
> "Triste é o destino de quem tenta vencer as batalhas e ter sucesso nos
> ataques sem cultivar o espírito da iniciativa (A Arte da Guerra – SUN
> TSU – pg 102)"
>



-- 
Filippos N Kolovos

Software Systems Analyst & Engineer
M.Sc. (Eng.) in Data Communications

Automation & Networking Department
University of Macedonia Library
Egnatia 156, P.O.Box 1591
540 06 Thessaloniki, Greece

E-Mail: [EMAIL PROTECTED],
           [EMAIL PROTECTED]
Phone: +30-2310-891-826
----------------------------------------------

Reply via email to