View Full Version : REPEAT loops
codeking
02-01-2007, 11:01 PM
repeat count decreases count once every loop and stops when is gets to zero.· But can I make a loop that loops until I say count = 0?· For example:
REPEAT UNTIL count = 0
·· IF something
······ count = 0
Newzed
02-01-2007, 11:20 PM
Yes.· For example:
PUB writestr | p···
··· p := 0
··· print_string(string(13,13,"· Enter starting address to read:· "))
··· repeat until· (msg[p] :=key.getkey) == 13
····· print(msg[p++])
··· print(13)
··· sendstr(@msg)
··· print(cls)
Sid
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Sid Weaver
Don't have VGA?
Newzed@aol.com (mailto:Module?Newzed@aol.com)
·
Mike Green
02-01-2007, 11:29 PM
codeking,
Here are a couple of examples:
repeat count 'this sets a maximum # times
if something
quit 'exit the loop if something is true
repeat until count == 0 'use "==" here instead of "="
if something
count := 0 ' use ":=" here instead of "="
asterick
02-01-2007, 11:35 PM
codeking said...
repeat count decreases count once every loop and stops when is gets to zero. But can I make a loop that loops until I say count = 0? For example:
REPEAT UNTIL count = 0
IF something
count = 0
Also a cute trick to remember is:
repeat while count
if something
quit
Since Non-zero is considered true. Saves you a logical comparison. (This was done in one of the examples)
Great for things like
repeat while LOCKSET(myLock) ' Halt for semaphor