Get var from Asterisk

Sep 19, 2013 at 4:38 PM
Hi. it's possible to get a var used in extensions.conf? or are there any way to make something like?

Thanks
Coordinator
Sep 19, 2013 at 7:20 PM
Yes, use
var x = GetVariable(var_name)
It will return variables from the dialplan.
Sep 22, 2013 at 2:58 PM
Hi skrusty... Thanks for answerd to me..

Ok, I'll try it... One thing.. Do you know if it's possible use your library with windows xp?
I'm using with windows 7, but for now, in windows xp, I'm using Asterisk.NET library...
It's possible?

Thnaks
Coordinator
Sep 22, 2013 at 6:04 PM
You may need to download the source, and compile against .NET 3.5, as I am unsure if the current target (4) is compatible with Windows XP.
Sep 22, 2013 at 6:40 PM
Hi... ok, I thought that you use .NET 4.5 (not compatible with XP)...

One question.. I wanted to use the var to differentiate between normal incoming calls (SIP/10 for example), and queue incoming calls (Local/10), you know?

Do you know if there are any way, any event to differentiate it?

I thought that use it:

exten => s,1,Set(MyVar=1)
exten => s,n,Queue(example)
exten => s,n,HangUp()

I could differentiate, but when I consult (Getvariable), always I have 1....

Can you think any way to do this?

Thanks a lot!!!!1
Oct 2, 2013 at 6:08 PM
I just compiled the source against .NET 2.0 today, only had to remove some using's in a couple of files, no other issues.

Frankly I don't understand why it's announced that this project is .NET 3.5 or 4.5. Especially for a library, it's nice to keep the .NET version as low as possible, as it makes it impossible to include into projects if the framework version is higher than the projects.

cheers
Coordinator
Oct 2, 2013 at 9:25 PM
Thanks phox,

I do understand your point and it's under consideration at the moment. It's the state it was in when I inherited it. assuming it causes no issues (i don't think it will) I am to do this soon.
Oct 7, 2013 at 2:08 PM
Ok, thanks for all.... Finally I fix it using New_state_event and dialevent..

Thanks for all!!
Nov 18, 2013 at 1:19 PM
Skrusty,

I created the thread with the similar question. I'm still having difficulties with the following piece of code:
var x = GetVariable(var_name)
what context it should be used in?

For example, the code below:
 private void dialButton_Click(object sender, EventArgs e)
        {

            var x = GetVariable("${EXTEN}");

        }
produces the following error:

The name 'GetVariable' does not exist in the current context.
Coordinator
Nov 18, 2013 at 6:04 PM
Hi,

GetVarialbe is a method for AGIScript, not AMI (Asterisk Manager Interface).

GetVariable returns variables that are in the current scope of a call, like 'DIAL_STATUS' etc.

If you want to get a Variable from the AMI, you need to call the GetVar Action.

When a variable is set, there's an event you can listen to in AMI called 'VarSetEvent'.

Hope this helps.
Nov 18, 2013 at 6:30 PM
Thank you, Skrusty!

Would you be so kind and give an example of the code? I'm trying to implement that simple functionality which I described in the other thread but can not figure out how to use C# with both framework and AGI.