Help with substr

Thanks in advance for your help, I've been stuck on this for hours.

I am using XLSForm to make my form. I have created a large a
cascading_select [province, then district, then facility], and at the end
of each set of choices, I also needed to include an "Other" option- a text
field where the user can enter the name of any facilities not listed.

I dealt with this by manually generating "other" choices for each possible
outcome from the cascading_select. I named these choices (z_other1,
z_other2... z_other 21).

I am now trying to have add the "other" text question, where the user can
enter the name of any facility not listed. My approach is to have the
question be relevant if a substring of the ${facility_f} field, from 1 to 7
is equal to "z_other". Thus, I have been trying to use the substr
operator.

I tried to create a relevant filter along the lines of selected(substr
('${facility_f}',1,7), 'z_other'**)
or *selected(${facility_f},
"substr('${facility_f}',1,7)" = 'z_other') *and have not gotten them to
work.

Is my approach to using the substring operator incorrect?

Thanks so much!!
-Aaron

If these are select1, the field value is just the value of what was
selected. You can just write:

substr(${facility_f},1,7) = 'z_other'

If it is a multiple-choice question, you would need to use the fact that
the field stores a space-separated list of values. You could then do:

regex( concat(' ',${facility_f}), '.* z_other.*')

This takes the space-separated selections, prepends a space, then tests
whether that string matches the pattern: "<0orMoreAnything>
z_other<0orMoreAnything>"

ยทยทยท On Mon, Nov 4, 2013 at 1:08 PM, Aaron wrote:

Thanks in advance for your help, I've been stuck on this for hours.

I am using XLSForm to make my form. I have created a large a
cascading_select [province, then district, then facility], and at the end
of each set of choices, I also needed to include an "Other" option- a text
field where the user can enter the name of any facilities not listed.

I dealt with this by manually generating "other" choices for each possible
outcome from the cascading_select. I named these choices (z_other1,
z_other2... z_other 21).

I am now trying to have add the "other" text question, where the user can
enter the name of any facility not listed. My approach is to have the
question be relevant if a substring of the ${facility_f} field, from 1 to 7
is equal to "z_other". Thus, I have been trying to use the substr
operator.

I tried to create a relevant filter along the lines of selected(substr('${facility_f}',1,7),
'z_other'**)
or *selected(${facility_f}, "substr('${facility_f}',1,7)"
= 'z_other') *and have not gotten them to work.

Is my approach to using the substring operator incorrect?

Thanks so much!!
-Aaron

--

Post: opendatakit@googlegroups.com
Unsubscribe: opendatakit+unsubscribe@googlegroups.com
Options: http://groups.google.com/group/opendatakit?hl=en


You received this message because you are subscribed to the Google Groups
"ODK Community" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to opendatakit+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

--
Mitch Sundt
Software Engineer
University of Washington
mitchellsundt@gmail.com