Introduction to GW
Introduction to GW
Operators – These are special symbols that are used for specific purpose. Operators are of 3
different types in BASIC
1. Arithmetic Operators
2. Logical Operators
3. Relational Operators
Relational Operators are used to perform decision making based on comparison between two
or more quantities.
< Less than
> Greater than
<= Less than or equal to, =< can also be used for the same purpose
>= Greater than or equal to, => can also be used for the same purpose
= Equal to
<> Not equal to
Logical Operators are used to join two or more relational operators in BASIC, There are 3
different types of Logical operators AND, OR, NOT (more of this will be discussed in Chapters
ahead)
System Commands –
NEW – This command is used to start a new program after removing previous ones (if any) from the
primary memory of the computer (RAM)
CLS – This command is used to clear the screen.
AUTO – This command is used to generate automatic line numbers, by default the gap is 10. To
customize the gaps we may use the following format as shown –
EDIT <line number> – This command is used to display any specific line of BASIC program and
correct the errors.
E.g. EDIT 30
The above command will show line number 30 and allow the programmer to edit the same.
LIST – This command is used to display the contents of entire program currently in the primary
memory
Shortcut key: F1
RUN – This command is used to execute the program which is currently residing in the primary
memory
Shortcut key: F2
SAVE – This command is used to save the current program from primary memory (RAM) to the
secondary storage device (Hard Disk)
Syntax: SAVE <filename.bas> (The filename is to be provided within double quotes)
LOAD <filename> – This command is used to load (copy) the program from Hard Disk to primary
memory (RAM)
RENUM – This command is used to re-number the line numbers if they are not in equal intervals
Syntax: RENUM
DELETE <line numbers> – This command is used to delete a line of code from the current program
residing in (RAM)
e.g. DELETE 30
The above command will delete line number 30 from the current program.
KILL <filename> – To delete a program file permanently from Hard Disk
LET Command
In GW-BASIC assignment can be done using LET command as well as direct assignment of
variables without using the LET command. The word assignment means “to store”. Both the
examples are shown below.
Syntax:
LET <variable> = <value>
LET A = 10
PRINT A
PRINT Command
This command is used to generate the output on the screen.
Syntax:
PRINT <list of expression>
If <list of expressions> is omitted, a blank line is displayed.
The Purpose of an INPUT statement is to prepare the program for input from the terminal during
program execution.
INPUT “Enter your age” ; A
IF A>=13 AND A<=19 THEN DISPLAY “TEENAGER” ELSE PRINT “NOT A TEENAGER”