04.03.2013 Views

Basic Micro Studio Syntax Manual

Basic Micro Studio Syntax Manual

Basic Micro Studio Syntax Manual

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

WHILE - WEND<br />

<strong>Syntax</strong><br />

while condition<br />

program statements<br />

wend<br />

• Condition - can be a variable or expression<br />

• Statements - any group of commands to be run inside the loop.<br />

Supported<br />

• BA - Supported.<br />

• BAN - Supported.<br />

• BAP - Supported.<br />

• BAP40 - Supported.<br />

Commands<br />

Description<br />

The WHILE - WEND loop executes commands nested inside of it while some condition is true. The<br />

condition is tested before the WHILE - WEND loop is run. This is opposite of DO - WHILE which will<br />

test the condition for true after running once. The condition can be any variable or expression and is<br />

tested every loop until false. A simple example would be using the WHILE - WEND loop to test the<br />

state of an input pin. If the pin is low “go do something” until pin is high.<br />

Notes<br />

1. In the programming world 0 is considered false. By default WHILE - WEND will test this condition.<br />

If a stand alone variable is used for the test the loop will continue until its value equals 0.<br />

2. WHILE - WEND checks the condition fi rst. If the condition is false the WHILE - WEND statements<br />

and all program code nested within them will not run.<br />

3. You can nest multiple WHILE - WEND commands within each other. However, you can not nest<br />

DO - WHILE with a WHILE - WEND together or the compiler will get the WHILE statements<br />

confused.<br />

201

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!