[Freeswitch-users] lua script

Muhammad Shahzad shaheryarkh at gmail.com
Mon Nov 26 22:33:19 MSK 2012


classical variable scope problem. :-)

http://lua-users.org/wiki/ScopeTutorial

Basically, you should declare variable above and outside IF condition and
initialize it say 'nil', then change its value in IF per logic, finally
outside below IF block check if variable value is other then 'nil', if so
then do your operation. This is very basic programming man!

Thank you.


On Mon, Nov 26, 2012 at 5:29 PM, Archana Venugopan
<a.venugopan at mundio.com>wrote:

>  Hi,****
>
> ** **
>
> Does anyone know how can we use a variable declared inside if statement
> outside if block?****
>
> ** **
>
> if sip_request_user == nil then****
>
> sip_request_user =  params:getHeader("sip_request_user")****
>
> else****
>
> local sip_request_user1 = tonumber(sip_request_user)****
>
> end****
>
> ** **
>
> In my lua I have something like above and I want to use the variable
> sip_request_user1 outside if. What can be done?****
>
> ** **
>
> Regards,****
>
> Archana****
>
> ** **
>
> _________________________________________________________________________
> Professional FreeSWITCH Consulting Services:
> consulting at freeswitch.org
> http://www.freeswitchsolutions.com
>
> 
> 
>
> Official FreeSWITCH Sites
> http://www.freeswitch.org
> http://wiki.freeswitch.org
> http://www.cluecon.com
>
> FreeSWITCH-users mailing list
> FreeSWITCH-users at lists.freeswitch.org
> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
> UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
> http://www.freeswitch.org
>
>


-- 
Muhammad Shahzad
-----------------------------------
CISCO Rich Media Communication Specialist (CRMCS)
CISCO Certified Network Associate (CCNA)
Cell: +49 176 99 83 10 85
MSN: shari_786pk at hotmail.com
Email: shaheryarkh at googlemail.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freeswitch.org/pipermail/freeswitch-users/attachments/20121126/b160f2c8/attachment.html 


Join us at ClueCon 2011 Aug 9-11, 2011
More information about the FreeSWITCH-users mailing list