hey!<br><br>Following is a small PyS60 script. The error seems related to basic syntax - &quot;state&quot; in  keys() is not recognized although defined globally.<br><br>Would appreciate assistance.<br><br>=============================================<br>
 import appuifw, key_codes, e32, telephone<br>state = None<br><br>def keys(event):<br>    &nbsp;&nbsp;&nbsp;if event[&#39;keycode&#39;] == key_codes.EKeyYes:<br>        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;appuifw.note(u&quot;Doesn&#39;t Matter&quot;)<br>    &nbsp;&nbsp;elif (event[&#39;keycode&#39;] == key_codes.EKeyYes) and (state == telephone.EStatusConnected):<br>
         &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;appuifw.note(u&quot;Yes was pressed and call active&quot;)<br><br>def cb_calling(args):<br>   &nbsp;&nbsp;&nbsp;state = args[0]<br><br>def quit():<br>    &nbsp;&nbsp;&nbsp;app_lock.signal()<br><br>telephone.call_state(cb_calling)<br>canvas = appuifw.Canvas(event_callback = keys)<br>
 appuifw.app.body = canvas<br>appuifw.app.exit_key_handler = quit<br>app_lock = e32.Ao_lock()<br>app_lock.wait()<br>==============================================<br><br>Best,<br> wirefree<br>