TCL issue : Can´t read .. no such variable

Version 1
    This document was generated from CDN thread

    Created by: Jean Lofrano on 13-07-2011 08:50:12 AM
     
    Hi,
     
     
     
     
    The router debug is bellow...
    *Jul 12 18:35:24.717: //55//TCL :/tcl_PutsObjCmd: IT7: playing audio Welcome
    *Jul 12 18:35:24.717:
    *Jul 12 18:35:24.717: //55//TCL :/tcl_PutsObjCmd: IT7: Caller ID 7081
    *Jul 12 18:35:24.717:
    *Jul 12 18:35:24.721: //55//TCL :/tcl_PutsObjCmd: IT7: Audio played Welcome
    *Jul 12 18:35:24.721:
    *Jul 12 18:35:28.773: //55//TCL :/tcl_PutsObjCmd: IT7: playing question 1
    *Jul 12 18:35:28.773:
    *Jul 12 18:35:28.773: //55//TCL :/tcl_PutsObjCmd: IT7: played question 1
    *Jul 12 18:35:28.773: 2
    *Jul 12 18:35:31.549: //55//TCL :/tcl_PutsObjCmd: IT7: collecting question 1
    *Jul 12 18:35:31.549:
    *Jul 12 18:35:31.549: //55//TCL :/tcl_PutsObjCmd: IT7: collected question 1
    *Jul 12 18:35:31.549:
    *Jul 12 18:35:42.629: //55//TCL :/tcl_PutsObjCmd: IT7: try to send web
    *Jul 12 18:35:42.629:
    *Jul 12 18:35:42.629: //55//TCL :/tcl_PutsObjCmd: IT7: cpf cd_005
    *Jul 12 18:35:42.629:
    *Jul 12 18:35:42.629: //55//TCL :/tcl_PutsObjCmd: IT7: starting web
    *Jul 12 18:35:42.629:
    *Jul 12 18:35:42.629: //55//TCL :/tcl_PutsObjCmd: IT7: URL Validacao #1 http://1                                                                             72.20.1.15:9778/URA/ValidarCPF?telefoneorigem=7081&cpf=22784639185
    *Jul 12 18:35:42.629:
    *Jul 12 18:35:42.629: //55//TCL :/tcl_PutsObjCmd: IT7: sent web
    *Jul 12 18:35:42.629:
    *Jul 12 18:35:42.629: //55//TCL :/tcl_PutsObjCmd: IT7: end try to send web
    *Jul 12 18:35:42.629:
    *Jul 12 18:35:45.281: //55//TCL :/tcl_PutsObjCmd: IT7: processing web return
    *Jul 12 18:35:45.281:
    *Jul 12 18:35:45.281: //55//TCL :/tcl_PutsObjCmd: IT7: Web Return:16494:
    *Jul 12 18:35:45.281:
    *Jul 12 18:35:45.281: //55//TCL :/tcl_PutsObjCmd: IT7: ------> Return OK - playi                                                                             ng question 2
    *Jul 12 18:35:45.281:
    *Jul 12 18:35:45.281: //55//TCL :/tcl_PutsObjCmd: IT7: Web Return:16494:
    *Jul 12 18:35:45.281:
    *Jul 12 18:35:45.281: //55//TCL :/tcl_PutsObjCmd: IT7: Web Return:16494
    *Jul 12 18:35:45.281:
    *Jul 12 18:35:52.549: //55//TCL :/tcl_PutsObjCmd: IT7: collect question 2
    *Jul 12 18:35:52.549:
    *Jul 12 18:35:52.549: //55//TCL :/tcl_PutsObjCmd: IT7: collected question 2
    *Jul 12 18:35:52.549:
    *Jul 12 18:36:00.533: //55//AFW_:/AFW_FSM_Drive: Tcl_Eval to drive FSM inside Tc                                                                             l modulespace. code=1 code=ERROR
    *Jul 12 18:36:00.533: TCL script failure
            Result:
                             can't read "UserKey": no such variable
    *Jul 12 18:36:00.533:   TCL script failure errorInfo:
                            can't read "UserKey": no such variable
        while executing
    "set URL http://$WebServer/URA/ValidarTelefone?telefoneorigem=$CallerID&user_key                                                                             "$UserKey&telefone=$Response2
        (procedure "Action2" line 17)
        invoked from within
    "Action2"
     
     
    I need to use the Webreturn value in the action 2... but it is not working....
     
     
    proc ActionPlayQuestion1 { } {
        puts "IT7: playing question 1"
        media play leg_incoming "flash:/digite-cpf1.wav"
        puts "IT7: played question 1"
    }
    proc ActionPlayQuestion1Again { } {
        puts "IT7: playing question 1 again"
        media play leg_incoming "flash:/digite-cpf2.wav"
        puts "IT7: played question 1 again"
    }  

    #coleta os digitos da questao 01
    proc ActionCollectQuestion1 { } {
        puts "IT7: collecting question 1"
        set Question1Param(interruptPrompt) true
        set Question1Param(terminationKey) #
        set Question1Param(maxDigits) 11
        set Question1Param(dialPlan) true
        set Question1Pattern(1) "..........."
        leg collectdigits leg_incoming Question1Param
        puts "IT7: collected question 1"
    }
    #send collected digits through web
    proc Action1 { } {
        puts "IT7: try to send web"
        global WebServer
        global Response1
        global WebReturn
        global CallerID
        set StatusCollectDigits [infotag get evt_status]
        puts "IT7: cpf $StatusCollectDigits"
        #matched pattern
        if {$StatusCollectDigits == "cd_005"} {
           puts "IT7: starting web"
           set Response1 [infotag get evt_dcdigits]

           set URL http://$WebServer/URA/ValidarCPF?telefoneorigem=$CallerID&cpf=$Response1

            # http://172.20.1.15:9778/URA/ValidarCPF?telefoneorigem=666&cpf=22784639185
     
        puts "IT7: URL Validacao #1 $URL"
           ::httpios::geturl $URL -command httpCallback1
           puts "IT7: sent web"
        } else {
        puts "IT7: error - playing error audio"
        media play leg_incoming "flash:/informacaoincorreta.wav"
        fsm setstate PLAYEDWRONG1
        puts "IT7: error - played error audio"
        }
        puts "IT7: end try to send web"
    }
    proc httpCallback1 { token } {
       puts "IT7: processing web return"
       if {[::httpios::status $token] == "ok"} {
          set WebReturn [string trim [::httpios::data $token]]
       } else {
          set WebReturn 0
       }
       puts "IT7: Web Return:$WebReturn:"
       if { $WebReturn != "0" } {
          puts "IT7: ------> Return OK - playing question 2"
          media play leg_incoming "flash:/digite-dn1.wav"
         fsm setstate PLAYEDQUESTION2
       } else {
          puts "IT7: wrong information, lets try again"
          media play leg_incoming "flash:/informacaoincorreta.wav"
          fsm setstate PLAYEDWRONG1
       }
    }
     
    #--------------------------------------------------------------------------------
    #--------------------------------------------------------------------------------
    #--------------------------------------------------------------------------------

    #play question 2, second time
    proc ActionPlayQuestion2Again { } {
        puts "IT7: playing question 2 again"
        media play leg_incoming "flash:/digite-dn2.wav"
        puts "IT7: played question 2 again"
    }  

    #coleta os digitos da questao 02
    proc ActionCollectQuestion2 { } {
        puts "IT7: collect question 2"
        set Question2Param(interruptPrompt) true
        set Question2Param(terminationKey) #
        set Question2Param(maxDigits) 10
        set Question2Param(dialPlan) true
        set Question2Pattern(1) ".........."
        leg collectdigits leg_incoming Question2Param
        puts "IT7: collected question 2"
    }

    proc Action2 { } {
        global WebServer
        global Response2
        global CallerID
     
        set StatusCollectDigits [infotag get evt_status]
        #matched pattern
        if {$StatusCollectDigits == "cd_005"} {
           set Response2 [infotag get evt_dcdigits]
         
      set URL http://$WebServer/URA/ValidarTelefone?telefoneorigem=$CallerID&user_key=$WebReturn&telefone=$Response2
     
     
     
     

    Subject: RE: TCL issue : Can´t read .. no such variable
    Replied by: Jean Lofrano on 13-07-2011 08:51:58 AM
    So,

    How can I to use a proc1´s webreturn value in another proc???

    thanks...

    Subject: RE: TCL issue : Can´t read .. no such variable
    Replied by: Raghavendra Gutty Veeranagappa on 13-07-2011 09:15:29 AM
    Hi Jean,

    Please add  "global WebReturn" in your Action2 procedure.

    thanks,
    Raghavendra

    Subject: RE: TCL issue : Can´t read .. no such variable
    Replied by: Jean Lofrano on 26-07-2011 04:37:45 PM
    Ok.. thanks....