Variable manipulation in the dialplan
Hello, I once found in the wiki a page explaining how to "substring" a channel variable, something like <@[intra]lanman> 12345 would be 345 if you do ${var:2} I can't find that page on the wiki anymore, any hint on were it could be? :-) Also do you think it could be useful to extend this functionality with a sort of Java indexOf() to extract a specific substring from a variable (but without knowing its size like in the example above)? Regards, Claudio Internet Email Confidentiality Footer ----------------------------------------------------------------------------------------------------- La presente comunicazione, con le informazioni in essa contenute e ogni documento o file allegato, e' rivolta unicamente alla/e persona/e cui e' indirizzata ed alle altre da questa autorizzata/e a riceverla. Se non siete i destinatari/autorizzati siete avvisati che qualsiasi azione, copia, comunicazione, divulgazione o simili basate sul contenuto di tali informazioni e' vietata e potrebbe essere contro la legge (art. 616 C.P., D.Lgs n. 196/2003 Codice in materia di protezione dei dati personali). Se avete ricevuto questa comunicazione per errore, vi preghiamo di darne immediata notizia al mittente e di distruggere il messaggio originale e ogni file allegato senza farne copia alcuna o riprodurne in alcun modo il contenuto. This e-mail and its attachments are intended for the addressee(s) only and are confidential and/or may contain legally privileged information. If you have received this message by mistake or are not one of the addressees above, you may take no action based on it, and you may not copy or show it to anyone; please reply to this e-mail and point out the error which has occurred. -----------------------------------------------------------------------------------------------------
play with it from the cli freeswitch>global_setvar foo=12345 API CALL [global_setvar(foo=12345)] output: +OK freeswitch> eval ${foo:2:1} API CALL [eval(${foo:2:1})] output: 3 freeswitch> eval ${foo:2:3} API CALL [eval(${foo:2:3})] output: 345 freeswitch> eval ${foo:3:2} API CALL [eval(${foo:3:2})] output: 45 freeswitch> eval ${foo:-4:4} API CALL [eval(${foo:-4:4})] output: 2345 On Tue, Jun 23, 2009 at 8:33 AM, Cavalera Claudio Luigi < Claudio.Cavalera@italtel.it> wrote:
Hello, I once found in the wiki a page explaining how to "substring" a channel variable, something like <@[intra]lanman> 12345 would be 345 if you do ${var:2}
I can't find that page on the wiki anymore, any hint on were it could be? :-)
Also do you think it could be useful to extend this functionality with a sort of Java indexOf() to extract a specific substring from a variable (but without knowing its size like in the example above)?
Regards, Claudio
Internet Email Confidentiality Footer
----------------------------------------------------------------------------------------------------- La presente comunicazione, con le informazioni in essa contenute e ogni documento o file allegato, e' rivolta unicamente alla/e persona/e cui e' indirizzata ed alle altre da questa autorizzata/e a riceverla. Se non siete i destinatari/autorizzati siete avvisati che qualsiasi azione, copia, comunicazione, divulgazione o simili basate sul contenuto di tali informazioni e' vietata e potrebbe essere contro la legge (art. 616 C.P., D.Lgs n. 196/2003 Codice in materia di protezione dei dati personali). Se avete ricevuto questa comunicazione per errore, vi preghiamo di darne immediata notizia al mittente e di distruggere il messaggio originale e ogni file allegato senza farne copia alcuna o riprodurne in alcun modo il contenuto.
This e-mail and its attachments are intended for the addressee(s) only and are confidential and/or may contain legally privileged information. If you have received this message by mistake or are not one of the addressees above, you may take no action based on it, and you may not copy or show it to anyone; please reply to this e-mail and point out the error which has occurred.
-----------------------------------------------------------------------------------------------------
_______________________________________________ Freeswitch-users mailing list Freeswitch-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
-- Anthony Minessale II FreeSWITCH http://www.freeswitch.org/ ClueCon http://www.cluecon.com/ AIM: anthm MSN:anthony_minessale@hotmail.com <MSN%3Aanthony_minessale@hotmail.com> GTALK/JABBER/PAYPAL:anthony.minessale@gmail.com<PAYPAL%3Aanthony.minessale@gmail.com> IRC: irc.freenode.net #freeswitch FreeSWITCH Developer Conference sip:888@conference.freeswitch.org <sip%3A888@conference.freeswitch.org> iax:guest@conference.freeswitch.org/888 googletalk:conf+888@conference.freeswitch.org<googletalk%3Aconf%2B888@conference.freeswitch.org> pstn:213-799-1400
From: freeswitch-users-bounces@lists.freeswitch.org [mailto:freeswitch-users-bounces@lists.freeswitch.org] On Behalf Of Anthony Minessale
play with it from the cli
freeswitch> eval ${foo:-4:4} API CALL [eval(${foo:-4:4})] output: 2345
Thanks anthm! This way to test directly on the cli is really nice, I didn't know of it. If I've understood well, a negative number as first parameter will make the second parameter useless/meaningless. Besides, the second parameter is useless/meaningless if set equal to 0 or lesser than 0. I still think that we could benefit from more power here in the dialplan, if I have 12346578@domain.org I'm not able to grab out the number (of which I don't know the length) even if I know that domain.org is always the same length. I've looked for something useful in http://apr.apache.org/docs/apr/1.3/apr__strings_8h.html and switch_apr.c but I think I'll end up calling an external script. :) Best Regars, Claudio Internet Email Confidentiality Footer ----------------------------------------------------------------------------------------------------- La presente comunicazione, con le informazioni in essa contenute e ogni documento o file allegato, e' rivolta unicamente alla/e persona/e cui e' indirizzata ed alle altre da questa autorizzata/e a riceverla. Se non siete i destinatari/autorizzati siete avvisati che qualsiasi azione, copia, comunicazione, divulgazione o simili basate sul contenuto di tali informazioni e' vietata e potrebbe essere contro la legge (art. 616 C.P., D.Lgs n. 196/2003 Codice in materia di protezione dei dati personali). Se avete ricevuto questa comunicazione per errore, vi preghiamo di darne immediata notizia al mittente e di distruggere il messaggio originale e ogni file allegato senza farne copia alcuna o riprodurne in alcun modo il contenuto. This e-mail and its attachments are intended for the addressee(s) only and are confidential and/or may contain legally privileged information. If you have received this message by mistake or are not one of the addressees above, you may take no action based on it, and you may not copy or show it to anyone; please reply to this e-mail and point out the error which has occurred. -----------------------------------------------------------------------------------------------------
Can we also test dialplan using CLI, like "dial" in asterisk? -----Original Message----- From: freeswitch-users-bounces@lists.freeswitch.org [mailto:freeswitch-users-bounces@lists.freeswitch.org] On Behalf Of Cavalera Claudio Luigi Sent: Wednesday, June 24, 2009 12:36 PM To: freeswitch-users@lists.freeswitch.org Subject: Re: [Freeswitch-users] Variable manipulation in the dialplan
From: freeswitch-users-bounces@lists.freeswitch.org [mailto:freeswitch-users-bounces@lists.freeswitch.org] On Behalf Of Anthony Minessale
play with it from the cli
freeswitch> eval ${foo:-4:4} API CALL [eval(${foo:-4:4})] output: 2345
Thanks anthm! This way to test directly on the cli is really nice, I didn't know of it. If I've understood well, a negative number as first parameter will make the second parameter useless/meaningless. Besides, the second parameter is useless/meaningless if set equal to 0 or lesser than 0. I still think that we could benefit from more power here in the dialplan, if I have 12346578@domain.org I'm not able to grab out the number (of which I don't know the length) even if I know that domain.org is always the same length. I've looked for something useful in http://apr.apache.org/docs/apr/1.3/apr__strings_8h.html and switch_apr.c but I think I'll end up calling an external script. :) Best Regars, Claudio Internet Email Confidentiality Footer ---------------------------------------------------------------------------- ------------------------- La presente comunicazione, con le informazioni in essa contenute e ogni documento o file allegato, e' rivolta unicamente alla/e persona/e cui e' indirizzata ed alle altre da questa autorizzata/e a riceverla. Se non siete i destinatari/autorizzati siete avvisati che qualsiasi azione, copia, comunicazione, divulgazione o simili basate sul contenuto di tali informazioni e' vietata e potrebbe essere contro la legge (art. 616 C.P., D.Lgs n. 196/2003 Codice in materia di protezione dei dati personali). Se avete ricevuto questa comunicazione per errore, vi preghiamo di darne immediata notizia al mittente e di distruggere il messaggio originale e ogni file allegato senza farne copia alcuna o riprodurne in alcun modo il contenuto. This e-mail and its attachments are intended for the addressee(s) only and are confidential and/or may contain legally privileged information. If you have received this message by mistake or are not one of the addressees above, you may take no action based on it, and you may not copy or show it to anyone; please reply to this e-mail and point out the error which has occurred. ---------------------------------------------------------------------------- ------------------------- _______________________________________________ Freeswitch-users mailing list Freeswitch-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
participants (4)
-
Anthony Minessale
-
Cavalera Claudio Luigi
-
Jason White
-
Saeed Ahmed