[asterisk-users] Originate with label?
Antony Stone
Antony.Stone at asterisk.open.source.it
Wed Aug 31 08:25:40 CDT 2022
On Wednesday 31 August 2022 at 15:01:57, Mark Murawski wrote:
> On 8/31/22 05:29, Antony Stone wrote:
> >
> > I realise that a better solution might be to wrap assignments (inside
> > Set() or MSet(), no matter) with $[..] *only* if the expressions contain
> > arithmetic operators + - * / and not if they are simple a=b assignments,
> > including a=${b}.
> >
> > This would ensure that even if ${b} expanded to something containing a
> > dash, it would be interpreted as a mathematical minus sign in a=${b}
>
> I would hesitate about making this happen as well.. without a
> migration-plan in place.
Agreed; I didn't mean "please change it now"!
> How is the compiler supposed to tell the difference between the
> following examples, for intent
> var1 = ${a} + ${b} / ${c};
> var2 = Hello World / Hello Bob / Hello Sue
> var3 = *1*1*1* HEY THERE IS A PROBLEM *1*1*1
> var4 = This-Is-Some-Dash-Separated-Data: 1-2-3-4-5-6
Agreed, but for text strings containing such symbols, I have to say that my
natural inclination would be to put them in quote marks, as you say:
> I think what you're looking for is quoted strings.
> var1 = "This-Is-Some-Dash-Separated-Data: 1-2-3-4-5-6"
It's when the *value of a variable* on the right hand side of the assignment
happens to contain an arithmetic operator that the real surprise occurs.
> Which considering MSet actually has a desired behavior here of removing
> quotes, your value of var1 will be exactly what you expect it to be
Strangely enough, I just discovered that as a solution to my example problem,
which was:
---------
Set(Tracker=${CDR(uniqueid)});
resulting in:
Set(Tracker=eagle.domain.com-1661872057.2349)
Just what I want.
However:
Tracker=${CDR(uniqueid)};
results in:
MSet(Tracker=-1661872057.2349)
---------
If I simply do
Tracker="${CDR(uniqueid)}";
it works as required.
It's just not the sort of syntax I've seen in any other language, and it feels
(to me) weird.
Maybe the documentation: "NOTE: AEL wraps the right hand side of an assignment
with $[ ] to allow expressions to be used If this is unwanted, you can protect
the right hand side from being wrapped by using the Set() application." could
be enhanced to point out that quote marks can overcome the problem as well?
https://wiki.asterisk.org/wiki/display/AST/AEL+Variables
Antony.
--
"640 kilobytes (of RAM) should be enough for anybody."
- Bill Gates
Please reply to the list;
please *don't* CC me.
More information about the asterisk-users
mailing list