{"id":3148,"date":"2014-04-11T18:48:41","date_gmt":"2014-04-11T09:48:41","guid":{"rendered":"http:\/\/pchero21.com\/?p=3148"},"modified":"2014-04-11T18:48:41","modified_gmt":"2014-04-11T09:48:41","slug":"asterisk-variables-in-asterisk","status":"publish","type":"post","link":"http:\/\/pchero21.com\/?p=3148","title":{"rendered":"[Asterisk] Variables in Asterisk"},"content":{"rendered":"<h1><strong>Using Variables in Asterisk Dialplans<\/strong><\/h1>\n<p>Asterisk \uc5d0\uc11c Dialplan \uc791\uc131\uc2dc, \ub0b4\ubd80 \ubcc0\uc218\ub97c \ubaa9\uc801\uc5d0 \ub530\ub77c Global, Shared, Chanel-specific \ubcc0\uc218\ub85c \uad6c\ubd84\ud574\uc11c \uc0ac\uc6a9\ud560 \uc218 \uc788\ub2e4.<br \/>\n\uacf5\ud1b5\uc801\uc73c\ub85c \ubcc0\uc218\ub97c \uc0ac\uc6a9\ud560 \ub54c \ub2e4\uc74c\uacfc \uac19\uc740 \ubc29\uc2dd\uc73c\ub85c \uc0ac\uc6a9\ud560 \uc218 \uc788\ub2e4.<\/p>\n<blockquote><p>${foo:offset:length}<\/p><\/blockquote>\n<p>foo \ub294 \ubcc0\uc218\uc758 \uc774\ub984\uc774\uace0, offset \uc740 \ubcc0\uc218\uc758 \ub0b4\uc6a9 \uc911 \ucc38\uc870\ud558\uace0\uc790 \ud558\ub294 \uc2dc\uc791 \uc704\uce58, length \ub294 offset \uc73c\ub85c\ubd80\ud130 \ucc38\uc870\ud558\uace0\uc790 \ud558\ub294 \ubcc0\uc218 \ub0b4\uc6a9\uc758 \uae38\uc774\uc774\ub2e4.<\/p>\n<p>\ubcc0\uc218 \uc774\ub984 \uc791\uc131\uc2dc, \uc0ac\uc6a9\uc790 \uc9c0\uc815 \ubcc0\uc218(User-defined value)\ub294 \ub300\/\uc18c\ubb38\uc790 \uc0c1\uad00 \uc5c6\uc774 \ucc38\uc870\uac00 \uac00\ub2a5\ud558\ub098, Asterisk \uc5d0\uc11c \uc9c0\uc815\ud558\uc5ec \uc0ac\uc6a9\ud558\ub294 \ubcc0\uc218(ex. ${EXTEN}) \uac19\uc740 \uacbd\uc6b0\ub294 \ub300\/\uc18c\ubb38\uc790\ub97c \uad6c\ubd84\ud55c\ub2e4.<\/p>\n<p>\ud06c\uac8c 4\uac00\uc9c0 \ud0c0\uc785\uc758 \ubcc0\uc218(Global, Shared, Channel, Environment)\uac00 \uc788\ub294\ub370, \uac01\uac01\uc758 \uc758\ubbf8\ub294 \ub2e4\uc74c\uacfc \uac19\ub2e4.<\/p>\n<blockquote><p><strong>Global :<\/strong> [globals] \uc139\uc158\uc5d0\uc11c \uc124\uc815\ud558\uac70\ub098 SetGlobalVal \uba85\ub839\uc73c\ub85c \uc124\uc815\ub41c \ubcc0\uc218. \ud55c\ubc88 \uc124\uc815\ud558\uba74 \uc5b8\uc81c\/\uc5b4\ub514\uc11c \ub4e0\uc9c0 \ud638\ucd9c\ud558\uc5ec \ucc38\uc870\uac00 \uac00\ub2a5\ud558\ub2e4.<br \/>\n<strong>Shared :<\/strong> Variables are new in Asterisk 1.6(however a backport is available for 1.4). Two (or more?) channels can gain full access with the help of Asterisk func SHARED to what otherwise would be a channel variable.<br \/>\n<strong>Channel :<\/strong> \ud2b9\uc815 Call \uc5d0 \uc5f0\ub3d9\ub418\uc5b4 \uc0ac\uc6a9\uac00\ub2a5\ud55c \ubcc0\uc218. Global \ud0c0\uc785\uacfc\ub294 \ub2ec\ub9ac Call(Channel)\uc5d0\uc11c\ub9cc \uc0ac\uc6a9 \uac00\ub2a5\ud558\ub2e4. \uc989, Call(Channel) \uc885\ub8cc\uc2dc, \ud574\ub2f9 \ubcc0\uc218\ub294 \ubaa8\ub450 \uc0ad\uc81c\ub41c\ub2e4.<br \/>\n<strong>Environment :<\/strong> Unix \ud658\uacbd \ubcc0\uc218. Dialplan \ub0b4\uc5d0\uc11c ENV() \ud568\uc218\ub85c \uc0ac\uc6a9\uac00\ub2a5\ud558\ub2e4. ${ENV(var)} var \uc5d0\ub294 \ucc38\uc870\ud558\uace0\uc790\ud558\ub294 Unix \ud658\uacbd\ubcc0\uc218 \uc774\ub984\uc744 \uc785\ub825\ud558\uba74 \ub41c\ub2e4.<\/p><\/blockquote>\n<p>\ub9cc\uc57d, Channel \ubcc0\uc218\ub97c \uc124\uc815\ud560 \ub54c, Global \ubcc0\uc218\uc5d0 \uc124\uc815\ub418\uc5b4 \uc788\ub294 \ubcc0\uc218\uc640 \ub611\uac19\uc740 \uc774\ub984\uc73c\ub85c \uc124\uc815\ud558\uac8c \ub41c\ub2e4\uba74 Channel \ubcc0\uc218\ub97c \ucc38\uc870\ud558\uac8c \ub41c\ub2e4.<\/p>\n<pre class=\"brush:shell\">[FooTest]\nexten =&gt; 100,1,SetGlobalVar(FOO=5)\nexten =&gt; 100,2,NoOp(${FOO})\nexten =&gt; 100,3,NoOp(${foo})\nexten =&gt; 100,4,Set(foo=8)\nexten =&gt; 100,5,NoOp(${FOO})\nexten =&gt; 100,6,NoOp(${foo})\n\n\u2014 Executing SetGlobalVar(\"Zap\/1-1\", \"FOO=5\") in new stack\n\u2014 Setting global variable 'FOO' to '5'\n\u2014 Executing NoOp(\"Zap\/1-1\", \"5\") in new stack\n\u2014 Executing NoOp(\"Zap\/1-1\", \"5\") in new stack\n\u2014 Executing Set(\"Zap\/1-1\", \"foo=8\") in new stack\n\u2014 Executing NoOp(\"Zap\/1-1\", \"8\") in new stack\n\u2014 Executing NoOp(\"Zap\/1-1\", \"8\") in new stack<\/pre>\n<p>Global \ubcc0\uc218 \uc124\uc815 \uc9c1\ud6c4 ${FOO} \uc758 \uac12\uc744 \ud655\uc778\ud574\ubcf4\uba74 &#8220;5&#8221; \ub85c \ub098\uc624\ub294 \uac83\uc744 \ud655\uc778\ud560 \uc218 \uc788\ub2e4. \ud558\uc9c0\ub9cc Channel \ubcc0\uc218\ub85c \uc124\uc815 \ud6c4, ${FOO} \uac12\uc744 \ud655\uc778\ud574\ubcf4\uba74 \ubaa8\ub450 &#8220;8&#8221;\ub85c \ud45c\uc2dc\ub418\ub294 \uac83\uc744 \uc54c \uc218 \uc788\ub2e4.<\/p>\n<h1><strong>Inheritance of Channel Variables<\/strong><\/h1>\n<p>\ubcc0\uc218 \uc120\uc5b8\uc2dc, _(underscore)\ub97c \ubd99\uc774\uac8c \ub418\uba74 \uc774\ub294 Inheritance of Channel Variable \uc784\uc744 \uc120\uc5b8\ud558\ub294 \uac83\uc774\ub2e4. \uadf8\ub7f0\ub370 \uc774 &#8216;_'(underscore) \ub97c \ud558\ub098\ub97c \ubd99\uc774\ub290\ub0d0, \ub450\uac1c\ub97c \ubd99\uc774\ub290\ub0d0\uc5d0 \ub530\ub77c \ubcc0\uc218\uac00 \uc0c1\uc18d\ub418\ub294 \ubc94\uc704\uac00 \ub2ec\ub77c\uc9c4\ub2e4.<br \/>\n\ud558\ub098\ub97c \ubd99\uc774\uba74 \ud55c\ubc88\ub9cc \uc0c1\uc18d\ub418\uace0, \ub450\uac1c\ub97c \ubd99\uc774\uac8c \ub418\uba74 \uacc4\uc18d\ud574\uc11c \uc0c1\uc18d\ub41c\ub2e4.<\/p>\n<pre class=\"brush:shell\">exten =&gt; 104,1,Set(FEE=fee)\nexten =&gt; 104,2,Set(_FIE=fie)\nexten =&gt; 104,3,Set(__FUM=fum)\nexten =&gt; 104,4,Dial(Local\/105)\n\nexten =&gt; 105,1,NoOp(${FEE})\nexten =&gt; 105,2,NoOp(${FIE})\nexten =&gt; 105,3,NoOp(${FUM})\nexten =&gt; 105,4,Dial(Local\/106)\n\nexten =&gt; 106,1,NoOp(${FEE})\nexten =&gt; 106,2,NoOp(${FIE})\nexten =&gt; 106,2,NoOp(${FUM})\n\nresults in\n\n\u2014 Executing Set(\"SIP\/oberon-365e\", \"FEE=fee\") in new stack\n\u2014 Executing Set(\"SIP\/oberon-365e\", \"_FIE=fie\") in new stack\n\u2014 Executing Set(\"SIP\/oberon-365e\", \"__FUM=fum\") in new stack\n\u2014 Executing Dial(\"SIP\/oberon-365e\", \"Local\/105\") in new stack\n\u2014 Called 105\n\u2014 Executing NoOp(\"Local\/105@default-7263,2\", \"\") in new stack\n\u2014 Executing NoOp(\"Local\/105@default-7263,2\", \"fie\") in new stack\n\u2014 Executing NoOp(\"Local\/105@default-7263,2\", \"fum\") in new stack\n\u2014 Executing Dial(\"Local\/105@default-7263,2\", \"Local\/106\") in new stack\n\u2014 Called 106\n\u2014 Executing NoOp(\"Local\/106@default-49be,2\", \"\") in new stack\n\u2014 Executing NoOp(\"Local\/106@default-49be,2\", \"\") in new stack\n\u2014 Executing NoOp(\"Local\/106@default-49be,2\", \"fum\") in new stack<\/pre>\n<p><strong>Using $<\/strong><\/p>\n<p>If you want to set a global variable containing the another variable name in the [globals] category of extensions.conf you have to do something like this:<\/p>\n<pre class=\"brush:shell\">[globals]\nSS=$\nMY_VAR=${SS}{EPOCH}-${SS}{EXTEN}.gsm<\/pre>\n<p>This way the MY_VAR value is ${EPOCH}-${EXTEN}.gsmUsing it with the EVAL() function is very useful. I.e. If you want to record you can do this:<\/p>\n<pre class=\"brush:shell\">exten =&gt; 104,1,Set(filename=${EVAL(${MYVAR}){)\nexten =&gt; 104,2,MixMonitor(${filename})<\/pre>\n<h1><strong>Predefined Channel Variables<\/strong><\/h1>\n<ul>\n<li><strong>${ACCOUNTCODE}<\/strong>: Account code, if specified &#8211; see <a title=\"Asterisk billing\" href=\"http:\/\/www.voip-info.org\/wiki\/view\/Asterisk+billing\">Asterisk billing<\/a> (DEPRECATED in 1.2.0 and removed in 1.4. Use ${CDR(accountcode)}<\/li>\n<li><strong>${ANSWEREDTIME}<\/strong>: This is the amount of time(in seconds) for actual call.<\/li>\n<li><strong>${BLINDTRANSFER}<\/strong>: The active SIP channel that dialed the number. This will return the SIP Channel that dialed the number when doing blind transfers &#8211; see <a title=\"BLINDTRANSFER\" href=\"http:\/\/www.voip-info.org\/wiki\/view\/BLINDTRANSFER\">BLINDTRANSFER<\/a><\/li>\n<li><strong>${CALLERID(all)}<\/strong>: The current Caller ID name and number &#8211; See <a title=\"Setting Callerid\" href=\"http:\/\/www.voip-info.org\/wiki\/view\/Setting+Callerid\">Setting Callerid<\/a> for usage in Asterisk 1.4<\/li>\n<li><strong>${CALLERID(name)}<\/strong>: The current Caller ID name &#8211; <strong>${CALLERIDNAME}<\/strong> was used in versions of Asterisk prior to 1.2.0, it was DEPRECATED in 1.2.0 and removed in 1.4.<\/li>\n<li><strong>${CALLERID(num)}<\/strong>: The current Caller ID number &#8211; <strong>${CALLERIDNUM}<\/strong> was used in versions of Asterisk prior to 1.2.0, it was DEPRECATED in 1.2.0 and removed in 1.4.<\/li>\n<\/ul>\n<p>(Note: this is not necessarily numeric as the name would indicate and can legitimately contain the space character. Commands acting on this variable (such as &#8216;GotoIf&#8217;, for example) should be aware of this).<\/p>\n<ul>\n<li><strong>${CALLINGPRES}<\/strong>: PRI Call ID Presentation variable for incoming calls (See <a title=\"Asterisk cmd CallingPres\" href=\"http:\/\/www.voip-info.org\/wiki\/view\/Asterisk+cmd+CallingPres\">callingpres<\/a> )<\/li>\n<li><strong>${CHANNEL}<\/strong>: Current channel name<\/li>\n<li><strong>${CONTEXT}<\/strong>: The name of the current context<\/li>\n<li><strong>${DATETIME}<\/strong>: Current date time in the format: DDMMYYYY-HH:MM:SS <strong>This is deprecated in Asterisk 1.2<\/strong>, instead use :${STRFTIME(${EPOCH},,%d%m%Y-%H:%M:%S)})<\/li>\n<li><strong>${DIALEDPEERNAME}<\/strong>: Name of the called party. Broken for now, see <a title=\"DIALEDPEERNAME\" href=\"http:\/\/www.voip-info.org\/wiki\/view\/DIALEDPEERNAME\">DIALEDPEERNAME<\/a><\/li>\n<li><strong>${DIALEDPEERNUMBER}<\/strong>: Number of the called party. Broken for now, see <a title=\"DIALEDPEERNUMBER\" href=\"http:\/\/www.voip-info.org\/wiki\/view\/DIALEDPEERNUMBER\">DIALEDPEERNUMBER<\/a><\/li>\n<li><strong>${DIALEDTIME}<\/strong>: Time since the number was dialed (only works when dialed party answers the line?!)<\/li>\n<li><strong>${DIALSTATUS}<\/strong>: Status of the call. See <a title=\"DIALSTATUS\" href=\"http:\/\/www.voip-info.org\/wiki\/view\/DIALSTATUS\">DIALSTATUS<\/a> (note: In the current SVN release, DIALSTATUS seems to have been removed. Now you should use the DEVSTATE function. Try in astersisk console &#8220;core show function DEVSTATE&#8221; for more informations)<\/li>\n<li><strong>${DNID}<\/strong>: Dialed Number Identifier. Limitations apply, see <a title=\"DNID\" href=\"http:\/\/www.voip-info.org\/wiki\/view\/DNID\">DNID<\/a><\/li>\n<li><strong>${EPOCH}<\/strong>: The current UNIX-style epoch (number of seconds since 1 Jan 1970)<\/li>\n<li><strong>${EXTEN}<\/strong>: The current extension &#8211; cannot be modified with the set command- just use the GoTo to change the EXTEN variable!<\/li>\n<li><strong>${<a title=\"Asterisk variable hangupcause\" href=\"http:\/\/www.voip-info.org\/wiki\/view\/Asterisk+variable+hangupcause\">HANGUPCAUSE<\/a>}<\/strong>: The last hangup return code on a Zap channel connected to a PRI interface<\/li>\n<li><strong>${INVALID_EXTEN}<\/strong>: The extension asked for when redirected to the <a title=\"Asterisk i extension\" href=\"http:\/\/www.voip-info.org\/wiki\/view\/Asterisk+i+extension\">i<\/a> (invalid) extension<\/li>\n<li><strong>${LANGUAGE}<\/strong>: The current language setting. See <a title=\"Asterisk multi-language\" href=\"http:\/\/www.voip-info.org\/wiki\/view\/Asterisk+multi-language\">Asterisk multi-language<\/a><\/li>\n<li><strong>${MEETMESECS}<\/strong>: Number of seconds a user participated in a MeetMe conference<\/li>\n<li><strong>${PRIORITY}<\/strong>: The current priority<\/li>\n<li><strong>${RDNIS}<\/strong>: The current redirecting <a title=\"DNIS\" href=\"http:\/\/www.voip-info.org\/wiki\/view\/DNIS\">DNIS<\/a>, Caller ID that redirected the call. Limitations apply, see <a title=\"RDNIS\" href=\"http:\/\/www.voip-info.org\/wiki\/view\/RDNIS\">RDNIS<\/a><\/li>\n<li><strong>${SIPDOMAIN}<\/strong>: SIP destination domain of an inbound call (if appropriate)<\/li>\n<li><strong>${SIP_CODEC}<\/strong>: Set the SIP codec for the inbound (=first) call leg (see channelvariables.txt or README.variables in 1.2); Asterisk 1.6.2 also comes with <a href=\"https:\/\/issues.asterisk.org\/view.php?id=13243\" target=\"_blank\" rel=\"nofollow\">SIP_CODEC_OUTBOUND<\/a> for the remote (=second) call leg.<\/li>\n<li><strong>${SIPCALLID}<\/strong>: The SIP dialog Call-ID: header<\/li>\n<li><strong>${SIPUSERAGENT}<\/strong>: The SIP user agent header<\/li>\n<li><strong>${TIMESTAMP}<\/strong>: Current date time in the format: YYYYMMDD-HHMMSS <strong>This is deprecated as of Asterisk 1.4<\/strong>, instead use :${STRFTIME(${EPOCH},,%Y%m%d-%H%M%S)})<\/li>\n<li><strong>${TRANSFERCAPABILITY}<\/strong>: Type of Channel<\/li>\n<li><strong>${TXTCIDNAME}<\/strong>: Result of application TXTCIDName (see below)<\/li>\n<li><strong>${UNIQUEID}<\/strong>: Current call unique identifier<\/li>\n<li><strong>${TOUCH_MONITOR}<\/strong>: used for &#8220;one touch record&#8221; (see features.conf, and wW dial flags). If is set on either side of the call then that var contains the app_args for app_monitor otherwise the default of WAV||m is used<\/li>\n<li><strong>${TOUCH_MONITOR_PREFIX}<\/strong>: used for &#8220;one touch record&#8221; (see features.conf, and wW dial flags). This set Prefix to ${TOUCH_MONITOR} default: auto &#8220;New in 1.8&#8221;<\/li>\n<\/ul>\n<p><strong>Application-specific variables<\/strong><\/p>\n<p>\ud2b9\uc815 Function\/Application \ub4e4\uc740 Input\/Output \uc73c\ub85c Channel \ubcc0\uc218\ub4e4\uc744 \uc774\uc6a9\ud55c \uacb0\uacfc\uac12\ub4e4\uc744 \uc81c\uacf5\ud55c\ub2e4.<\/p>\n<ul>\n<li><strong>AgentCallbackLogin<\/strong> returns <strong>${AGENTBYCALLERID_${CALLERID}}<\/strong>: The ID of the agent successfully logged on.<\/li>\n<li><strong>ChanIsAvail<\/strong> returns <strong>${AVAILCHAN}<\/strong>: The first available channel<\/li>\n<li><strong>Dial<\/strong> takes input from <strong>${VXML_URL}<\/strong>: Send XML Url to Cisco 7960 or to i6net VoiceXML browser<\/li>\n<li><strong>Dial<\/strong> takes input from <strong>${ALERT_INFO}<\/strong>: Set ring cadence or allow intercom on for various SIP phones<\/li>\n<li><strong>Dial<\/strong> returns <strong>${CAUSECODE}<\/strong>: If the dial failed, this is the errormessage<\/li>\n<li><strong>Dial<\/strong> returns <strong>${DIALSTATUS}<\/strong>: Text code returning status of last dial attempt.<\/li>\n<li><strong>Dial<\/strong> takes input from <strong>${TRANSFER_CONTEXT}<\/strong>: If this variable exists, when a #transfer is executed it goes to the selected extension on this context.<\/li>\n<li><strong>EnumLookup<\/strong> returns <strong>${ENUM}<\/strong>: The result of the lookup<\/li>\n<li><strong>Hangup<\/strong> reads the <strong>${PRI_CAUSE}<\/strong> variable for setting PRI return codes<\/li>\n<li><strong>MeetMe<\/strong> takes input from <strong>{MEETME_AGI_BACKGROUND}<\/strong>: An AGI script to run<\/li>\n<li><strong>MeetMe<\/strong> returns <strong>${MEETMESECS}<\/strong>: The number of seconds the user was in a conference<\/li>\n<li><strong>Playback<\/strong> returns <strong>${PLAYBACKSTATUS}<\/strong>: The status of the command (FAILED|SUCCESS)<\/li>\n<li><strong>Queue<\/strong> returns <strong>${QUEUESTATUS}<\/strong>: The reason for popping the call out of the queue<\/li>\n<li><strong>TXTCIDName<\/strong> returns <strong>${TXTCIDNAME}<\/strong>: The result of the DNS lookup<\/li>\n<li><strong>VoiceMail<\/strong> returns <strong>${VMSTATUS}<\/strong>: indicates the status of the execution of the VoiceMail application. Possible values are: SUCCESS | USEREXIT | FAILED .<\/li>\n<\/ul>\n<p><strong>Macro-specific variables<\/strong><\/p>\n<p>Macro context \uc5d0\uc11c\ub294 \ucd94\uac00\uc801\uc778 Channel \ubcc0\uc218\ub4e4\uc774 \uc0ac\uc6a9\uac00\ub2a5\ud558\ub2e4.<\/p>\n<ul>\n<li>${ARG1}: The first argument passed to the macro<\/li>\n<li>${ARG2}: The second argument passed to the macro (<em>and so on<\/em>)<\/li>\n<li>${MACRO_CONTEXT}: The context of the extension that triggered this macro<\/li>\n<li>${MACRO_EXTEN}: The extension that triggered this macro<\/li>\n<li>${MACRO_OFFSET}: Set by a macro to influence the priority where execution will continue after exiting the macro<\/li>\n<li>${MACRO_PRIORITY}: The priority in the extension where this macro was triggered<\/li>\n<\/ul>\n<p><strong>Call files extension specific variables<\/strong><\/p>\n<ul>\n<li><strong>${REASON}<\/strong>: A number that represents the reason why an outgoing call failed. See Asterisk Reason variable.<\/li>\n<\/ul>\n<p><strong>Environment Variables<\/strong><\/p>\n<p>Unix \ud658\uacbd \ubcc0\uc218\ub4e4\ub3c4 \ucc38\uc870\uac00 \uac00\ub2a5\ud558\ub2e4.<\/p>\n<blockquote><p>${ENV(foo)}<\/p><\/blockquote>\n<ul>\n<li><strong>${ENV(ASTERISK_PROMPT)}<\/strong>: the current Asterisk CLI prompt.<\/li>\n<li><strong>${ENV(RECORDED_FILE)}<\/strong>: the filename of the last file saved by the Record command (available in CVS &gt; 2004-03-21)<\/li>\n<\/ul>\n<h1><strong>String Handling Functions<\/strong><\/h1>\n<p><strong>String Length<\/strong><\/p>\n<blockquote><p>${LEN(foo)}<\/p><\/blockquote>\n<p>foo \ubcc0\uc218\uc758 \uae38\uc774\ub97c \ub9ac\ud134\ud55c\ub2e4. \ud574\ub2f9 \ubcc0\uc218\uac00 NULL \uc778\uc9c0 \ube48 \ubb38\uc790\uc5f4\uc778\uc9c0 \ud655\uc778\ud558\ub294\ub370 \ud6a8\uacfc\uc801\uc778 \ubc29\ubc95\uc774\ub2e4.<\/p>\n<pre class=\"brush:shell\">exten =&gt; 100,1,Set(Fruit=pear)\nexten =&gt; 100,2,NoOp(${LEN(Fruit)})\nexten =&gt; 100,3,NoOp(${LEN(${Fruit})})<\/pre>\n<p>\uccab\ubc88\uc9f8 NoOp() \uacb0\uacfc\ub294 &#8220;5&#8221;\ub97c \ub9ac\ud134\ud55c\ub2e4(Fruit). \ub450\ubc88\uc9f8 NoOp() \uacb0\uacfc\ub294 &#8220;4&#8221;\ub97c \ub9ac\ud134\ud55c\ub2e4(${Fruit} == pear)<\/p>\n<p><strong>Substrings<\/strong><\/p>\n<blockquote><p>${foo:offset:length}<\/p><\/blockquote>\n<p>returns a substring of the string <em>foo<\/em>, beginning at offset <em>offset<\/em> and returning the next <em>length<\/em> characters. The first character is at offset 0.<\/p>\n<ul>\n<li>If <em>offset<\/em> is negative, it is taken leftwards from the right hand end of the string.<\/li>\n<li>If <em>length<\/em> is omitted or is negative, then all the rest of the string beginning at <em>offset<\/em> is returned.<\/li>\n<\/ul>\n<pre class=\"brush:shell\">${123456789:1} - returns the string 23456789\n${123456789:-4} - returns the string 6789\n${123456789:0:3} - returns the string 123\n${123456789:2:3} - returns the string 345\n${123456789:-4:3} - returns the string 678\n\nexten =&gt; _NXX.,1,Set(areacode=${EXTEN:0:3}) - get the first 3 digits of ${EXTEN}\nexten =&gt; _516XXXXXXX,1,Dial(${EXTEN:3}) - get all but the first 3 digits of ${EXTEN}\nexten =&gt; 100,1,Set(whichVowel=4)\n\nexten =&gt; 100,2,Set(foo=AEIOU:${whichVowel}:1) - sets ${foo} to the single letter 'U'<\/pre>\n<p><strong>String Concatenation<\/strong><\/p>\n<p>\ub450 \uac1c\uc774\uc0c1\uc758 \ubb38\uc790\uc5f4\ub4e4\uc744 \ud569\uce5c\ub2e4\uba74 \ub2e4\uc74c\uacfc \uac19\uc774 \ud558\uba74 \ub41c\ub2e4.<\/p>\n<pre class=\"brush:shell\">${foo}${bar}\n555${theNumber}\n${longDistancePrefix}555${theNumber}<\/pre>\n<p><strong>Variable math<\/strong><\/p>\n<p>\ubcc0\uc218\ub4e4\uc744 \uc774\uc6a9\ud558\uc5ec \ub354\ud558\uae30, \uacf1\ud558\uae30, \uc99d\uac00\ud558\uae30\ub4e4\uc744 \ud558\uace0\uc2f6\ub2e4\uba74..<\/p>\n<pre class=\"brush:shell\">exten =&gt; s,1,Set(SOMEVAR=$[${SOMEVAR} + 1]) ; increment\nexten =&gt; s,2,Set(SOMEVAR=$[2 * ${SOMEVAR}]) ; multiplication etc...\nIn times past, a single space was required between items in the $[...] expressions. This is no longer the case!\n\nIn late model Asterisks (1.2?), the MATH function is also available...\n\nexten =&gt; s,1,Set(SOMEVAR=${MATH(${SOMEVAR}+1,i)}) ; increment, get result as integer\nexten =&gt; s,2,Set(SOMEVAR=${MATH(2*${SOMEVAR})}) ; multiplication etc...<\/pre>\n<p>\ucd9c\ucc98 : <a title=\"http:\/\/www.voip-info.org\/wiki\/view\/Asterisk+variables\" href=\"http:\/\/www.voip-info.org\/wiki\/view\/Asterisk+variables\" target=\"_blank\">http:\/\/www.voip-info.org\/wiki\/view\/Asterisk+variables<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Using Variables in Asterisk Dialplans Asterisk \uc5d0\uc11c Dialplan \uc791\uc131\uc2dc, \ub0b4\ubd80 \ubcc0\uc218\ub97c \ubaa9\uc801\uc5d0 \ub530\ub77c Global, Shared, Chanel-specific \ubcc0\uc218\ub85c \uad6c\ubd84\ud574\uc11c \uc0ac\uc6a9\ud560 \uc218 \uc788\ub2e4. \uacf5\ud1b5\uc801\uc73c\ub85c \ubcc0\uc218\ub97c \uc0ac\uc6a9\ud560 \ub54c \ub2e4\uc74c\uacfc \uac19\uc740 \ubc29\uc2dd\uc73c\ub85c \uc0ac\uc6a9\ud560 \uc218 \uc788\ub2e4. ${foo:offset:length} foo \ub294 \ubcc0\uc218\uc758 \uc774\ub984\uc774\uace0, offset \uc740 \ubcc0\uc218\uc758 \ub0b4\uc6a9 &hellip; <a href=\"http:\/\/pchero21.com\/?p=3148\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[15],"tags":[103,154,409],"_links":{"self":[{"href":"http:\/\/pchero21.com\/index.php?rest_route=\/wp\/v2\/posts\/3148"}],"collection":[{"href":"http:\/\/pchero21.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/pchero21.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/pchero21.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/pchero21.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3148"}],"version-history":[{"count":0,"href":"http:\/\/pchero21.com\/index.php?rest_route=\/wp\/v2\/posts\/3148\/revisions"}],"wp:attachment":[{"href":"http:\/\/pchero21.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3148"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/pchero21.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3148"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/pchero21.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3148"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}