will it also be executed when the trial branches into itself?
This. block.ontrialbegin is defining global statements to be executed in *all trials* in the block. I.e.
<values>
/ count = 0
</values>
<block myblock>
/ ontrialbegin = [values.count+=1]
/ trials = [1=a]
</block>
<trial a>
/ stimulusframes = [1=mytext]
/ trialduration = 1000
/ branch = [trial.b]
</trial>
<trial b>
/ stimulusframes = [1=mytext]
/ trialduration = 1000
/ branch = [trial.a]
</trial>
<text mytext>
/ items = ("<%values.count%>")
</text>
is equivalent to
<values>
/ count = 0
</values>
<block myblock>
/ trials = [1=a]
</block>
<trial a>
/ ontrialbegin = [values.count+=1]
/ stimulusframes = [1=mytext]
/ trialduration = 1000
/ branch = [trial.b]
</trial>
<trial b>
/ ontrialbegin = [values.count+=1]
/ stimulusframes = [1=mytext]
/ trialduration = 1000
/ branch = [trial.a]
</trial>
<text mytext>
/ items = ("<%values.count%>")
</text>
Will block.ontrialbegin be executed only for the 10 times the block will call the trial OR will it also be executed when the trial branches into itself?
In any case, do I assume correctly that block.ontrialbegin always fires before trial.ontrialbegin?
No, actually it fires after, which you can see by doing something like this:
<values>
/ count = 0
</values>
<block myblock>
/ ontrialbegin = [values.count+=1]
/ trials = [1=a]
</block>
<trial a>
/ ontrialbegin = [values.count=666]
/ stimulusframes = [1=mytext]
/ trialduration = 1000
/ branch = [trial.a]
</trial>
<text mytext>
/ items = ("<%values.count%>")
</text>
Hope this helps,
~Dave