WHILE-WEND/de

From MCS Wiki AVR
< WHILE-WEND
Revision as of 01:46, 17 February 2013 by Stefanhamburg (Talk | contribs)
Jump to: navigation, search

Funktion =

Führt eine Folge von Anweisungen in einer Schleife aus solange eine Bedingung wahr ist.

 

 

Contents

Syntax

WHILE condition

 statements

WEND

 

 

Remarks

If the condition is true then any intervening statements are executed until the WEND statement is encountered.

BASCOM then returns to the WHILE statement and checks the condition.

If it is still true, the process is repeated.

If it is not true, execution resumes with the statement following the WEND statement.

 

So in contrast with the DO-LOOP structure, a WHILE-WEND condition is tested first so that if the condition fails, the statements in the WHILE-WEND structure are never executed.

 

 

See also

DO-LOOP

 

 

Example


'-----------------------------------------------------------------------------------------
'name : while_w.bas
'copyright : (c) 1995-2005, MCS Electronics
'purpose : demo: WHILE, WEND
'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 var
While A < 10 'test expression
Print A 'print var
Incr A 'increase by one
Wend 'continue loop
End

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