> 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:
/ ontrialbegin = [
values.a = "trial"
/ stimulusframes = [1=atext]
/ validresponse = (57)
/ ontrialbegin = [
values.a = "block"
/ trials = [1=atrial]
/ items = ("<%values.a%>")
/ a = "?"
> 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
/ trials = [1= trial.a; 2=surveypage.b]
you can immediately see that "a" is a <trial> element and "b" is a <surveypage>, whereas with
/ trials = [1= a; 2=b]