Still Trying to set a Variable

I need to set a variable when a users context is entered from sip.conf, and use it later on in ANOTHER context. How can I do this? I’ve been searching for several days now with no answer. Seems like a pretty serious limitation of Asterisk.

It would be nice if matching a dialed number didn’t cause execution to stop, for example:

[c_user1]
exten => _X.,SetVar(FOO=1)

It would be AWESOME if after doing that, execution where to continue, and later on I could use the variable FOO. Why doesn’t Asterisk allow this?

Why doesn’t this work???

[c_user1]
FOO=1
include => local

[local]
exten => _X.,1,NoOp(${FOO})

Foo should equal 1 but it’s empty!!!

doug,

have you looked at a working example yet ? there are hundreds to be had, either by googlin’, or by installing/untar’ing samples and pre-built configs from other places.

i have a context that runs my dial-out via asstd trunks. it started off as A@H, but has been tweaked by me to do more. or are you against that kind of thing ?

why make things harder for yourself, when a few minutes reading of something that already works is going to make things easier ? i’ve suggested it on a number of your threads, but you don’t seem to have moved on at all.

and before you ask, yes, they have includes to other contexts, and yes, they work, and yes, they set variables, and yes, it’s customisable.

As I stated in other posts, more information is needed from you before we may assess your issue. If you refuse to provide the additional information, than you will only be left to struggle through the issues on your own.

Asterisk works fine for 1000s and 1000s of users.

Good luck!

MuppetMaster, why do you need to know what I’m trying to do? I’ve tried to explain it before and it just confused people. My question is quite simple and quite straight forward. I want to set a variable in one context and use it in another.

Now, I’m having another problem. I’m trying to set the caller id of a call with AGI. The caller id needs to be in the format:

“Name”

However, when you try and set a variable through AGI with:

SET VARIABLE variable name

the quotes around the name are confusing the set variable command. It stops after the quotes, thinking that is the end of the variable. It ends up setting the variable to “Name” only.

BaconButtie: No I haven’t looked at a working example yet, because I can’t find any. Asterisk docs are thin and far between.

Yeah, don’t be so nosy MuppetMaster! Just answer the bloody question can’t you? You can see the customer is sick of waiting around while you ask silly questions. He’s a busy man and has got more important things to do than engage in idle chitchat!

:wink:

Perhaps I can help…

I think the command you want to use is SetGlobalVar()

voip-info.org/wiki/index.php … tGlobalVar

You’ll want to reset the variable anytime you’re finished using it if you plan to re-use the same code to do something. (Like dialing calls or whatever.) That way if you don’t have a specific “something” for that variable this time around, it doesn’t default to the setting that was last used.

i’ve just looked through my various extension conf files … loads of examples of what doug wants to do. or at least, what i think he wants to do, 'cos he’s being a bit secretive.

doug, ffs, send me what you have, what you want to do with it, and i’ll send you back some code to do it, and include the blocklist thing you were harping on about the other night (which i actually quite like, i can set an incoming callerid and give them congestion :smiley:).

i think we established you’re already too far for me to come visit !!

did you install HEAD yet ?

am i setting myself up for a flame here now like the guys at digium ??

Dufus, SetGlobalVar() does not help.

The SetGlobalVar() command can only be executed when a dialed number is matched in the dial plan. I want to set the variable BEFORE a dialed number is matched, so that later on when it DOES match, I can use the variable.

Why can’t asterisk have some sort of setup extension, where, when a context is entered, it issues these commands first? That would be soooo helpful.