Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
BASIC
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
==== Program flow control ==== ; <code>IF ... THEN ... {ELSE}</code> : used to perform comparisons or make decisions. Early dialects only allowed a line number after the <code>THEN</code>, but later versions allowed any valid statement to follow. <code>ELSE</code> was not widely supported, especially in earlier versions. ; <code>FOR ... TO ... {STEP} ... NEXT</code> : repeat a section of code a given number of times. A variable that acts as a counter, the "index", is available within the [[Control flow#Loops|loop]]. ; <code>WHILE ... WEND</code> and <code>REPEAT ... UNTIL</code> : repeat a section of code while the specified condition is true. The condition may be evaluated before each iteration of the loop, or after. Both of these commands are found mostly in later dialects. ; <code>DO ... LOOP {WHILE}</code> or <code>{UNTIL}</code> : repeat a section of code indefinitely or while/until the specified condition is true. The condition may be evaluated before each iteration of the loop, or after. Similar to <code>WHILE</code>, these keywords are mostly found in later dialects. ; <code>[[Goto|GOTO]]</code> : jumps to a numbered or labelled line in the program. Most dialects also allowed the form {{code|GO TO}}. ; <code>GOSUB ... RETURN</code> : jumps to a numbered or labelled line, executes the code it finds there until it reaches a <code>RETURN</code> command, on which it jumps back to the statement following the <code>GOSUB</code>, either after a colon, or on the next line. This is used to implement [[subroutine]]s. ; <code>ON ... GOTO/GOSUB</code> : chooses where to jump based on the specified conditions. See [[Switch statement]] for other forms. ; <code>DEF FN</code> : a pair of keywords introduced in the early 1960s to define functions. The original BASIC functions were modelled on FORTRAN single-line functions. BASIC functions were one expression with variable arguments, rather than [[subroutine]]s, with a syntax on the model of <code>DEF FND(x) = x*x</code> at the beginning of a program. Function names were originally restricted to FN, plus one letter, ''i.e.'', FNA, FNB ...
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)