Millisecond Forums

Quitting the script at different values

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

By Djo - 5/27/2021

Dear all,
At the beginning of our experiment, I would like to request the postal code of our participants and only allow people who live in certain areas to participate in our experiment. For this purpose, I have created the following:
<textbox PLZ>
/ caption = "xxx postal code xxx."
/ required = true
/ mask = decimal
</textbox>

<values>
/PLZ_correct = 0
</values>

<surveypage s_einwilligung>
/ questions = [1 = Einwilligung; 2 = Alter; 3 = PLZ]
/ ontrialend = [if (textbox.PLZ.response == "20259" || "20251" || "20249") values.PLZ_correct +=1
else values.PLZ_correct +=0]
</surveypage>

<surveypage s_einwilligung2>
/ questions = [1 = Sehen; 2 = Erkrankung; 3= LRS]
/ branch = [if (values.PLZ_correct == 1) survey.X
     else surveypage.s_ende;]
</surveypage>
Unfortunately, it does not work, and I can not find the error. For any help, I would be very grateful!
All the best,
Djo
By Dave - 5/27/2021

Djo - 5/27/2021
Dear all,
At the beginning of our experiment, I would like to request the postal code of our participants and only allow people who live in certain areas to participate in our experiment. For this purpose, I have created the following:
<textbox PLZ>
/ caption = "xxx postal code xxx."
/ required = true
/ mask = decimal
</textbox>

<values>
/PLZ_correct = 0
</values>

<surveypage s_einwilligung>
/ questions = [1 = Einwilligung; 2 = Alter; 3 = PLZ]
/ ontrialend = [if (textbox.PLZ.response == "20259" || "20251" || "20249") values.PLZ_correct +=1
else values.PLZ_correct +=0]
</surveypage>

<surveypage s_einwilligung2>
/ questions = [1 = Sehen; 2 = Erkrankung; 3= LRS]
/ branch = [if (values.PLZ_correct == 1) survey.X
     else surveypage.s_ende;]
</surveypage>
Unfortunately, it does not work, and I can not find the error. For any help, I would be very grateful!
All the best,
Djo

This is not proper syntax:

if (textbox.PLZ.response == "20259" || "20251" || "20249")

The correct way to state the above is

if (textbox.PLZ.response == "20259" || textbox.PLZ.response == "20251" || textbox.PLZ.response == "20249")

Moreover, you cannot have a <surveypage> (which is a type of <trial>) /branch to a <survey> (which is a type of <block>).

<surveypage s_einwilligung2>
/ questions = [1 = Sehen; 2 = Erkrankung; 3= LRS]
/ branch = [if (values.PLZ_correct == 1) survey.X
  else surveypage.s_ende;]
</surveypage>

A <trial> may only branch to another <trial>, it cannot branch to a <block>. Similarly, a <block> may only branch to another <block>, it cannot branch to a <trial>.

<textbox PLZ>
/ caption = "xxx postal code xxx."
/ required = true
/ mask = decimal
</textbox>

<values>
/PLZ_correct = 0
</values>

<survey mysurvey>
/ pages = [1=s_einwilligung]
</survey>

<surveypage s_einwilligung>
/ questions = [1 = PLZ]
/ ontrialend = [if (textbox.PLZ.response == "20259" || textbox.PLZ.response == "20251" || textbox.PLZ.response == "20249") values.PLZ_correct +=1
else values.PLZ_correct +=0]
/ branch = [
    if (values.PLZ_correct == 1) {
        surveypage.ok
    } else {
        surveypage.ende
    }
]
</surveypage>

<surveypage ok>
/ caption = "OK"
/ showbackbutton = false
</surveypage>

<surveypage ende>
/ caption = "ENDE"
/ showbackbutton = false
</surveypage>

By Djo - 5/28/2021

Dave - 5/27/2021
Djo - 5/27/2021
Dear all,
At the beginning of our experiment, I would like to request the postal code of our participants and only allow people who live in certain areas to participate in our experiment. For this purpose, I have created the following:
<textbox PLZ>
/ caption = "xxx postal code xxx."
/ required = true
/ mask = decimal
</textbox>

<values>
/PLZ_correct = 0
</values>

<surveypage s_einwilligung>
/ questions = [1 = Einwilligung; 2 = Alter; 3 = PLZ]
/ ontrialend = [if (textbox.PLZ.response == "20259" || "20251" || "20249") values.PLZ_correct +=1
else values.PLZ_correct +=0]
</surveypage>

<surveypage s_einwilligung2>
/ questions = [1 = Sehen; 2 = Erkrankung; 3= LRS]
/ branch = [if (values.PLZ_correct == 1) survey.X
     else surveypage.s_ende;]
</surveypage>
Unfortunately, it does not work, and I can not find the error. For any help, I would be very grateful!
All the best,
Djo

This is not proper syntax:

if (textbox.PLZ.response == "20259" || "20251" || "20249")

The correct way to state the above is

if (textbox.PLZ.response == "20259" || textbox.PLZ.response == "20251" || textbox.PLZ.response == "20249")

Moreover, you cannot have a <surveypage> (which is a type of <trial>) /branch to a <survey> (which is a type of <block>).

<surveypage s_einwilligung2>
/ questions = [1 = Sehen; 2 = Erkrankung; 3= LRS]
/ branch = [if (values.PLZ_correct == 1) survey.X
  else surveypage.s_ende;]
</surveypage>

A <trial> may only branch to another <trial>, it cannot branch to a <block>. Similarly, a <block> may only branch to another <block>, it cannot branch to a <trial>.

<textbox PLZ>
/ caption = "xxx postal code xxx."
/ required = true
/ mask = decimal
</textbox>

<values>
/PLZ_correct = 0
</values>

<survey mysurvey>
/ pages = [1=s_einwilligung]
</survey>

<surveypage s_einwilligung>
/ questions = [1 = PLZ]
/ ontrialend = [if (textbox.PLZ.response == "20259" || textbox.PLZ.response == "20251" || textbox.PLZ.response == "20249") values.PLZ_correct +=1
else values.PLZ_correct +=0]
/ branch = [
    if (values.PLZ_correct == 1) {
        surveypage.ok
    } else {
        surveypage.ende
    }
]
</surveypage>

<surveypage ok>
/ caption = "OK"
/ showbackbutton = false
</surveypage>

<surveypage ende>
/ caption = "ENDE"
/ showbackbutton = false
</surveypage>


Dear Dave,

Thank you very much for your quick help. Now it works quite nicely!

All the best,
Djo