[Asterisk-Users] Macro's and Var Scope's

Alex Barnes abarnes at ubiquitysoftware.com
Mon Oct 4 07:36:10 MST 2004


I think I know why the Vars are getting "lost".
 
I didn't realise that the Dial() command changes the channel the script
is executing in.  For example if I run a SetVar before the dial it is
set in the CALLER's channel space.  When running a macro in the Dial
Command the channel space becomes that of the CALLEE.  
 
So the question is, is not being able to put ARGS on the the Dial
command macro option a bug.  If it isn't how are you expected to share
variables across channel spaces without doing something silly like put
it in a global variable.  If it is I shall raise it (once I know how to
raise bugs).
 
 
---------------------------------------------------------------
    -- Executing SetVar("SIP/snom-ee1d",
"CALLFILENAME=/tmp/call_logs/6101/20041004-143928-6107") in new stack
    -- Executing Dial("SIP/snom-ee1d",
"SIP/pingtel|10|tTM(record-start)") in new stack
    -- Called pingtel
    -- SIP/pingtel-5a9c is ringing
    -- SIP/pingtel-5a9c answered SIP/snom-ee1d
    -- Executing SetVar("SIP/pingtel-5a9c",
"CALLFILENAME=/tmp/call_logs//20041004-143929-6107") in new stack
--------------------------------------------------------------- 
 
thanks for any help on this
 
alex
 

	-----Original Message-----
	From: Alex Barnes 
	Sent: 04 October 2004 14:09
	To: asterisk-users at lists.digium.com
	Subject: [Asterisk-Users] Macro's and Var Scope's
	
	
	Hi,
	 
	I am having difficulty getting my record phone call dial-plan
script working.  I have tried the example record call scripts but they
start recording before they are actually connected to an end point, e.g.
you get ringing or announcements being recorded.
	 
	It seems to me that these are bugs with the Dial() command:
	 
	1) Using M(x) in a dial command does not allow argument to be
passed.  Using something like "Dial(${ARG2},10,tTM(record-start,1111))"
means that the macro cannnot be found.
	 
	2) Variables are not passed from one context into another when
using the M(x) command.  For example the variable CALLFILENAME set in
stdexten cannot be seen by record-start but can be seen if I use the
Macro() command rather than Dial() with the M(x) switch.
	 
	 
	If anyone can offer any advice it would be much appreciated. Pls
note the working method is included but commented out I hope thats not
confusing.  Also record-cleanup is called from the default context when
ever a call is hung-up (not sure if thats a good thing to do or not).
	 
	If I set the vars as globals then the script works perfectly but
I assume this would go horribly wrong once there are two or more calls
connected.
	 
	 
	SCRIPT
	----------------------------------
	
;-----------------------------------------------------------------------
------
	[macro-stdexten]
	exten => s,1,Answer
	exten => s,2,Playback(transfer)                 ;play transfer
(please hold whilst i try to conenct you)
	 ;exten => s,3,Macro(record-start)    ; WORKS but starts
recording before connect
	 ;exten => s,4,Dial(${ARG2},10,tT))    ; WORKS but starts
recording before connect
	exten =>
s,3,SetVar(CALLFILENAME=/tmp/call_logs/${ARG1}/${TIMESTAMP}-${CALLERID})
	exten => s,4,Dial(${ARG2},10,tTM(record-start))
	exten => s,5,Goto(s-${DIALSTATUS},1)            ; Jump based on
status (NOANSWER,BUSY,CHANUNAVAIL,CONGESTION,ANSWER)
	 
	;--<SNIP>--
	 
	
;-----------------------------------------------------------------------
------
	[macro-record-start]
	 ;exten =>
s,1,SetVar(CALLFILENAME=/tmp/call_logs/${ARG1}/${TIMESTAMP}-${CALLERID})
; WORKS but starts recording before connect
	exten => s,1,SetVar(STARTREC=true)
	exten => s,2,NoOp(${CALLFILENAME})   ; Debug
	exten => s,3,NoOp(${ARG1})     ; Debug
	exten => s,4,NoOp(${EXTEN})     ; Debug
	exten => s,5,Monitor(wav,${CALLFILENAME})
	exten => s,6,NoOp
	 
	
;-----------------------------------------------------------------------
------
	[macro-record-cleanup]
	 ;exten => s,1,GotoIf($[${CALLFILENAME} = ${NULL}]?6:2) ; WORKS
but starts recording before connect
	exten => s,1,GotoIf($[${STARTREC} = ${NULL}]?6:2)
	exten => s,2,StopMonitor
	exten => s,3,System(/usr/local/bin/soxmix ${CALLFILENAME}-in.wav
${CALLFILENAME}-out.wav ${CALLFILENAME}.wav)
	exten => s,4,System(/usr/bin/notlame --preset phone
${CALLFILENAME}.wav ${CALLFILENAME}.mp3)
	exten => s,5,System(rm ${CALLFILENAME}*.wav)
	 
	; End of routine, return to calling point (note: NoOp required
for GotoIf called from priority 2)
	exten => s,6,NoOp

	 


	
	Dear Friends of Ubiquity Software: 
	 
	As you may have noticed, Ubiquity Software began using the web
domain ubiquity.com earlier this year in addition to the previously
established ubiquity.net for our website and email communications to
you.  However, since that time, a dispute has emerged with respect to
actual ownership of the ubiquity.com domain.

	 
	As an international software company founded over decade ago,
you can always reach Ubiquity Software under the website
www.ubiquity.net <http://www.ubiquity.net/ <http://www.ubiquity.net/> >
and via email at @ubiquity.net.  However, we have also chosen to expand
our domain to the more specific www.ubiquitysoftware.com
<http://www.ubiquitysoftware.com/ <http://www.ubiquitysoftware.com/> >
for web and @ubiquitysoftware.com for email communications.
	 
	Please use either the historical ubiquity.net or begin to use
the new ubiquitysoftware.com domain for all email communications to
Ubiquity employees from now on. 
	  
	Thank you.
	 
	Regards,
	 
	Ubiquity Software 
	www.ubiquitysoftware.com <http://www.ubiquitysoftware.com/
<http://www.ubiquitysoftware.com/> > 
	info at ubiquitysoftware.com <mailto:info at ubiquitysoftware.com>  

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.digium.com/pipermail/asterisk-users/attachments/20041004/725c4ecc/attachment.htm


More information about the asterisk-users mailing list