User Tools

Site Tools


basic

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
basic [2020/04/16 18:16]
smj
basic [2020/04/18 01:39] (current)
smj
Line 18: Line 18:
 ====== BASIC Programming Examples ====== ====== BASIC Programming Examples ======
  
-There are many statements available to you in BASIC, but here are a few that can get you started and will work across many BASIC interpreters.  Check out the BASIC Reference Manuals section below for all the statements available for a particular system.  Statement names and syntax can vary a bit. These examples are run under [[unix_survival|UNIX System V]] on the [[lcm3b2|AT&T 3B2 1000-70]] using the Bell Labs BASIC interpreter, but are generic enough to run on any of the BASIC systems available.+There are many statements available to you in BASIC, but here are a few that can get you started and will work across many BASIC interpreters.  Check out the BASIC Reference Manuals section below for all the statements available for a particular system.  Statement names and syntax can vary a bit. These examples are run under [[unix_survival|UNIX System V]] on the [[at_t_3b2_1000-70|AT&T 3B2 1000-70]] using the Bell Labs BASIC interpreter, but are generic enough to run on any of the BASIC systems available.
  
       UNIX System V  R.3 (WINS) (lcm3b2)       UNIX System V  R.3 (WINS) (lcm3b2)
Line 42: Line 42:
      *print a      *print a
       1        1 
-      +           
      * REM *** STRINGS are quoted in BASIC and to use a variable as a string, just append '$' to it      * REM *** STRINGS are quoted in BASIC and to use a variable as a string, just append '$' to it
      *print "Hello World!"      *print "Hello World!"
Line 49: Line 49:
      * print a$      * print a$
      Hello World!      Hello World!
-     +          
      * REM *** Now let's write it as a program with line numbers      * REM *** Now let's write it as a program with line numbers
      *10 print "Hello World!"      *10 print "Hello World!"
      *20 end      *20 end
 +     
      * REM *** The LIST command will show us what we typed in      * REM *** The LIST command will show us what we typed in
      *list      *list
      10 print "Hello World!"      10 print "Hello World!"
      20 end      20 end
-     +          
      * REM *** The RUN command will run our program      * REM *** The RUN command will run our program
      *run      *run
Line 161: Line 161:
       1        1 
       0        0 
 +           
 +     * REM *** Here is an advanced example which will introduce nested FOR loops
 +     * REM *** and the function INT (integer) and SIN (sine) to calculate a sine wave
 +     
 +     *list
 +     10 let w = 2  
 +     15 let h = 20
 +     20 let t = 6.28318/h  
 +     25 let s = 35
 +     30 for i = 1 to w
 +     35 for j = 0 to 6.38318 - t step t  
 +     40 let a = int(sin(j) * s + 0.5)  
 +     45 for k = 1 to s + a
 +     50 print " ";
 +     55 next k
 +     60 print "+"  
 +     65 next j
 +     70 next i
 +     *run
 +                                        +
 +                                                   +
 +                                                             +
 +                                                                    +
 +                                                                         +
 +                                                                           +
 +                                                                         +
 +                                                                    +
 +                                                             +
 +                                                   +
 +                                        +
 +                             +
 +                   +
 +            +
 +       +
 +     +
 +       +
 +            +
 +                   +
 +                             +
 +                                        +
 +                                                   +
 +                                                             +
 +                                                                    +
 +                                                                         +
 +                                                                           +
 +                                                                         +
 +                                                                    +
 +                                                             +
 +                                                   +
 +                                        +
 +                             +
 +                   +
 +            +
 +       +
 +     +
              
      * REM *** To return back to UNIX, type the command "SYSTEM"      * REM *** To return back to UNIX, type the command "SYSTEM"
Line 168: Line 223:
 ====== BASIC Reference Manuals ====== ====== BASIC Reference Manuals ======
  
-  * Control Data Corporation BASIC(([[http://bitsavers.trailing-edge.com/pdf/cdc/cyber/lang/basic/19980300B_BASIC_Language_Version_2_Reference_Nov74.pdf|CDC Basic v2 Reference]]))+Visit our repository for [[https://livingcomputers.org/Computer-Collection/Online-Systems/User-Documentation.aspx|User Documentation for Online Systems]] for formal user and reference manual. 
  
  
basic.1587060974.txt.gz · Last modified: 2020/04/16 18:16 by smj