Hello I've tried a bunch of things, but still get errors/warnings when using the IF() function: ============== TEST #1 exten => h,n,Set(WAV_FILE=${IF($[ ${STAT(e,/tmp/${CALLTIME}.wav)} ]?${CALLTIME}.wav)}) [Nov 26 21:52:34] WARNING[5074]: func_logic.c:107 acf_if: Syntax IF(<expr>?[<true>][:<false>]) ============== TEST #2 exten => h,n,Set(WAV_FILE=${IF($[STAT(e,/tmp/${CALLTIME}.wav)]?${CALLTIME}.wav:"")}) [Nov 26 22:02:23] WARNING[5101]: ast_expr2.fl:398 ast_yyerror: ast_yyerror(): syntax error: syntax error, unexpected '(', expecting $end; Input: STAT(e|/tmp/.wav) ^ [Nov 26 22:02:23] WARNING[5101]: ast_expr2.fl:402 ast_yyerror: If you have questions, please refer to doc/channelvariables.txt in the asterisk source. ============== TEST #3 exten => h,n,Set(WAV_FILE=${IF($[${STAT(e,/tmp/${CALLTIME}.wav)}=1]?${CALLTIME}.wav)}) [Nov 26 22:08:42] WARNING[5109]: ast_expr2.fl:398 ast_yyerror: ast_yyerror(): syntax error: syntax error, unexpected '=', expecting $end; Input: =1 ^ [Nov 26 22:08:42] WARNING[5109]: func_logic.c:107 acf_if: Syntax IF(<expr>?[<true>][:<false>]) ============== TEST #4 exten => h,n,Set(WAV_FILE=${IF($[STAT(e,/tmp/${CALLTIME}.wav)=1]?${CALLTIME}.wav)}) [Nov 26 22:10:38] WARNING[5113]: ast_expr2.fl:398 ast_yyerror: ast_yyerror(): syntax error: syntax error, unexpected '(', expecting $end; Input: STAT(e|/tmp/.wav)=1 ^ [Nov 26 22:10:38] WARNING[5113]: ast_expr2.fl:402 ast_yyerror: If you have questions, please refer to doc/channelvariables.txt in the asterisk source. ============== TEST #5 exten => h,n,Set(WAV_FILE=${IF($[${STAT(e,/tmp/${CALLTIME}.wav)} 1]?${CALLTIME}.wav)}) [Nov 26 22:13:55] WARNING[5117]: ast_expr2.fl:398 ast_yyerror: ast_yyerror(): syntax error: syntax error, unexpected '=', expecting $end; Input: = 1 ^ [Nov 26 22:13:55] WARNING[5117]: ast_expr2.fl:402 ast_yyerror: If you have questions, please refer to doc/channelvariables.txt in the asterisk source. [Nov 26 22:13:55] WARNING[5117]: func_logic.c:107 acf_if: Syntax IF(<expr>?[<true>][:<false>]) I can't figure out why * is unhappy :-/ Any idea? Thank you.
On Monday 26 November 2007 15:51, Vincent wrote:> I've tried a bunch of things, but still get errors/warnings > when using the IF() function:Please upgrade to 1.4.14 and try again. -- Tilghman
Quoting Vincent <vincent.delporte at bigfoot.com>:> exten => h,n,Set(WAV_FILE=${IF($[ ${STAT(e,/tmp/${CALLTIME}.wav)} ]?${CALLTIME}.wav)})^ ^ ^ To start, to many spaces... And a missing end parenthesis... And a end parenthesis in the wrong place exten => h,n,Set(WAV_FILE=${IF($[${STAT(e,/tmp/${CALLTIME}.wav)}])?${CALLTIME}.wav}) ^> exten => h,n,Set(WAV_FILE=${IF($[STAT(e,/tmp/${CALLTIME}.wav)]?${CALLTIME}.wav:"")})You're missing the end parentheses of the IF. exten => h,n,Set(WAV_FILE=${IF($[STAT(e,/tmp/${CALLTIME}.wav)])?${CALLTIME}.wav:"")}) I didn't check your rest examples, but I will asume that they suffer the same problem. You should code a little lisp. That will teach you to keep your parenthesis in order :) What you do is you always write the beginning _and_ the end at once. Never try to do them 'later'... Example: 1. Set() 2. Set(WAV_FILE=${}) 3. Set(WAV_FILE=${IF()}) 4. Set(WAV_FILE=${IF($[]?:)}) etc. Do you see it? It DO help to have a good editor. I'm not going to start a war about this, but emacs rocks :).
Rpgrade.... but are you sure a '}' is not missing in your h,n,SET....... ? ----- Original Message ----- From: Vincent <vincent.delporte at bigfoot.com> To: <asterisk-users at lists.digium.com> Sent: Monday, November 26, 2007 9:51 PM Subject: [asterisk-users] Correct syntax for IF()?> Hello > > I've tried a bunch of things, but still get errors/warnings > when using the IF() function: > > ============== TEST #1 > exten => h,n,Set(WAV_FILE=${IF($[ ${STAT(e,/tmp/${CALLTIME}.wav)} > ]?${CALLTIME}.wav)}) > > [Nov 26 21:52:34] WARNING[5074]: func_logic.c:107 acf_if: Syntax > IF(<expr>?[<true>][:<false>]) > > ============== TEST #2 > exten => >h,n,Set(WAV_FILE=${IF($[STAT(e,/tmp/${CALLTIME}.wav)]?${CALLTIME}.wav:"")})> > [Nov 26 22:02:23] WARNING[5101]: ast_expr2.fl:398 ast_yyerror: > ast_yyerror(): syntax error: syntax error, unexpected '(', expecting > $end; Input: > STAT(e|/tmp/.wav) > ^ > [Nov 26 22:02:23] WARNING[5101]: ast_expr2.fl:402 ast_yyerror: If you > have questions, please refer to doc/channelvariables.txt in the > asterisk source. > > ============== TEST #3 > exten => >h,n,Set(WAV_FILE=${IF($[${STAT(e,/tmp/${CALLTIME}.wav)}=1]?${CALLTIME}.wav)} )> > [Nov 26 22:08:42] WARNING[5109]: ast_expr2.fl:398 ast_yyerror: > ast_yyerror(): syntax error: syntax error, unexpected '=', expecting > $end; Input: > =1 > ^ > [Nov 26 22:08:42] WARNING[5109]: func_logic.c:107 acf_if: Syntax > IF(<expr>?[<true>][:<false>]) > > ============== TEST #4 > exten => > h,n,Set(WAV_FILE=${IF($[STAT(e,/tmp/${CALLTIME}.wav)=1]?${CALLTIME}.wav)}) > > [Nov 26 22:10:38] WARNING[5113]: ast_expr2.fl:398 ast_yyerror: > ast_yyerror(): syntax error: syntax error, unexpected '(', expecting > $end; Input: > STAT(e|/tmp/.wav)=1 > ^ > [Nov 26 22:10:38] WARNING[5113]: ast_expr2.fl:402 ast_yyerror: If you > have questions, please refer to doc/channelvariables.txt in the > asterisk source. > > ============== TEST #5 > exten => h,n,Set(WAV_FILE=${IF($[${STAT(e,/tmp/${CALLTIME}.wav)} > 1]?${CALLTIME}.wav)}) > > [Nov 26 22:13:55] WARNING[5117]: ast_expr2.fl:398 ast_yyerror: > ast_yyerror(): syntax error: syntax error, unexpected '=', expecting > $end; Input: > = 1 > ^ > [Nov 26 22:13:55] WARNING[5117]: ast_expr2.fl:402 ast_yyerror: If you > have questions, please refer to doc/channelvariables.txt in the > asterisk source. > [Nov 26 22:13:55] WARNING[5117]: func_logic.c:107 acf_if: Syntax > IF(<expr>?[<true>][:<false>]) > > I can't figure out why * is unhappy :-/ Any idea? > > Thank you. > > > _______________________________________________ > --Bandwidth and Colocation Provided by http://www.api-digital.com-- > > asterisk-users mailing list > To UNSUBSCRIBE or update options visit: > http://lists.digium.com/mailman/listinfo/asterisk-users