Millisecond Forums

Using the script.currenttime as an integer

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

By audiosophy - 3/28/2018

Hi I am having a problem whereby I want to branch in my study if the currenttime is over a certain value:

e.g. 

<trial Blockertrial>
/ ontrialbegin = [values.currenttime = script.currenttime]
/ stimulustimes = [1=Blocker]
/ trialduration = 5000
/ branch = [if (values.currenttime >= 11:56:01) surveypage.sliders]
</trial>

but inquisit is not liking the "11:56:01" part ("Expression contains unknown element or property name".) 

It's got me thinking - how can I use this figure with colons etc as a value? I thought that as perhaps it is a string, I could somehow remove the colons, and convert it to an integer somehow.

I tried using one of the functions: replaceall("<% values.currenttime %>", ":", "") but Inquisit doesn't 'see' the value rather just the actual characters (the greater than sign, the percentage sign and the letters)

Would greatly appreciate a response on this as I'm up against a deadline and can't figure this out! Thanks in advance
By Dave - 3/29/2018

audiosophy - Thursday, March 29, 2018
Hi I am having a problem whereby I want to branch in my study if the currenttime is over a certain value:

e.g. 

<trial Blockertrial>
/ ontrialbegin = [values.currenttime = script.currenttime]
/ stimulustimes = [1=Blocker]
/ trialduration = 5000
/ branch = [if (values.currenttime >= 11:56:01) surveypage.sliders]
</trial>

but inquisit is not liking the "11:56:01" part ("Expression contains unknown element or property name".) 

It's got me thinking - how can I use this figure with colons etc as a value? I thought that as perhaps it is a string, I could somehow remove the colons, and convert it to an integer somehow.

I tried using one of the functions: replaceall("<% values.currenttime %>", ":", "") but Inquisit doesn't 'see' the value rather just the actual characters (the greater than sign, the percentage sign and the letters)

Would greatly appreciate a response on this as I'm up against a deadline and can't figure this out! Thanks in advance

This should do the trick:

<values>
/ currenttime = 0
</values>

<block myblock>
/ trials = [1=Blockertrial]
</block>

<trial Blockertrial>
/ ontrialbegin = [values.currenttime = script.currenttime;
    values.currenttime = replaceall(values.currenttime, ":", "");
    ]
/ stimulustimes = [1=Blocker]
/ trialduration = 5000
/ branch = [if (values.currenttime >= 115601) surveypage.sliders]
</trial>

<text blocker>
/ items = ("This is the blocker trial.")
</text>

<surveypage sliders>
/ caption = "This is the slider page."
</surveypage>
By seandr - 3/29/2018

One other thing to mention - if you're interested in the time relative to the start of the trial (as opposed to the time of day), check out the "elapsedtime" property. 

This returns an integer representing the number of milliseconds elapsed since the trial started, and is generally what we use for dynamically setting time limits and criteria. In that case, your code would look something like the following (assuming a 10 second criterion):

<trial Blockertrial>
/ stimulustimes = [1=Blocker]
/ trialduration = 5000
/ branch = [if (trial.Blockertrial.elapsedtime >=10000) surveypage.sliders]
</trial>


-Sean
By audiosophy - 3/29/2018

Ohhh sweet jesus thankyou!! That's fantastic Dave, so I have the blocker trial just looping if it isn't the right time and then when it gets to the right time it switches to the questions. Awesome.
By audiosophy - 3/29/2018

seandr - Thursday, March 29, 2018
One other thing to mention - if you're interested in the time relative to the start of the trial (as opposed to the time of day), check out the "elapsedtime" property. 

This returns an integer representing the number of milliseconds elapsed since the trial started, and is generally what we use for dynamically setting time limits and criteria. In that case, your code would look something like the following (assuming a 10 second criterion):

<trial Blockertrial>
/ stimulustimes = [1=Blocker]
/ trialduration = 5000
/ branch = [if (trial.Blockertrial.elapsedtime >=10000) surveypage.sliders]
</trial>


-Sean

Ok yeah in this case it's the absolute time of day I'm interested in but that's good to know too thanks