Closed GoogleCodeExporter closed 8 years ago
You can use field "test" to get conditional PARAM. If test is true the PARAM is
visible else it will be invisible.
Example <PARAM name="kkk" ... test="${MY_VAR} = 2"/>
The condition is like a shell "test" utility.
It can contain user defined variables.
It's not obvious how to implement condition in your case. But there is a hack.
If the user defined variable is "dynamic" it will see the other PARAMs values
because it will executed in the current command context.
So you can implement the user defined var and the return value of this var can
depends on the name (and existence) of your route. But note it's a hack.
Original comment by serj.kalichev@gmail.com
on 30 Apr 2012 at 6:23
<VIEW name="configure-view">
<COMMAND name="route"
help="Select a route to configure"
view="configure-route-view"
viewid="route=${route};pattern=${pattern};trunk_group_id=${trunk_group_id}">
<PARAM name="route"
help="Name of the route you would like to configure"
ptype="STRING"
completion="${POSSIBLE_ROUTE}"/>
<PARAM name="trunk_group_id"
help="Route trunk group ID"
ptype="UINT"
completion="${POSSIBLE_TRUNK_GROUP_ID}"/>
<PARAM name="pattern"
help="Route pattern"
ptype="STRING"
test="${POSSIBLE_ROUTE}"
completion="${POSSIBLE_PATTERN}"/>
</COMMAND>
</VIEW>
Okay so I've got that now but it's the opposite of what I want, if the route
exists it requires a pattern, if the route doesn't exist it doesn't require a
pattern. If I do test="!${POSSIBLE_ROUTE}" then it requires the pattern whether
the route exists or not. Same thing happens when I use
test="${POSSIBLE_PATTERN}" or test="${POSSIBLE_PATTERN} != ''".
Original comment by zaka...@gmail.com
on 30 Apr 2012 at 7:33
The value of variable is not expression itself. The value of variable is output
of variables's code. Like a var=`ls`. The variable can generate different
output depends on some conditions.
<... test='"${CHECK_ROUTE}" = "exist"'/>
Original comment by serj.kalichev@gmail.com
on 2 May 2012 at 7:04
Not sure that I understand. I want to only require a pattern if
${POSSIBLE_PATTERN} returns "" so I tried
test="${POSSIBLE_PATTERN} != ''"
but that doesn't work it asks for a pattern when ${POSSIBLE_PATTERN} returns
something and does not ask for a pattern when ${POSSIBLE_PATTERN} returns
nothing (the opposite of what I want.)
If I try the opposite -
test="${POSSIBLE_PATTERN} = ''"
it asks for a pattern for both. So I'm really confused as to what it's checking
against. Does it try to get the value of ${POSSIBLE_PATTERN} first? Does it run
everything using test in the command line? ${POSSIBLE_PATTERN} is set by a Perl
script so does that affect anything?
<VAR name="POSSIBLE_PATTERN"
help="Displays route pattern"
dynamic="true">
<ACTION>
helper.pl exists --table=asterisk.v_routes --keycol=route_name --val="${route}%" --retcol=pattern --retempty="1"
</ACTION>
</VAR>
Original comment by zaka...@gmail.com
on 2 May 2012 at 5:03
Okay I got it to work by making my script return 'empty' when there are no
matches and using this for the param -
<PARAM name="pattern"
help="Route pattern"
ptype="STRING"
test='${POSSIBLE_PATTERN} = "empty"'
completion="${POSSIBLE_PATTERN}"/>
The only problem is when my script returns 'empty' if I tab complete it'll
actually say 'empty'.
Original comment by zaka...@gmail.com
on 2 May 2012 at 6:54
Ah okay fixed that too, I made a new variable for testing that returns empty if
it needs to, and the completion variable returns nothing when there's nothing
to complete, thank you very much.
<PARAM name="pattern"
help="Route pattern"
ptype="STRING"
test='${ROUTE_EXISTS} = "empty"'
completion="${POSSIBLE_PATTERN}"/>
Original comment by zaka...@gmail.com
on 2 May 2012 at 7:07
Original issue reported on code.google.com by
zaka...@gmail.com
on 30 Apr 2012 at 2:09