Millisecond Forums

Formatting subject ID

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

By nidhi_desai - 12/23/2020

I am interested in having a values.marker variable which will contain some digits as the subject ID. I need this variable's 3rd, 4th and 5th digit to indicate the subject ID. So if the subjectID is 123 values.marker should be 11123 and if subjectID is 45 values.marker should be 11045. When I use the following code using format function, I get some set of random numbers in my marker and the not the appropriate subject id. If I use another variable in the script that I had defined like values.faceDuration the formatting this way works. I am not sure why it does not work for script.subjectid and how may I resolve this?

values.marker = 11;
values.marker = concat(values.marker, format("%03d", script.subjectid));
By Dave - 12/23/2020

nidhi_desai - 12/23/2020
I am interested in having a values.marker variable which will contain some digits as the subject ID. I need this variable's 3rd, 4th and 5th digit to indicate the subject ID. So if the subjectID is 123 values.marker should be 11123 and if subjectID is 45 values.marker should be 11045. When I use the following code using format function, I get some set of random numbers in my marker and the not the appropriate subject id. If I use another variable in the script that I had defined like values.faceDuration the formatting this way works. I am not sure why it does not work for script.subjectid and how may I resolve this?

values.marker = 11;
values.marker = concat(values.marker, format("%03d", script.subjectid));

<values>
/ marker = 0
</values>

<trial mytrial>
/ ontrialbegin = [
    values.marker = 11;
    values.marker = concat(values.marker, format("%03d", evaluate(script.subjectid)));
]
/ stimulusframes = [1=mytext]
/ validresponse = (57)
</trial>

<text mytext>
/ items = ("<%values.marker%>")
</text>

You need to make sure the ID is not treated as a string, but as an integer.
By nidhi_desai - 12/23/2020

Dave - 12/23/2020
nidhi_desai - 12/23/2020
I am interested in having a values.marker variable which will contain some digits as the subject ID. I need this variable's 3rd, 4th and 5th digit to indicate the subject ID. So if the subjectID is 123 values.marker should be 11123 and if subjectID is 45 values.marker should be 11045. When I use the following code using format function, I get some set of random numbers in my marker and the not the appropriate subject id. If I use another variable in the script that I had defined like values.faceDuration the formatting this way works. I am not sure why it does not work for script.subjectid and how may I resolve this?

values.marker = 11;
values.marker = concat(values.marker, format("%03d", script.subjectid));

<values>
/ marker = 0
</values>

<trial mytrial>
/ ontrialbegin = [
    values.marker = 11;
    values.marker = concat(values.marker, format("%03d", evaluate(script.subjectid)));
]
/ stimulusframes = [1=mytext]
/ validresponse = (57)
</trial>

<text mytext>
/ items = ("<%values.marker%>")
</text>

You need to make sure the ID is not treated as a string, but as an integer.

Great, that solved the problem. Thank you.