Summary:ASTERISK-12664: Read() does not set variable
Reporter:Ray Morris (raymor)Labels:
Date Opened:2008-08-30 11:21:25Date Closed:2011-06-07 14:03:00
Versions:Frequency of
Description:When Read()ing dtmf input, although the debugging
console shows what the user entered the variable
is left unset.  For example, this code from the
documentation does not work:

exten => s,1,Gotoif($[ "${LEN(${extensao})}" < "3"]?3:100)
exten => s,n,NoOp(executando - ${extensao} - )
exten => s,n,Read(digito||1)
exten => s,n,SayDigits(${digito})
exten => s,n,Set(extensao=${extensao}${digito})
exten => s,n,GoTo(s,1)
exten => s,100,GoTo(from-pstn,s,1)
exten => h,1,hangup()

SayDigits says nothing because ${digito} is empty
regardless of what the user presses.
Comments:By: Mark Michelson (mmichelson) 2008-08-30 16:05:24

The reason this isn't working is because Asterisk 1.6 requires that a comma (",") be used to separate arguments instead of a pipe ("|"). Try replacing the pipes with commas and see if the problem still exists.

By: Mark Michelson (mmichelson) 2008-08-30 16:06:34

Oh, another thing, you mentioned that the code you were testing is from documentation. Which document was this? We need to update the documentation to use the correct symbols so that it's not invalid.

By: Ray Morris (raymor) 2008-09-01 13:03:17

I downgraded to Asterisk in order to get things
working, so I can't confirm the fix.  I can however confirm
that commas work in, so documentation should reflect
that for ease of upgrading commas are preferred in 1.4.

One place pipes appeared in documentation is the wiki:

I have updated the wiki. When updating I made it read that
commas would work in 1.4, based on testing it in
Please update the wiki if commas were not allowed in 1.4.

Presumably any documentation of Read() that has not been
recently updated shows the old syntax.

This is actually one example of a much larger bug -
Asterisk has too many syntax changes generally.
For example, there have been at least three different
incompatible ways of setting the caller ID for different
1.x versions.  Syntax should be changed less often and
whenever possible changes should EXTEND existing syntax
rather than replacing it in order to achieve compatibility
between versions when possible.

By: Tilghman Lesher (tilghman) 2008-09-03 11:27:09

What are those 3 incompatible ways?  I only know of 2:  SetCallerID in 1.0 and Set(CALLERID(all)=...) in 1.2 and later.

By: Mark Michelson (mmichelson) 2008-09-03 14:35:14

The issue at hand, the fact that Read was not populating the variable, has been identified as being the use of pipes instead of commas. I have confirmed by making a sample dialplan that used pipes that the issue the reporter mentions happens.

As far as the comma and pipe usage goes, it is documented in UPGRADE.txt in the Asterisk source directory of 1.6.0. That document is the place to look to find behavior changes and application syntax changes when upgrading major versions of Asterisk.

Anyway, as far as backwards-compatibility of applications goes, this really isn't the proper forum for this sort of discussion. I'm not trying to blow off your point, but we've been hearing about this more and more the past few months and so our future efforts when changing the code is to preserve backwards-compatibility of old applications if at all possible. As far as changing things which were removed with the 1.2 or 1.4 releases goes, that's a different matter.

Anyway, since the issue reported here has been identified and no fix is necessary, I'm going to go ahead and close this issue.

By: Ray Morris (raymor) 2008-09-03 15:51:07

To answer the question from Corydon76 (administrator) ,
these are the ways I was referring to:

exten => 2,n,SetCIDNum(19797102021)
exten => 2,n,SetCIDName(Intergroup)

exten => 2,n,SetCallerID(9798236391)

exten => 2,n,Set(CALLERID(name)=Intergroup)

exten => 2,n,Set(CALLERID=Intergroup <19797102021>)

a) SetCIDNum() and SetCIDName()
b) SetCallerID()
c) Set(CALLERID())

I will refrain from commenting further on this
unless an administrator has a question or something
of that nature.

By: Tilghman Lesher (tilghman) 2008-10-22 17:37:25

Reclosing, as no change is necessary.