[prev in list] [next in list] [prev in thread] [next in thread] 

List:       tkined
Subject:    Re: [tkined] Returning after the callback execution...
From:       Juergen Schoenwaelder <schoenw () ibr ! cs ! tu-bs ! de>
Date:       2002-08-13 15:25:26
[Download RAW message or body]


>>>>> Ajit Bhat writes:

Ajit> Please check the following procedure.

[...]

Ajit> I want this proc to return '1' if the snmp-set is
Ajit> successful. But it ALWAYS returns 0!  I think the "snmp wait"
Ajit> doesn't affect the return to actually wait.  How can I work
Ajit> around this problem? Or any other thoughts on this?

The problem is that the callback is executed in global scope and thus
the success variable in global scope is not the same as the success
variable in the setValue scope.

Here is a solution that should work better:

proc setValue1 {session oid value} {
    global success
    set success 0
    $session set [list [list $oid $value]] {
        if {"%E" == "noError"} {
            set success 1
        } else {
            set success 0
        }
    }
    $session wait

    return $success
}

And since you do not gain anything here by doing async. sets, you
can even use this version:

proc setValue2 {session oid value} {
    return [expr ! [ catch { $session set [list [list $oid $value]] } ]]
}

/js

-- 
Juergen Schoenwaelder    <http://www.informatik.uni-osnabrueck.de/schoenw/>


-- 
!! This message is brought to you via the `tkined' mailing list.
!! Please do not reply to this message to unsubscribe. To unsubscribe or adjust
!! your settings, send a mail message to <tkined-request@ibr.cs.tu-bs.de>
!! or look at https://www.ibr.cs.tu-bs.de/mailman/listinfo/tkined.
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic