BASIC
In computer programming, BASIC (an acronym which stands for Beginner's All-purpose Symbolic Instruction Code) is a family of high-level programming languages designed to be easy to use.
The following example is written for GW-BASIC, but will work in most versions of BASIC with minimal changes:
10 INPUT "What is your name: ", U$ 20 PRINT "Hello "; U$ 30 INPUT "How many stars do you want: ", N 40 S$ = "" 50 FOR I = 1 TO N 60 S$ = S$ + "*" 70 NEXT I 80 PRINT S$ 90 INPUT "Do you want more stars? ", A$ 100 IF LEN(A$) = 0 THEN GOTO 90 110 A$ = LEFT$(A$, 1) 120 IF A$ = "Y" OR A$ = "y" THEN GOTO 30 130 PRINT "Goodbye "; U$ 140 END
The resulting dialog might resemble:
What is your name: Mike
Hello Mike
How many stars do you want: 7
*******
Do you want more stars? yes
How many stars do you want: 3
***
Do you want more stars? no
Goodbye Mike
**The original Dartmouth BASIC was designed in 1964 by John George Kemeny and Thomas Eugene Kurtz at Dartmouth College in New Hampshire, USA to provide computer access to non-science students. At the time, nearly all use of computers required writing custom software, which was something only scientists and mathematicians tended to do. The language and its variants became widespread on microcomputers in the late 1970s and 1980s.
BASIC remains popular to this day in a handful of highly modified dialects and new languages influenced by BASIC such as Microsoft Visual Basic. In 2006, 59% of developers for the .NET platform used Visual Basic .NET as their only programming language.
Syntax: Typical BASIC keywords
- Data manipulation
- LET: assigns a value (which may be the result of an expression) to a variable.
- DATA: holds a list of values which are assigned sequentially using the READ Command.
- Program flow control
- IF ... THEN ... ELSE: used to perform comparisons or make decisions.
- FOR ... TO ... {STEP} ... NEXT: repeat a section of code a given number of times. A variable that acts as a counter is available within the loop.
- WHILE ... WEND and REPEAT ... UNTIL: repeat a section of code while the specified condition is true. The condition may be evaluated before each iteration of the loop, or after.
- DO ... LOOP {WHILE} or {UNTIL}: repeat a section of code Forever or While/Until the specified condition is true . The condition may be evaluated before each iteration of the loop, or after.
- GOTO: jumps to a numbered or labelled line in the program.
- GOSUB: temporarily jumps to a numbered or labelled line, returning to the following line after encountering the RETURN Command. This is used to implement subroutines.
- ON ... GOTO/GOSUB: chooses where to jump based on the specified conditions. See Switch statement for other forms.
- Input and output
- PRINT: displays a message on the screen or other output device.
- INPUT: asks the user to enter the value of a variable. The statement may include a prompt message.
- TAB or AT: sets the position where the next character will be shown on the screen or printed on paper.
- Miscellaneous
- REM: holds a programmer's comment; often used to give a title to the program and to help identify the purpose of a given section of code.
During my time in school they used to make us write these computer programs in BASIC. Just got curious about it today and decided to look into it. hahaha.. I still remember~~
Comments