> >
> > toneCount = toneCount +1
> >
> > If toneCount <= 5 Then
> > Goto Label2
End If
JK
At 5/9/2008 07:45 AM Friday, James Keidel wrote:
>the order you need to test things is check whether there is a
>correct response, and if there is not then you check the value of the
>toneCount.
Just to complete James' thought, here is the script (with a bit of
rearangement, and adding comments):
toneCount = toneCount + 1
If (toneCount <= 5) And (TrainingSound2.RESP <> "{SPACE}"> Then
Goto Label2 ' repeat the training loop
Else
toneCount = 0 ' reset counter for next time
Goto Label3 ' exit the training loop
End If
BTW, if the movie object immediately follows this inline script, then
you shouldn't even need the final Goto. Also, strictly speaking,
since the first Goto jumps you out of the If ... Then, you don't even
need the Else clause (although it may improve readability if you
leave it in). Putting all those together, the script might become simply:
toneCount = toneCount + 1
If (toneCount <= 5) And (TrainingSound2.RESP <> "{SPACE}"> Then
Goto Label2 ' repeat the training loop
End If
' Training loop completed, reset counter for next time:
toneCount = 0
' And move on to the movie ...
But now I'm getting too pedantic.
-- David McFarlane, Professional Faultfinder
>I tried this code, trying to adapt what you all gave me:
>
>If (toneCount <= 5) And (TrainingSound2.RESP <> "") Then
> Goto Label4 (where Label 4 was placed before the Start Screen)
>Else
> toneCount = 0
>End If
Indeed, the "... And (TrainingSound2.RESP <> "")" means it will never
stop without a response. To make it stop you need to rewrite that
test as either
If (toneCount <= 5) And (TrainingSound2.RESP <> "") Then
or
If (toneCount <= 5) And (TrainingSound2.RESP = "{SPACE}") Then
Pay close attention to the differing use of = vs. <>, and "" vs.
"{SPACE}". This first example will exit the loop for *any* key
press, the second example will exit only for a *space* key.
Now, it sounds like, after the program plays five tones without a
response, you want it to skip the movie. If that is correct then ...
well, let's review the experiment structure first so we have
something to refer to (thanks for posting that). Here is how I
understand your experiment structure, with a few names changed to
suit my tastes:
- TrialList (this contains your three trials)
- TrialProc
- StartScreenLabel
- StartScreen (where you press a button to proceed to the trial)
- TrainingSound1
- TrainingSound2
- TrialResponseScript
- MovieLabel
- Movie
- NoMovieLabel
Now we have three possible outcomes: repeat the loop, play the
movie, or skip the movie and go right to the next trial. We need to
rearrange the logic of TrialResponseScript a bit, maybe something
like this (again, some renaming and commenting to suit my tastes):
toneCount = toneCount + 1
If TrainingSound2.RESP <> "" Then ' stop for any response
toneCount = 0 ' reset counter for next time
Goto MovieLabel
ElseIf toneCount <= 5 Then
Goto StartScreenLabel ' repeat the training loop
Else ' completed 5 loops with no response
toneCount = 0 ' reset counter for next time
Goto NoMovieLabel ' no response, so skip the movie
End If
There might be a better way to arrange that (makes me nervous to have
put same the counter reset in two branches), but that's enough
thinking for now.
Oops, I misread that the first time. The "... And (TrainingSound2.RESP <>
"")" really means that it will repeat the training sounds *only* if there
*is* a response *and* it has not yet done it five times. But this does not
correspond to the behavior that you report, so I suspect that the first
line of script was mis-copied. No matter, as by now you no doubt have your
program working with the help you've gotten.
Regards,
-- David McFarlane, Professional Faultfinder, trying to correct the record