[asterisk-users] Correct syntax for IF()?
Turbo Fredriksson
turbo at bayour.com
Mon Nov 26 16:40:37 CST 2007
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 :).
More information about the asterisk-users
mailing list