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.

IF...THEN...ELSEIF...ELSE...ENDIF<br />

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

if expression then label<br />

if expression then goto label<br />

if expression then gosub label<br />

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

if expression then<br />

...code...<br />

endif<br />

if expression then<br />

...code...<br />

else<br />

...code...<br />

endif<br />

if expression then<br />

...code...<br />

elseif expression<br />

...code...<br />

endif<br />

if expression then<br />

...code...<br />

elseif expression<br />

...code...<br />

else<br />

...code...<br />

endif<br />

Supported<br />

• BA - Supported<br />

• BAN - Supported<br />

• BAP - Supported<br />

• BAP40 - Supported<br />

Commands<br />

Description<br />

IF..THEN commands are the decision makers of M<strong>Basic</strong>. IF..THEN evaluates a condition to determine<br />

if it is true. If you want to test the value of a variable against another variable or a known value, you<br />

would use the IF..THEN commands. When the results are true, the code after THEN is executed.<br />

If it returns false, the code after THEN will be ignored. A simple example would be to increment a<br />

variable in a loop and each time through the loop test if the variable equals 10. This lets us control<br />

how many times through the loop we want to run. We can also test if our variable is greater than, less<br />

than or not equal too. Several math expressions can be used for the test condition.<br />

main<br />

if temp = 10 then label<br />

goto main<br />

125

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

Saved successfully!

Ooh no, something went wrong!