Repeat command blocks

Michiel Spape Michiel.Spape at nottingham.ac.uk
Tue Jan 11 16:58:21 UTC 2011


Ha,
Sorry to other people whom I haven't replied to yet. I saw loads of code and my flu told my brain that I shouldn't bother. Perhaps the flu is rampant at the PST headquarters too? Anyway, this however, we have sorted out quickly.

DIM I as INTEGER
IF c.GetAttrib("bet") = 1 THEN
	FOR I = 1 to 5
		WritePort &H378,64
		sleep 5
		WritePort &H378,0
		sleep 5
	NEXT I 'thus repeats 5 times
ELSE
	FOR I = 1 to 5
		WritePort &H378,64
		sleep 10
		WritePort &H378,0
		sleep 10
	NEXT I 'thus repeats 5 times
END IF

There's prettier ways to code this, such as
Dim I as integer
FOR I = 1 to 5
	WritePort &H378,64
	sleep cInt(c.GetAttrib ("bet")) * 5
	WritePort &H378,0
	sleep cInt(c.GetAttrib ("bet")) * 5
	NEXT I 'thus repeats 5 times
NEXT I

But one might question the soundness of why you'd want this in the first place, but there you go. (as an aside to David: I'm going for tab indentation, you can see windows has set that to 6 spaces, but I'm addicted to emacs style tab indentation)
Cheers,
Mich


Michiel Spapé
Research Fellow
Perception & Action group
University of Nottingham
School of Psychology
www.cognitology.eu


-----Original Message-----
From: e-prime at googlegroups.com [mailto:e-prime at googlegroups.com] On Behalf Of jens
Sent: 11 January 2011 16:39
To: E-Prime
Subject: Repeat command blocks

Hello

Does anyone have an idea on how to repeat a block of commands a number
of times? I have gone through the E-Basic but I can't get the
Do...Loop or For...Next commands to work for me.

Example:

IF c.getAttrib("bet") = 1 THEN
WritePort &H378,64
sleep 5
WritePort &H378,0
sleep 5

*repeat 5 times

ELSEIF c.getAttrib("bet") = 2 THEN
WritePort &H378,64
sleep 10
WritePort &H378,0
sleep 10

*repeat 5 times

END IF

-- 
You received this message because you are subscribed to the Google Groups "E-Prime" group.
To post to this group, send email to e-prime at googlegroups.com.
To unsubscribe from this group, send email to e-prime+unsubscribe at googlegroups.com.
For more options, visit this group at http://groups.google.com/group/e-prime?hl=en.

This message and any attachment are intended solely for the addressee and may contain confidential information. If you have received this message in error, please send it back to me, and immediately delete it.   Please do not use, copy or disclose the information contained in this message or in any attachment.  Any views or opinions expressed by the author of this email do not necessarily reflect the views of the University of Nottingham.

This message has been checked for viruses but the contents of an attachment
may still contain software viruses which could damage your computer system:
you are advised to perform your own checks. Email communications with the
University of Nottingham may be monitored as permitted by UK legislation.

-- 
You received this message because you are subscribed to the Google Groups "E-Prime" group.
To post to this group, send email to e-prime at googlegroups.com.
To unsubscribe from this group, send email to e-prime+unsubscribe at googlegroups.com.
For more options, visit this group at http://groups.google.com/group/e-prime?hl=en.



More information about the Eprime mailing list