[asterisk-users] Basic GotoIf question

Tony Mountifield tony at softins.co.uk
Sat Aug 25 12:08:03 CDT 2012


In article <50390065.6020200 at truemetal.org>,
Markus <universe at truemetal.org> wrote:
> 
> Can anyone shed some light on:
> 
> 
> A few more questions - the doc link that I just mentioned shows:
> 
> GotoIf(condition?label1[[:label2])
> 
> What are the [[ before :label2? There are two opening square brackets, 
> but just one ] closing? Is that a typo?

Yes, it looks like a typo and should be [ instead of [[

These square brackets are not part of the syntax, but are just showing that
the colon and label2 are optional, so it means you can have either:

GotoIf(condition?label1:label2)

or:

GotoIf(condition?label1)

In the latter case, you branch to label1 if the condition is true, and just
continue with the next statement if it's false.

> Also, the doc shows:
> 
> GotoIf(condition?[label1]:label2)
> 
> Why is label1 in square brackets and label2 isn't?

This is saying that label1 is optional. If you only want to branch when
the condition is false, you say:

GotoIf(condition?:label2)

I guess it could easily have been confusing because typically the condition
is an expression contained within $[...], where the square brackets ARE part
of the syntax!

Hope this helps!

Cheers
Tony

-- 
Tony Mountifield
Work: tony at softins.co.uk - http://www.softins.co.uk
Play: tony at mountifield.org - http://tony.mountifield.org



More information about the asterisk-users mailing list