-
At first you need to schedule the "loop" proc to execute at the
start (or whenever you like) of the simulation.

Then, you need to put the "re-scheduling" code inside the procedure itself
in order to make it recursive. In this way the loop procedure will execute
once
at the start of the simulation and then every time it is executed it will
re-schedule itself.
You can also use the "now" method of the Simulator object, in order to get
the exact current time
of execution of the procedure as below.

For example you need to change the code to something like this:

proc loop {} {
        global abc value inc ns

        set value [$abc get_value]
        set current_time [$ns now]
        set time  [expr {$current_time + $inc}]
        $ns at $time "loop"
        exit 0
}

set time 0.2
set inc 0.01
$ns at $time "loop"
}



On 2/9/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
>
> ---------- Forwarded message ----------
> From: "Somera Javed" <[EMAIL PROTECTED]>
> To: ns-users@ISI.EDU
> Date: Fri, 9 Feb 2007 03:41:46 +0500
> Subject: [ns] How to call a procedure after a constant delay
> Hi,
> i  am trying to call a procedure after a delay of every 0.01 sec
>
> proc loop {} {
>         global abc value
>         set value [$abc get_value]
>         exit 0
> }
> set time 0.2
> set inc 0.01
> while 1 {
>     $ns at $time "loop"
>     set time [expr $time + $inc]
>     if {$value == 1} break;
> }
>
> but the program stuck while execution
> what is the right way to do this???
>
>
>
> ---------- Forwarded message ----------
> From: "Scott Ricketts" <[EMAIL PROTECTED]>
> To: ns-users@ISI.EDU
> Date: Thu, 8 Feb 2007 15:29:47 -0800
> Subject: Re: [ns] How to call a procedure after a constant delay
> It looks to me like you are putting the Otcl interpreter in an
> infinite loop before the simulation starts. That is, "loop" is getting
> scheduled every time the while loop iterates, but it does not actually
> get called until you do $ns run, so $value never gets set.
>
> -Scott
>
> _______________________________________________
> Ns-users mailing list
> Ns-users@isi.edu
> http://mailman.isi.edu/mailman/listinfo/ns-users
>
>


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

Reply via email to