Millisecond Forums

Conditional branching in batch files

https://forums.millisecond.com/Topic28947.aspx

By charlotterae - 5/7/2020

My study has a number of exclusion criteria. I start the study by first checking for these exclusion criteria, in a file called ‘demographics.iqx’.

I then want to use their report to either continue or abort the study.

For example, if a participant responds ‘yes’ to the question ‘do you have a sleep disorder’, I want to skip over all the questionnaires in my study, and take them to a ‘goodbye’ page with info about sleep disorders.

If they respond ‘no’, I want to present them with my sequence of .iqx files.

i.e. something like

<batch>
/ file = “demographics.iqx”
if radiobuttons.sleepdisorders.response == 1 in the demographics_summary.iqdat then
/ file = “goodbye.iqx”
</batch>

<batch>
/ file = “demographics.iqx”
if radiobuttons.sleepdisorders.response == 2 in the demographics_summary.iqdat then
/ file = “questionnaire1.iqx”
/ file = “questionnaire2.iqx”
/ file = “questionnaire3.iqx”
</batch>

Is there some sort of equivalent to <branch> or <skip> that you can use in a batch file?

With many thanks

Charlotte Rae
By Dave - 5/7/2020

charlotterae - 5/7/2020
My study has a number of exclusion criteria. I start the study by first checking for these exclusion criteria, in a file called ‘demographics.iqx’.

I then want to use their report to either continue or abort the study.

For example, if a participant responds ‘yes’ to the question ‘do you have a sleep disorder’, I want to skip over all the questionnaires in my study, and take them to a ‘goodbye’ page with info about sleep disorders.

If they respond ‘no’, I want to present them with my sequence of .iqx files.

i.e. something like

<batch>
/ file = “demographics.iqx”
if radiobuttons.sleepdisorders.response == 1 in the demographics_summary.iqdat then
/ file = “goodbye.iqx”
</batch>

<batch>
/ file = “demographics.iqx”
if radiobuttons.sleepdisorders.response == 2 in the demographics_summary.iqdat then
/ file = “questionnaire1.iqx”
/ file = “questionnaire2.iqx”
/ file = “questionnaire3.iqx”
</batch>

Is there some sort of equivalent to <branch> or <skip> that you can use in a batch file?

With many thanks

Charlotte Rae

You need to work with batch parameters and values ( https://www.millisecond.com/support/docs/v5/html/howto/batchparameters.htm ) and then use script.abort(false) /onexptbegin in the various scripts to prevent them from running. See this example: https://www.millisecond.com/forums/Topic23921.aspx#23934
By charlotterae - 5/7/2020

Dave - 5/7/2020
charlotterae - 5/7/2020
My study has a number of exclusion criteria. I start the study by first checking for these exclusion criteria, in a file called ‘demographics.iqx’.

I then want to use their report to either continue or abort the study.

For example, if a participant responds ‘yes’ to the question ‘do you have a sleep disorder’, I want to skip over all the questionnaires in my study, and take them to a ‘goodbye’ page with info about sleep disorders.

If they respond ‘no’, I want to present them with my sequence of .iqx files.

i.e. something like

<batch>
/ file = “demographics.iqx”
if radiobuttons.sleepdisorders.response == 1 in the demographics_summary.iqdat then
/ file = “goodbye.iqx”
</batch>

<batch>
/ file = “demographics.iqx”
if radiobuttons.sleepdisorders.response == 2 in the demographics_summary.iqdat then
/ file = “questionnaire1.iqx”
/ file = “questionnaire2.iqx”
/ file = “questionnaire3.iqx”
</batch>

Is there some sort of equivalent to <branch> or <skip> that you can use in a batch file?

With many thanks

Charlotte Rae

You need to work with batch parameters and values ( https://www.millisecond.com/support/docs/v5/html/howto/batchparameters.htm ) and then use script.abort(false) /onexptbegin in the various scripts to prevent them from running. See this example: https://www.millisecond.com/forums/Topic23921.aspx#23934

Dave - 5/7/2020
charlotterae - 5/7/2020
My study has a number of exclusion criteria. I start the study by first checking for these exclusion criteria, in a file called ‘demographics.iqx’.

I then want to use their report to either continue or abort the study.

For example, if a participant responds ‘yes’ to the question ‘do you have a sleep disorder’, I want to skip over all the questionnaires in my study, and take them to a ‘goodbye’ page with info about sleep disorders.

If they respond ‘no’, I want to present them with my sequence of .iqx files.

i.e. something like

<batch>
/ file = “demographics.iqx”
if radiobuttons.sleepdisorders.response == 1 in the demographics_summary.iqdat then
/ file = “goodbye.iqx”
</batch>

<batch>
/ file = “demographics.iqx”
if radiobuttons.sleepdisorders.response == 2 in the demographics_summary.iqdat then
/ file = “questionnaire1.iqx”
/ file = “questionnaire2.iqx”
/ file = “questionnaire3.iqx”
</batch>

Is there some sort of equivalent to <branch> or <skip> that you can use in a batch file?

With many thanks

Charlotte Rae

You need to work with batch parameters and values ( https://www.millisecond.com/support/docs/v5/html/howto/batchparameters.htm ) and then use script.abort(false) /onexptbegin in the various scripts to prevent them from running. See this example: https://www.millisecond.com/forums/Topic23921.aspx#23934

Hi Dave,

Many thanks for your advice – I have given this a try (attached Batch and .iqx files), but running into 2 difficulties:

1)    It seems the parameters.sleepdis is not being recognised within ‘ontrialbegin’ in each .iqx file, because they all execute, regardless of the answer I give in demographics.iqx. I also tried ‘onblockbegin’ but this gives the same result. Do I maybe need to use ‘expressions’ within ‘onblockend’ in demographics.iqx, instead of ‘values’?
2)    When attempting to add in age criteria e.g.
if (parameters.age !>30) script.abort(true)
it throws ‘parameter.age invalid’. I suspect its because I use a textbox in demographics to get age, and the ontrial begin expects a numeric parameter. Is there a way to convert text to age?

Can you help with both these?

Best

Charlotte

By Dave - 5/7/2020

charlotterae - 5/7/2020
Dave - 5/7/2020
charlotterae - 5/7/2020
My study has a number of exclusion criteria. I start the study by first checking for these exclusion criteria, in a file called ‘demographics.iqx’.

I then want to use their report to either continue or abort the study.

For example, if a participant responds ‘yes’ to the question ‘do you have a sleep disorder’, I want to skip over all the questionnaires in my study, and take them to a ‘goodbye’ page with info about sleep disorders.

If they respond ‘no’, I want to present them with my sequence of .iqx files.

i.e. something like

<batch>
/ file = “demographics.iqx”
if radiobuttons.sleepdisorders.response == 1 in the demographics_summary.iqdat then
/ file = “goodbye.iqx”
</batch>

<batch>
/ file = “demographics.iqx”
if radiobuttons.sleepdisorders.response == 2 in the demographics_summary.iqdat then
/ file = “questionnaire1.iqx”
/ file = “questionnaire2.iqx”
/ file = “questionnaire3.iqx”
</batch>

Is there some sort of equivalent to <branch> or <skip> that you can use in a batch file?

With many thanks

Charlotte Rae

You need to work with batch parameters and values ( https://www.millisecond.com/support/docs/v5/html/howto/batchparameters.htm ) and then use script.abort(false) /onexptbegin in the various scripts to prevent them from running. See this example: https://www.millisecond.com/forums/Topic23921.aspx#23934

Dave - 5/7/2020
charlotterae - 5/7/2020
My study has a number of exclusion criteria. I start the study by first checking for these exclusion criteria, in a file called ‘demographics.iqx’.

I then want to use their report to either continue or abort the study.

For example, if a participant responds ‘yes’ to the question ‘do you have a sleep disorder’, I want to skip over all the questionnaires in my study, and take them to a ‘goodbye’ page with info about sleep disorders.

If they respond ‘no’, I want to present them with my sequence of .iqx files.

i.e. something like

<batch>
/ file = “demographics.iqx”
if radiobuttons.sleepdisorders.response == 1 in the demographics_summary.iqdat then
/ file = “goodbye.iqx”
</batch>

<batch>
/ file = “demographics.iqx”
if radiobuttons.sleepdisorders.response == 2 in the demographics_summary.iqdat then
/ file = “questionnaire1.iqx”
/ file = “questionnaire2.iqx”
/ file = “questionnaire3.iqx”
</batch>

Is there some sort of equivalent to <branch> or <skip> that you can use in a batch file?

With many thanks

Charlotte Rae

You need to work with batch parameters and values ( https://www.millisecond.com/support/docs/v5/html/howto/batchparameters.htm ) and then use script.abort(false) /onexptbegin in the various scripts to prevent them from running. See this example: https://www.millisecond.com/forums/Topic23921.aspx#23934

Hi Dave,

Many thanks for your advice – I have given this a try (attached Batch and .iqx files), but running into 2 difficulties:

1)    It seems the parameters.sleepdis is not being recognised within ‘ontrialbegin’ in each .iqx file, because they all execute, regardless of the answer I give in demographics.iqx. I also tried ‘onblockbegin’ but this gives the same result. Do I maybe need to use ‘expressions’ within ‘onblockend’ in demographics.iqx, instead of ‘values’?
2)    When attempting to add in age criteria e.g.
if (parameters.age !>30) script.abort(true)
it throws ‘parameter.age invalid’. I suspect its because I use a textbox in demographics to get age, and the ontrial begin expects a numeric parameter. Is there a way to convert text to age?

Can you help with both these?

Best

Charlotte


You need to add the relevant parameters to each script as detailed in the example:



and stuff like this

<survey age>
/ pages = [
    1 = age;
]
/ onblockbegin = [
    if (parameters.age !18<>30) script.abort(true)
    if (parameters.sleepdis !>=31) script.abort(false)
    if (parameters.sleepdis !<=17) script.abort(false)
]

simply isn't valid syntax. I'm honestly not sure what these are supposed to do.
By Dave - 5/7/2020

Dave - 5/7/2020
charlotterae - 5/7/2020
Dave - 5/7/2020
charlotterae - 5/7/2020
My study has a number of exclusion criteria. I start the study by first checking for these exclusion criteria, in a file called ‘demographics.iqx’.

I then want to use their report to either continue or abort the study.

For example, if a participant responds ‘yes’ to the question ‘do you have a sleep disorder’, I want to skip over all the questionnaires in my study, and take them to a ‘goodbye’ page with info about sleep disorders.

If they respond ‘no’, I want to present them with my sequence of .iqx files.

i.e. something like

<batch>
/ file = “demographics.iqx”
if radiobuttons.sleepdisorders.response == 1 in the demographics_summary.iqdat then
/ file = “goodbye.iqx”
</batch>

<batch>
/ file = “demographics.iqx”
if radiobuttons.sleepdisorders.response == 2 in the demographics_summary.iqdat then
/ file = “questionnaire1.iqx”
/ file = “questionnaire2.iqx”
/ file = “questionnaire3.iqx”
</batch>

Is there some sort of equivalent to <branch> or <skip> that you can use in a batch file?

With many thanks

Charlotte Rae

You need to work with batch parameters and values ( https://www.millisecond.com/support/docs/v5/html/howto/batchparameters.htm ) and then use script.abort(false) /onexptbegin in the various scripts to prevent them from running. See this example: https://www.millisecond.com/forums/Topic23921.aspx#23934

Dave - 5/7/2020
charlotterae - 5/7/2020
My study has a number of exclusion criteria. I start the study by first checking for these exclusion criteria, in a file called ‘demographics.iqx’.

I then want to use their report to either continue or abort the study.

For example, if a participant responds ‘yes’ to the question ‘do you have a sleep disorder’, I want to skip over all the questionnaires in my study, and take them to a ‘goodbye’ page with info about sleep disorders.

If they respond ‘no’, I want to present them with my sequence of .iqx files.

i.e. something like

<batch>
/ file = “demographics.iqx”
if radiobuttons.sleepdisorders.response == 1 in the demographics_summary.iqdat then
/ file = “goodbye.iqx”
</batch>

<batch>
/ file = “demographics.iqx”
if radiobuttons.sleepdisorders.response == 2 in the demographics_summary.iqdat then
/ file = “questionnaire1.iqx”
/ file = “questionnaire2.iqx”
/ file = “questionnaire3.iqx”
</batch>

Is there some sort of equivalent to <branch> or <skip> that you can use in a batch file?

With many thanks

Charlotte Rae

You need to work with batch parameters and values ( https://www.millisecond.com/support/docs/v5/html/howto/batchparameters.htm ) and then use script.abort(false) /onexptbegin in the various scripts to prevent them from running. See this example: https://www.millisecond.com/forums/Topic23921.aspx#23934

Hi Dave,

Many thanks for your advice – I have given this a try (attached Batch and .iqx files), but running into 2 difficulties:

1)    It seems the parameters.sleepdis is not being recognised within ‘ontrialbegin’ in each .iqx file, because they all execute, regardless of the answer I give in demographics.iqx. I also tried ‘onblockbegin’ but this gives the same result. Do I maybe need to use ‘expressions’ within ‘onblockend’ in demographics.iqx, instead of ‘values’?
2)    When attempting to add in age criteria e.g.
if (parameters.age !>30) script.abort(true)
it throws ‘parameter.age invalid’. I suspect its because I use a textbox in demographics to get age, and the ontrial begin expects a numeric parameter. Is there a way to convert text to age?

Can you help with both these?

Best

Charlotte


You need to add the relevant parameters to each script as detailed in the example:



and stuff like this

<survey age>
/ pages = [
    1 = age;
]
/ onblockbegin = [
    if (parameters.age !18<>30) script.abort(true)
    if (parameters.sleepdis !>=31) script.abort(false)
    if (parameters.sleepdis !<=17) script.abort(false)
]

simply isn't valid syntax. I'm honestly not sure what these are supposed to do.

Attached below is a set of files; this represents my best guess of how you want things to work.
By charlotterae - 5/12/2020

Dave - 5/7/2020
Dave - 5/7/2020
charlotterae - 5/7/2020
Dave - 5/7/2020
charlotterae - 5/7/2020
My study has a number of exclusion criteria. I start the study by first checking for these exclusion criteria, in a file called ‘demographics.iqx’.

I then want to use their report to either continue or abort the study.

For example, if a participant responds ‘yes’ to the question ‘do you have a sleep disorder’, I want to skip over all the questionnaires in my study, and take them to a ‘goodbye’ page with info about sleep disorders.

If they respond ‘no’, I want to present them with my sequence of .iqx files.

i.e. something like

<batch>
/ file = “demographics.iqx”
if radiobuttons.sleepdisorders.response == 1 in the demographics_summary.iqdat then
/ file = “goodbye.iqx”
</batch>

<batch>
/ file = “demographics.iqx”
if radiobuttons.sleepdisorders.response == 2 in the demographics_summary.iqdat then
/ file = “questionnaire1.iqx”
/ file = “questionnaire2.iqx”
/ file = “questionnaire3.iqx”
</batch>

Is there some sort of equivalent to <branch> or <skip> that you can use in a batch file?

With many thanks

Charlotte Rae

You need to work with batch parameters and values ( https://www.millisecond.com/support/docs/v5/html/howto/batchparameters.htm ) and then use script.abort(false) /onexptbegin in the various scripts to prevent them from running. See this example: https://www.millisecond.com/forums/Topic23921.aspx#23934

Dave - 5/7/2020
charlotterae - 5/7/2020
My study has a number of exclusion criteria. I start the study by first checking for these exclusion criteria, in a file called ‘demographics.iqx’.

I then want to use their report to either continue or abort the study.

For example, if a participant responds ‘yes’ to the question ‘do you have a sleep disorder’, I want to skip over all the questionnaires in my study, and take them to a ‘goodbye’ page with info about sleep disorders.

If they respond ‘no’, I want to present them with my sequence of .iqx files.

i.e. something like

<batch>
/ file = “demographics.iqx”
if radiobuttons.sleepdisorders.response == 1 in the demographics_summary.iqdat then
/ file = “goodbye.iqx”
</batch>

<batch>
/ file = “demographics.iqx”
if radiobuttons.sleepdisorders.response == 2 in the demographics_summary.iqdat then
/ file = “questionnaire1.iqx”
/ file = “questionnaire2.iqx”
/ file = “questionnaire3.iqx”
</batch>

Is there some sort of equivalent to <branch> or <skip> that you can use in a batch file?

With many thanks

Charlotte Rae

You need to work with batch parameters and values ( https://www.millisecond.com/support/docs/v5/html/howto/batchparameters.htm ) and then use script.abort(false) /onexptbegin in the various scripts to prevent them from running. See this example: https://www.millisecond.com/forums/Topic23921.aspx#23934

Hi Dave,

Many thanks for your advice – I have given this a try (attached Batch and .iqx files), but running into 2 difficulties:

1)    It seems the parameters.sleepdis is not being recognised within ‘ontrialbegin’ in each .iqx file, because they all execute, regardless of the answer I give in demographics.iqx. I also tried ‘onblockbegin’ but this gives the same result. Do I maybe need to use ‘expressions’ within ‘onblockend’ in demographics.iqx, instead of ‘values’?
2)    When attempting to add in age criteria e.g.
if (parameters.age !>30) script.abort(true)
it throws ‘parameter.age invalid’. I suspect its because I use a textbox in demographics to get age, and the ontrial begin expects a numeric parameter. Is there a way to convert text to age?

Can you help with both these?

Best

Charlotte


You need to add the relevant parameters to each script as detailed in the example:



and stuff like this

<survey age>
/ pages = [
    1 = age;
]
/ onblockbegin = [
    if (parameters.age !18<>30) script.abort(true)
    if (parameters.sleepdis !>=31) script.abort(false)
    if (parameters.sleepdis !<=17) script.abort(false)
]

simply isn't valid syntax. I'm honestly not sure what these are supposed to do.

Attached below is a set of files; this represents my best guess of how you want things to work.

Hi Dave,

Great, thanks - this is working.

I am hitting one more snag - at the termination of the final .iqx (whether the WHO5 surveypage or 'you don't meet inclusion criteria, goodbye' page), a blank white screen appears, with no way to exit other than Command+Q (I am on a mac). All the data are recorded, there's just no way to exit the white screen. What am I missing in either my batch or the .iqx files so that when the participant presses Finish (specified in e.g. survey.age.finishlabel), the window closes?

Charlotte
By Dave - 5/12/2020

charlotterae - 5/12/2020
Dave - 5/7/2020
Dave - 5/7/2020
charlotterae - 5/7/2020
Dave - 5/7/2020
charlotterae - 5/7/2020
My study has a number of exclusion criteria. I start the study by first checking for these exclusion criteria, in a file called ‘demographics.iqx’.

I then want to use their report to either continue or abort the study.

For example, if a participant responds ‘yes’ to the question ‘do you have a sleep disorder’, I want to skip over all the questionnaires in my study, and take them to a ‘goodbye’ page with info about sleep disorders.

If they respond ‘no’, I want to present them with my sequence of .iqx files.

i.e. something like

<batch>
/ file = “demographics.iqx”
if radiobuttons.sleepdisorders.response == 1 in the demographics_summary.iqdat then
/ file = “goodbye.iqx”
</batch>

<batch>
/ file = “demographics.iqx”
if radiobuttons.sleepdisorders.response == 2 in the demographics_summary.iqdat then
/ file = “questionnaire1.iqx”
/ file = “questionnaire2.iqx”
/ file = “questionnaire3.iqx”
</batch>

Is there some sort of equivalent to <branch> or <skip> that you can use in a batch file?

With many thanks

Charlotte Rae

You need to work with batch parameters and values ( https://www.millisecond.com/support/docs/v5/html/howto/batchparameters.htm ) and then use script.abort(false) /onexptbegin in the various scripts to prevent them from running. See this example: https://www.millisecond.com/forums/Topic23921.aspx#23934

Dave - 5/7/2020
charlotterae - 5/7/2020
My study has a number of exclusion criteria. I start the study by first checking for these exclusion criteria, in a file called ‘demographics.iqx’.

I then want to use their report to either continue or abort the study.

For example, if a participant responds ‘yes’ to the question ‘do you have a sleep disorder’, I want to skip over all the questionnaires in my study, and take them to a ‘goodbye’ page with info about sleep disorders.

If they respond ‘no’, I want to present them with my sequence of .iqx files.

i.e. something like

<batch>
/ file = “demographics.iqx”
if radiobuttons.sleepdisorders.response == 1 in the demographics_summary.iqdat then
/ file = “goodbye.iqx”
</batch>

<batch>
/ file = “demographics.iqx”
if radiobuttons.sleepdisorders.response == 2 in the demographics_summary.iqdat then
/ file = “questionnaire1.iqx”
/ file = “questionnaire2.iqx”
/ file = “questionnaire3.iqx”
</batch>

Is there some sort of equivalent to <branch> or <skip> that you can use in a batch file?

With many thanks

Charlotte Rae

You need to work with batch parameters and values ( https://www.millisecond.com/support/docs/v5/html/howto/batchparameters.htm ) and then use script.abort(false) /onexptbegin in the various scripts to prevent them from running. See this example: https://www.millisecond.com/forums/Topic23921.aspx#23934

Hi Dave,

Many thanks for your advice – I have given this a try (attached Batch and .iqx files), but running into 2 difficulties:

1)    It seems the parameters.sleepdis is not being recognised within ‘ontrialbegin’ in each .iqx file, because they all execute, regardless of the answer I give in demographics.iqx. I also tried ‘onblockbegin’ but this gives the same result. Do I maybe need to use ‘expressions’ within ‘onblockend’ in demographics.iqx, instead of ‘values’?
2)    When attempting to add in age criteria e.g.
if (parameters.age !>30) script.abort(true)
it throws ‘parameter.age invalid’. I suspect its because I use a textbox in demographics to get age, and the ontrial begin expects a numeric parameter. Is there a way to convert text to age?

Can you help with both these?

Best

Charlotte


You need to add the relevant parameters to each script as detailed in the example:



and stuff like this

<survey age>
/ pages = [
    1 = age;
]
/ onblockbegin = [
    if (parameters.age !18<>30) script.abort(true)
    if (parameters.sleepdis !>=31) script.abort(false)
    if (parameters.sleepdis !<=17) script.abort(false)
]

simply isn't valid syntax. I'm honestly not sure what these are supposed to do.

Attached below is a set of files; this represents my best guess of how you want things to work.

Hi Dave,

Great, thanks - this is working.

I am hitting one more snag - at the termination of the final .iqx (whether the WHO5 surveypage or 'you don't meet inclusion criteria, goodbye' page), a blank white screen appears, with no way to exit other than Command+Q (I am on a mac). All the data are recorded, there's just no way to exit the white screen. What am I missing in either my batch or the .iqx files so that when the participant presses Finish (specified in e.g. survey.age.finishlabel), the window closes?

Charlotte

I don't know, not seeing that. I suspect your Inquisit 5 installation may be outdated, so may you want to check that first and update it to 5.0.14.0 if it isn't that already.

https://www.millisecond.com/download/