Go To Index
List of Basic Commands and Statements
Basic Commands:
These are some standard Commands of GW BASIC:Definition: Keywords which are written without line number are called Basic commands. They are used in direct mode.
- List: To list all or part of a program to the screen, line printer, or file.
- Run: To execute the program currently in memory, or to load a file from the diskette into memory and run it.
- Load: To load a file from diskette into memory.
- Save: To save a program file on diskette.
- Auto: To generate and increment line numbers automatically each time you press the RETURN key.
- CLEAR: To set all numeric variables to zero, all string variables to null, and to close all open files. Options set the end of memory and reserve the amount of string and stack space available for use by GW-BASIC.
- Delete: To delete program lines or line ranges.
- New: To delete the program currently in memory and clear all variables.
- Files: To print the names of the files residing on the specified drive.
- Kill: To delete a file from a disk.
- Renum: To renumber program lines.
- Edit: To display a specified line, and to position the cursor under the first digit of the line number, so that the line may be edited.
- System: Close GW-Basic
Basic Statements:
These are some standard Statements of GW Basic:Definition: Keywords which are written with line numbers are called Statements. They are used in in-direct mode.
- CLS: To clear the screen.
- PRINT: To output a display to the screen.
- LPRINT: To print data at the line printer.
- END: To terminate program execution, close all files, and return to command level.
- REM: To allow explanatory remarks to be inserted in a program.
- INPUT: To prepare the program for input from the terminal during program execution.
- LET: To assign the value of an expression to a variable.
- ON-GOTO: To branch to one of several specified line numbers, depending on the value returned when an expression is evaluated.
- IF - THEN: To make a decision regarding program flow based on the result returned by an expression.
- LOCATE: To move the cursor to the specified position on the active screen.
- FOR – NEXT: To execute instructions a specified number of times in a loop.
- Read: To read values from a DATA statement and assign them to variables.
- Data: To store the numeric and string constants that are accessed by the program READ statement(s).
- TIME$: To set or retrieve the current system time.
- DATE$: To set or retrieve the current system date.
- DIM: To specify the maximum values for array variable subscripts and allocate storage accordingly.
OR
Important Commands for GW Basic and Flow Chart
Locate: is use to move the cursor to specified row and column.
Syntax: Locate <row>, <column>
Note: Locate statement is used with INPUT and PRINT statement.
Default Screen:-
- Text Screen / Screen 0
- No. of rows 0-24 = 25
- No. of columns 0-79 = 80/2 = 40
- available rows- 24/2 = 12
Tab: It is use to print the data at a specified column.
Syntax: Tab(column)
Note: This function is only with Print Statement.
Default Screen:-
- Text Screen / Screen 0
- No. of rows ?
- No. of columns 0-79 = 80/2 = 40
Calculation of Meter Reading:
Input: Meter number, Previous reading, Present reading.
Calculation: Unit consumed = Present reading - Previous reading
Amount Changed = Unit consumed
Output = Meter number, Previous reading, Present reading, Unit consumed, Amount Changed
Counter: is a process that is use to generate sequence of number by addition or subtraction. -- 00 is initial value.
- Natural number (1 - so on) (+2)
- Even number (2, 4, 6, 8, 10) (+2)
10 CLS
20 Let A=0
30 Let A=A+2 - Odd number (1, 3, 5, 7, 9) (-1 Initial)
10 CLS
20 Let A=-1
30 Let A=A+2 - Whole number (0, 1 - so on) (-1 Initial)
10 CLS
20 Let A=-1
30 Let A=A+2 - Descending number (10, 9, 8, 7, 6, 5, 4, 3, 2, 1) National number (In natural numbers 1 to 10 or from any value we can start it as an initial value.
Even (D) (10, 8, 6, 4, 2) 12 initial values
Odd (D) (9, 7, 5, 3, 1) 12 initial values
Whole (0, 1, 2 - so on) 12 initial values
Syntax: IV = IV(+/- ) value
A = A + 1 | A |
A = A + 2 | 0 |
A = A + 2 | -1 |
A = A + 1 | -1 |
Go Statement: is use to branch unconditionally
Syntax: Go to (Line number)
If ......... then ......... ELSE : is a conditional statement that is use to create condition in a program
If (condition) Then (condition) Else (condition)
If (clause) Then (clause) Else (clause)
If A=10 Then (END) Else Goto 30.
10 CLS: Print Tab(25) "Sequence of Natural Number" up till 10
20 Let A=0
30 Let A=A+1
40 Print TAB (40) A
50 If A=0 then END
60 Goto 30
Loop: Any process that is repeated more than one is called Loop.
Types Of Loops:
- Conditional Loop
- Unconditional Loop
Unconditional Loop : Any process that is repeated
No comments:
Post a Comment