1
set tracefile [open out.tr w]
$ns trace-all $namfile

When I am running the above TCL code this is showing in terminal. I have just started learning TCL so don't know what to do anything this error.

can't read "namfile": no such variable
    while executing
"$ns trace-all $namfile"
Donal Fellows
  • 133,037
  • 18
  • 149
  • 215
  • 1
    Looks like "Net simulator **ns2** otcl commands". `set tracefile [open out.tr w]` and `$ns trace-all $namfile` are two different lines, and are about two different trace file types. See the example `ex1-Rx.tcl` https://drive.google.com/drive/folders/1PHAMygJidHPppjuzuaRtn5Zbq5dq1nZV?usp=sharing ..... to be run with the **ns** interpreter : `$ ns ex1-Rx.tcl` ........... All 3000 ns2 simulation examples https://drive.google.com/drive/folders/0B7S255p3kFXNSmRYb2lGcDRUdWs?resourcekey=0-vrEMHtGTFP3yLoTQz_UAwA&usp=sharing – Knud Larsen Mar 22 '22 at 10:34
  • 1
    The provided snippet doesn't set the namfile variable. Do that to "get rid of the error", e.g. `set namfile mynamfile.txt`. What to set it to depends on where the code is from and what it is trying to do, neither of which you provided in the question so far. – Andreas Mar 22 '22 at 11:05

1 Answers1

0

The error message is pretty clear: the variable called namfile is not set at the point when the code $ns trace-all $namfile is run. I can't tell why from the snippet you provided; maybe it's because you should have used $tracefile instead, or maybe you should set namfile to something and haven't done so? Or even possibly something more complicated. (I also don't know whether you're supposed to give a channel or a filename to the trace-all method; you should look that up.)

Donal Fellows
  • 133,037
  • 18
  • 149
  • 215