Language Questions


Language Questions

Author
Message
morgan_w
morgan_w
Associate Member
Associate Member (156 reputation)Associate Member (156 reputation)Associate Member (156 reputation)Associate Member (156 reputation)Associate Member (156 reputation)Associate Member (156 reputation)Associate Member (156 reputation)Associate Member (156 reputation)Associate Member (156 reputation)

Group: Forum Members
Posts: 5, Visits: 43
Hi All,

Hoping to clear up some syntax I can't figure out from the language reference. This is my time learning a programming language, so please excuse me if I've missed anything from the reference. If anyone has learnt the answers to any of these questions, I'd really appreciate some input. Just trying to learn as fast as I can!

1. What are the key differences between values and expressions? Can expressions do everything values can, and if so, why would I ever use values? (And parameters...?)

2. What are the key differences between .insertstimulustimes( )  and .setstimulustimes( ) ?

3. Is there an order in which expressions are executed in something like /ontrialbegin[expression1; expression2; expression3]?

4. Is there an order in which competing /ontrialbegin 's (in the trial element vs above in the block element) are executed? Block before trial or vice-versa?

5.  What parts of a trial timing structure can take variables, and which of these can update between trials? I've noticed for instance that although /stimulustimes cannot take variables, insertstimulustimes() and setstimulus() can. Also, although /timeout can take a variable (value or expression), sometimes it doesn't seem to update as the variable updates from trial to trial. Is there an equivalent to /timeout that will update across trials?

6. In certain attributes or functions a stimulus needs explicit description such as trial.trialname.insertstimulustimes(picture.stimulusname, time) and in others, it does not (but can take either) e.g. /trials = [1 = trial1; 2=trial2; etc.]. In the second case, is it any more efficient to be explicit like in the first case?

An answer to even one of these questions would be much appreciated!

Cheers,
Morgan

Dave
Dave
Supreme Being
Supreme Being (752K reputation)Supreme Being (752K reputation)Supreme Being (752K reputation)Supreme Being (752K reputation)Supreme Being (752K reputation)Supreme Being (752K reputation)Supreme Being (752K reputation)Supreme Being (752K reputation)Supreme Being (752K reputation)

Group: Administrators
Posts: 9.9K, Visits: 49K
morgan_w - 7/17/2019
Hi All,

Hoping to clear up some syntax I can't figure out from the language reference. This is my time learning a programming language, so please excuse me if I've missed anything from the reference. If anyone has learnt the answers to any of these questions, I'd really appreciate some input. Just trying to learn as fast as I can!

1. What are the key differences between values and expressions? Can expressions do everything values can, and if so, why would I ever use values? (And parameters...?)

2. What are the key differences between .insertstimulustimes( )  and .setstimulustimes( ) ?

3. Is there an order in which expressions are executed in something like /ontrialbegin[expression1; expression2; expression3]?

4. Is there an order in which competing /ontrialbegin 's (in the trial element vs above in the block element) are executed? Block before trial or vice-versa?

5.  What parts of a trial timing structure can take variables, and which of these can update between trials? I've noticed for instance that although /stimulustimes cannot take variables, insertstimulustimes() and setstimulus() can. Also, although /timeout can take a variable (value or expression), sometimes it doesn't seem to update as the variable updates from trial to trial. Is there an equivalent to /timeout that will update across trials?

6. In certain attributes or functions a stimulus needs explicit description such as trial.trialname.insertstimulustimes(picture.stimulusname, time) and in others, it does not (but can take either) e.g. /trials = [1 = trial1; 2=trial2; etc.]. In the second case, is it any more efficient to be explicit like in the first case?

An answer to even one of these questions would be much appreciated!

Cheers,
Morgan

> 1. What are the key differences between values and expressions? Can expressions do everything values can, and if so, why would I ever use values? (And parameters...?)

Values are simply global variables. They are set to something and then represent whatever they were set to until you change it.
https://www.millisecond.com/support/docs/v5/html/language/elements/values.htm

Expressions are something more aking to primitive user-defined functions. Values are static, expressions are dynamic.
https://www.millisecond.com/support/docs/v5/html/language/elements/expressions.htm

Parameters are intended for a script's global, customizable settings.
https://www.millisecond.com/support/docs/v5/html/language/elements/parameters.htm

> 2. What are the key differences between .insertstimulustimes( )  and .setstimulustimes( ) ?

When you want to insert multiple stimuli at the same point in time and/or the trial already has some stimulus at that time defined per /stimulustimes and you want to dynamically add additional stimuli, you use insertstimulustime(). If a trial already has a stimulus defined per /stimulustimes and you want to change that to something else, you can use setstimulustime().

> 3. Is there an order in which expressions are executed in something like /ontrialbegin[expression1; expression2; expression3]?

Yes. They are executed in the order given, left to right, and top to bottom.

> 4. Is there an order in which competing /ontrialbegin 's (in the trial element vs above in the block element) are executed? Block before trial or vice-versa?

First the trial-level /ontrialbegin statements are executed in the order given. After that, any block-level /ontrialbegin statements are executed. See for yourself:

<trial atrial>
/ ontrialbegin = [
values.a = "trial"
]
/ stimulusframes = [1=atext]
/ validresponse = (57)
</trial>

<block ablock>
/ ontrialbegin = [
values.a = "block"
]
/ trials = [1=atrial]
</block>

<text atext>
/ items = ("<%values.a%>")
</text>

<values>
/ a = "?"
</values>

> 5.  What parts of a trial timing structure can take variables, and which of these can update between trials? I've noticed for instance that although /stimulustimes cannot take variables, insertstimulustimes() and setstimulus() can. Also, although /timeout can take a variable (value or expression), sometimes it doesn't seem to update as the variable updates from trial to trial. Is there an equivalent to /timeout that will update across trials?

It's not possible to go through all trial attributes here. Please consult the documentation for a given attribute, or -- if you have questions about a specific one -- please ask about the specific attribute here.That said,  /timeout takes variables just fine and does update across trials. If you have the impression that it does not, there is likely something wrong with your code.

> 6. In certain attributes or functions a stimulus needs explicit description such as trial.trialname.insertstimulustimes(picture.stimulusname, time) and in others, it does not (but can take either) e.g. /trials = [1 = trial1; 2=trial2; etc.]. In the second case, is it any more efficient to be explicit like in the first case?

It makes no difference in terms of efficiency. Being explicit, however, can improve code readability and aid understanding. For example with

<block example>
/ trials = [1= trial.a; 2=surveypage.b]
...
</trial>

you can immediately see that "a" is a <trial> element and "b" is a <surveypage>, whereas with

<block example>
/ trials = [1= a; 2=b]
...
</trial>

you don't.

GO


Reading This Topic


Login
Existing Account
Email Address:


Password:


Social Logins

Select a Forum....






Millisecond Forums


Search