Search Results

Search found 3 results on 1 pages for 'otcl'.

Page 1/1 | 1 

  • NS2, Otcl: using a variable of an owned instance within a class

    - by Hussain
    Hello all, I'm using NS2 to create some new classes in C++ and then link them to otcl. The linkage and everything works, but when I try to use the otcl variables in an object, I'm having a trouble. For example, suppose I have a class "Node" with the variable X. In the code I want to set this value and later on use it in some if-statements. Setting the variable is no problem using this code: $node1 set x 4 Now the problem I'm having is when I try to use this variable x anywhere. In C++ we could use a general variable (i.e. y) and say "y=node.x and then use y in some if-statements. I have tried to look for a method to perform the same thing in otcl, but failed. Any help is appriciated. Thanks in Advance.

    Read the article

  • Unable to change the value of the variable

    - by Legend
    I'm using a discrete event simulator called ns-2 that was built using Tcl and C++. I was trying to write some code in TCL: set ns [new Simulator] set state 0 $ns at 0.0 "puts \"At 0.0 value of state is: $state\"" $ns at 1.0 "changeVal" $ns at 2.0 "puts \"At 2.0 values of state is: $state\"" proc changeVal {} { global state global ns $ns at-now "set state [expr $state+1]" puts "Changed value of state to $state" } $ns run Here's the output: At 0.0 value of state is: 0 Changed value of state to 0 At 2.0 values of state is: 0 The value of state does not seem to change. I am not sure if I am doing something wrong in using TCL. Anyone has an idea as to what might be going wrong here? EDIT: Thanks for the help. Actually, ns-2 is something over which I do not have much control (unless I recompile the simulator itself). I tried out the suggestions and here's the output: for the code: set ns [new Simulator] set state 0 $ns at 0.0 "puts \"At 0.0 value of state is: $state\"" $ns at 1.0 "changeVal" $ns at 9.0 "puts \"At 2.0 values of state is: $state\"" proc changeVal {} { global ns set ::state [expr {$::state+1}] $ns at-now "puts \"At [$ns now] changed value of state to $::state\"" } $ns run the output is: At 0.0 value of state is: 0 At 1 changed value of state to 1 At 2.0 values of state is: 0 And for the code: set ns [new Simulator] set state 0 $ns at 0.0 "puts \"At 0.0 value of state is: $state\"" $ns at 1.0 "changeVal" $ns at 9.0 "puts \"At 2.0 values of state is: $state\"" proc changeVal {} { global ns set ::state [expr {$::state+1}] $ns at 1.0 {puts "At 1.0 values of state is: $::state"} } $ns run the output is: At 0.0 value of state is: 0 At 1.0 values of state is: 1 At 2.0 values of state is: 0 Doesn't seem to work... Not sure if its a problem with ns2 or my code...

    Read the article

  • Exporting Environment Variables in Ubuntu Linux

    - by stanigator
    I know many people have asked about environment variables before, but I am having a hard time dealing with these paths while ensuring I don't mess around with the original settings. How would you go about executing these commands in Ubuntu in terms of environment variables? Thanks in advance! Please put /home/stanley/Downloads/ns-allinone-2.34/bin:/home/stanley/Downloads/ns-allinone-2.34/tcl8.4.18/unix:/home/stanley/Downloads/ns-allinone-2.34/tk8.4.18/unix into your PATH environment; so that you'll be able to run itm/tclsh/wish/xgraph. IMPORTANT NOTICES: (1) You MUST put /home/stanley/Downloads/ns-allinone-2.34/otcl-1.13, /home/stanley/Downloads/ns-allinone-2.34/lib, into your LD_LIBRARY_PATH environment variable. If it complains about X libraries, add path to your X libraries into LD_LIBRARY_PATH. If you are using csh, you can set it like: setenv LD_LIBRARY_PATH If you are using sh, you can set it like: export LD_LIBRARY_PATH= (2) You MUST put /home/stanley/Downloads/ns-allinone-2.34/tcl8.4.18/library into your TCL_LIBRARY environmental variable. Otherwise ns/nam will complain during startup.

    Read the article

1