DO-LOOP/de

(Difference between revisions)
Jump to: navigation, search
((**COPIED FROM ENGLISH PAGE**) =)
(Remarks)
Line 19: Line 19:
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
= <span class="f_Header">Remarks</span> =
+
= <span class="f_Header">Anmerkungen</span> =
  
You can exit a DO..LOOP with the EXIT DO statement.
+
Man kann eine DO..LOOP mit EXIT DO verlassen.
  
The DO-LOOP is always performed at least once.
+
Die DO-LOOP Schleife wird immer mindestens einmal ausgeführt.
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
The main part of your code can best be executed within a DO.. LOOP.
+
Der Haupt-Teil eines BASCOM-Programms sollte normalerweise in einer DO..LOOP Endlosschleife ausgeführt werden.
  
You could use a GOTO also but it is not as clear as the DO LOOP.
+
Man könnte auch GOTO benutzen aber das ist nicht so klar wie DO..LOOP.
  
 
Main:
 
Main:
  
' &nbsp;code
+
'Code
  
 
GOTO Main
 
GOTO Main
Line 47: Line 47:
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
Of course in the example above, it is simple to see what happens, but when the code consist of a lot of lines of code, it is not so clear anymore what the GOTO Main does.
+
Natürlich ist es im obigen Beispiel einfach, zu sehen was passiert aber wenn das Programm aus vielen Zeilen Code besteht dann ist es nicht mehr so klar was GOTO Main bewirken soll.
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>

Revision as of 02:08, 17 February 2013

Contents

Action

Wiederholt einen Block von Befehlen bis die Bedingung wahr ist.

 

 

Syntax

DO

 statements

LOOP [ UNTIL expression]

 

 

Anmerkungen

Man kann eine DO..LOOP mit EXIT DO verlassen.

Die DO-LOOP Schleife wird immer mindestens einmal ausgeführt.

 

Der Haupt-Teil eines BASCOM-Programms sollte normalerweise in einer DO..LOOP Endlosschleife ausgeführt werden.

Man könnte auch GOTO benutzen aber das ist nicht so klar wie DO..LOOP.

Main:

'Code

GOTO Main

 

Do

'Code

Loop

 

Natürlich ist es im obigen Beispiel einfach, zu sehen was passiert aber wenn das Programm aus vielen Zeilen Code besteht dann ist es nicht mehr so klar was GOTO Main bewirken soll.

 

 

See also

EXIT , WHILE-WEND , FOR-NEXT

 

 

Example


'-----------------------------------------------------------------------------------------
'name : do_loop.bas
'copyright : (c) 1995-2005, MCS Electronics
'purpose : demo: DO, LOOP
'micro : Mega48
'suited for demo : yes
'commercial addon needed : no
'-----------------------------------------------------------------------------------------
 
$regfile = "m48def.dat" ' specify the used micro
$crystal = 4000000 ' used crystal frequency
$baud = 19200 ' use baud rate
$hwstack = 32 ' default use 32 for the hardware stack
$swstack = 10 ' default use 10 for the SW stack
$framesize = 40 ' default use 40 for the frame space
 
Dim A As Byte
 
A = 1 'assign a var
Do 'begin a do..loop
Print A 'print var
Incr A 'increase by one
Loop Until A = 10 'do until a=10
End
 
'You can write a never-ending loop with the following code
Do
'Your code goes here
Loop

Languages   English Deutsch  
Personal tools
Namespaces
Variants
Actions
Navigation
In other languages
Language