buffer value is not getting printed

64 views Asked by At

i have written a code for doing conference between three phones, now i am trying to call a method name confList, which will display the list of all the phones in the conference, but the buffer value which should be the output of last command is con coming up, it is not getting executed.

my confList method is

if {[execCmd -cmd "xCommand Experimental Conference ParticipantList Search CallId: $x" -expectingValue OK -waitTime 15 -buffersize 10000]} {
  OutputInfo error 1 1 0 "[subst $_procInfo] Error in finding the conference Participant List ."

puts "Now my updated budffer is <<<<<< $buffer >>>>>>>>>"
}

in the same way when i tried to execute one another command just above the last statment like this

if {[execCmd -cmd "xstatus call status" -expectingValue OK -waitTime 5]} {
puts "the Buffer value after executing the command is something like this>>>>>>>>>>>>>>>>>>$buffer<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n"
}

then it is giving the expected behaviour, but when i tried to do it from CLI it is giving the correct output and the behaviour is correct only.

The value X is getting there correctly.

please help me out.

1

There are 1 answers

0
wolfhammer On

If the puts statement doesn't run at all then the condition isn't evaluating to true. In that case do a puts on the the "[exec Cmd..." to see what's being returned. If puts runs and the buffer string is empty then you might be running an async command and will need to figure out how to run a callback proc when it's done or make a loop that checks for a buffer response periodically.

Here's an example of how an async proc can be checked.

#!/usr/bin/tclsh

set buffer ""
set count 0

proc async_call {} {
        global buffer
        set buffer "Hello World"
}

proc buffer_check {} {
        global buffer
        global count

        # keep count of buffer checks
        puts [incr count]

        if {$buffer == ""} {
                # buffer is empty.
                # try again in 1 second.
                after 1000 buffer_check
                return
        }

        puts $buffer

        # exit program
        exit
}

# run async_call after 3 seconds
after 3000 async_call

# run the buffer_check
after 1000 buffer_check

# keep program running
vwait forever

Output:

./test.tcl
1
2
3
Hello World