Sponsor: VoiceMeUp - Corporate & Wholesale VoIP Services

VoIP Mailing List Archives
Mailing list archives for the VoIP community
 SearchSearch 

[asterisk-users] Logical AND


 
Post new topic   Reply to topic    VoIP Mailing List Archives Forum Index -> Asterisk Users
View previous topic :: View next topic  
Author Message
sst at sil.at
Guest





PostPosted: Sun May 25, 2008 6:33 am    Post subject: [asterisk-users] Logical AND Reply with quote

Adrian Marsh schrieb:
Quote:
Hi All,

I'm trying to figure out why in the below code, the PSTN_NUM variable is
always amended

exten => s,n,NoOp(${PSTN_NUM})
exten => s,n,ExecIf( $[ "${PSTN_NUM:0:1}" != "0" ] & $[
${LEN(${PSTN_NUM})} = 10 ]|Set|PSTN_NUM=001${PSTN_NUM})
exten => s,n,NoOp(${PSTN_NUM})

-- Executing [s at macro-setpstncli:8] NoOp("SIP/427-b7d0f518",
"0123456789") in new stack
-- Executing [s at macro-setpstncli:9] ExecIf("SIP/427-b7d0f518", " 0 &
1|Set|PSTN_NUM=0010123456789") in new stack
-- Executing [s at macro-setpstncli:10] NoOp("SIP/427-b7d0f518",
"0010123456789") in new stack

It should evaluate PSTN_NUM and add a 001 only if: PSTN_NUM is 10 digits
long and doesn't start with a 0.

However, from the debug it's being changed, even though the first test
operator logically is 0. If seems as though the "&" isnt being applied.

Any ideas?

Thanks

Adrian

hello,

you should try this:

exten => s,n,ExecIf($[ $[ "${PSTN_NUM:0:1}" != "0" ] & $[
${LEN(${PSTN_NUM})} = 10 ]]|Set|PSTN_NUM=001${PSTN_NUM})

cause the AND Operator is another thing to work, so the result at your
way look like this ExecIf(1&1 | ...) and with my way it looks like this
ExecIf($[1&1]|...) which is the right syntax for it.

best regards

steve smith
Back to top
Adrian.Marsh at ubiqui...
Guest





PostPosted: Sun May 25, 2008 7:10 am    Post subject: [asterisk-users] Logical AND Reply with quote

Hi Steve,

I can see what yours does, but I still get the same end result (even
though theres only a single "0" result now)

:
exten => s,n,ExecIf( $[ $[ "${PSTN_NUM:0:1}" != "0" ] & $[
${LEN(${PSTN_NUM})} = 10 ] ] |Set|PSTN_NUM=001${PSTN_NUM})


-- Executing [s at macro-setpstncli:8] NoOp("SIP/427-b7d9a9a0",
"0123456789") in new stack
-- Executing [s at macro-setpstncli:9] ExecIf("SIP/427-b7d9a9a0", " 0
|Set|PSTN_NUM=0010123456789") in new stack
-- Executing [s at macro-setpstncli:10] NoOp("SIP/427-b7d9a9a0",
"0010123456789") in new stack


---------------------------------
hello,

you should try this:

exten => s,n,ExecIf($[ $[ "${PSTN_NUM:0:1}" != "0" ] & $[
${LEN(${PSTN_NUM})} = 10 ]]|Set|PSTN_NUM=001${PSTN_NUM})

cause the AND Operator is another thing to work, so the result at your
way look like this ExecIf(1&1 | ...) and with my way it looks like this
ExecIf($[1&1]|...) which is the right syntax for it.

best regards

steve smith
Back to top
tilghman at mail.jeffa...
Guest





PostPosted: Sun May 25, 2008 9:07 am    Post subject: [asterisk-users] Logical AND Reply with quote

On Sunday 25 May 2008 07:10:22 Adrian Marsh wrote:
Quote:
exten => s,n,ExecIf( $[ $[ "${PSTN_NUM:0:1}" != "0" ] & $[
${LEN(${PSTN_NUM})} = 10 ] ] |Set|PSTN_NUM=001${PSTN_NUM})

-- Executing [s at macro-setpstncli:8] NoOp("SIP/427-b7d9a9a0",
"0123456789") in new stack
-- Executing [s at macro-setpstncli:9] ExecIf("SIP/427-b7d9a9a0", " 0
|Set|PSTN_NUM=0010123456789") in new stack
-- Executing [s at macro-setpstncli:10] NoOp("SIP/427-b7d9a9a0",
"0010123456789") in new stack

There's an extra space between the opening "(" and the opening "$[", so
the result is space-zero, which is not the same thing as zero. Any string
that is not exactly "0" (or the empty string), such as "foo", " ", or " 0" is
true.

--
Tilghman
Back to top
Adrian.Marsh at ubiqui...
Guest





PostPosted: Sun May 25, 2008 9:38 am    Post subject: [asterisk-users] Logical AND Reply with quote

From: asterisk-users-bounces at lists.digium.com
[mailto:asterisk-users-bounces at lists.digium.com] On Behalf Of Tilghman
Lesher
Sent: 25 May 2008 15:07
To: Asterisk Users Mailing List - Non-Commercial Discussion
Subject: Re: [asterisk-users] Logical AND

On Sunday 25 May 2008 07:10:22 Adrian Marsh wrote:
Quote:
exten => s,n,ExecIf( $[ $[ "${PSTN_NUM:0:1}" != "0" ] & $[
${LEN(${PSTN_NUM})} = 10 ] ] |Set|PSTN_NUM=001${PSTN_NUM})

-- Executing [s at macro-setpstncli:8] NoOp("SIP/427-b7d9a9a0",
"0123456789") in new stack
-- Executing [s at macro-setpstncli:9] ExecIf("SIP/427-b7d9a9a0", " 0
|Set|PSTN_NUM=0010123456789") in new stack
-- Executing [s at macro-setpstncli:10] NoOp("SIP/427-b7d9a9a0",
"0010123456789") in new stack

There's an extra space between the opening "(" and the opening "$[", so
the result is space-zero, which is not the same thing as zero. Any
string
that is not exactly "0" (or the empty string), such as "foo", " ", or "
0" is
true.

--
Tilghman
---------

I did wonder where the extra spaces were coming from, but I thought that
was where the quotes were supposed to come into play... Well that got
it working so thanks guys..
Back to top
tilghman at mail.jeffa...
Guest





PostPosted: Sun May 25, 2008 11:23 am    Post subject: [asterisk-users] Logical AND Reply with quote

On Sunday 25 May 2008 09:38:28 Adrian Marsh wrote:
Quote:
I did wonder where the extra spaces were coming from, but I thought that
was where the quotes were supposed to come into play... Well that got
it working so thanks guys..

The quotes generally aren't supposed to take care of spaces; they are
generally used so that variables which are unset do not create an invalid
expression, i.e. $["" != "foo"] is valid, but $[ != foo] is not.

--
Tilghman
Back to top
Display posts from previous:   
Post new topic   Reply to topic    VoIP Mailing List Archives Forum Index -> Asterisk Users All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group

VoiceMeUp - Corporate & Wholesale VoIP Services