109
BASIC Includes Visual BASIC, VB.net, QuickBasic, PowerBasic, GW Basic, PowerBASIC and the BASIC Programming Language Shane Estavillo Jeffrey James Valerio

BASIC Programming Language

Embed Size (px)

Citation preview

BASICIncludes Visual BASIC, VB.net, QuickBasic,

PowerBasic, GW Basic, PowerBASIC and the

BASIC Programming Language

Shane Estavillo

Jeffrey James Valerio

BASICeginner

’sll Purposeymbolic

nstructionode

It is a family of high-level programming languages, in other words, a multi

platform language.

One of the earliest and simplest high-level languages with commands

similar to English. It can be learned with relative ease even by

schoolchildren and novice programmers.

It is in widespread use but has gotten little respect.

BASIC

The language was based partly on the FORTRAN IV and partly on the ALGOL 60, with additions to make it suitable for timesharing.

FORTRAN IV (1962)

ALGOL 60 (1960

BASIC (1964)

Genealogy of BASIC

The language was based partly on the FORTRAN IV and partly on the ALGOL 60, with additions to make it suitable for timesharing.

BASIC

(1964)

QuickBASIC(1988)

Visual BASIC (1990)

BASIC was first implemented on

the GE-265 mainframe which

supported multiple terminals.

Original BASIC Language

OverviewVery small and oddly, was not interactive.

No means of getting input data from terminal.

Programs were typed in, compiled and run, in sort of batch-oriented way.

Had only 14 different statement types and a single data type, floating point, referred to as “numbers”.

Overall, it was very limited language though quite easy to learn.

Significant Language

Features

Loops

Input from the keyboard

Menu Driven Applications

System Commands - These are words

that make the system perform a

specific task immediately.

Significant Language

FeaturesUser-Defined Functions

Arrays, sorting, and searches

Areas of Application

BASIC has many strong points, such as:

Easy to learn for beginners

Structured Programming

Subroutines

Built-In Functions

Significant Language

FeaturesAdds powerful additional features for

the advanced user

Is designed for interactive use rather

than batch work

Lends itself to learning by hands-on

practical use

and is therefore suitable for both the

professional and non-professional.

The goals of the system were:

1. It must be easy for non-science

students to learn and use.

2. It must be pleasant and friendly.

3. It must provide fast turnaround for

homework.

4. It must allow free and private access.

5. It must consider user time more

important than computer time.

The eight design principle of

BASIC:1. Be easy for beginners to use.

2. Be a general-purpose programming language.

3. Allow advanced features to be added for experts (while keeping the language simple for beginners).

4. Be interactive.

5. Provide clear and friendly error messages.

6. Respond quickly for small programs.

7. Not to require an understanding of computer hardware.

8. Shield the user from the operating system.

Evaluation and Criticisms

Poor structure of programs written in it.

Early versions were not meant for serious programs of any significant size, though later versions can handle such tasks.

Edsger W. Djikstra, a highly-respected computer proffessional that the use of GoTo statements, particularly in BASIC, promoted poor programming practices.

BASIC is too slow.

Then why BASIC is

successful?Ease with which it can be learned and

the ease with which it can be

implemented, even on very small

computers.

The original

BASIC was

designed in 1964

by John George

Kemeny (right)

and Thomas

Eugene Kurtz

(left) at Dartmouth

College (now

Dartmouth

University) in New

Hampshire, USA

Brief History of BASIC

Before the mid-1960s, computers were extremely expensive and used only for special-purpose tasks.

As prices decreased, from research aabs, computing went into commercial use.

Newer computer systems then supportedtime-sharing, a system that allows multiple users or processes to use the CPU and memory.

Brief History of BASIC

In the following years, as other dialects of BASIC appeared, Kemeny and Kurtz’s original BASIC dialect became known as Dartmouth BASIC.

When it was implemented in minicomputers DEC PDP Series and the Data General Nova; HP-Time Shared BASIC System (1960s), BASIC acted merely as an interpreter rather than a compiler.

DEC-PDP

ALTAIR 8800

NOVA

SYSTEM

Brief History of BASIC

It was the introduction of Altair 8800

“kit” microcomputer in 1975 that

provided BASIC a path to

universality.

BASIC provided faster memory

access for audio tapes and suitable

text editors that time.

Brief History of BASIC

In order to promote the language, it

was available FREE OF CHARGE.

One of the first to appear was the Tiny

Basic originally written by Li-Chen

Wang, a simple BASIC

implementation. For 8080 machines

like the Altair.

Brief History of BASIC

MITS then released Altair BASIC,

developed by Bill Gates and Paul

Allen in 1975.

Microsoft BASIC (widely known as

MBASIC or M BASIC)was soon

bundled with an original floppy disk

based CP/M computers.

Brief History of BASIC

The Atari 8-bit family had their own

Atari BASIC that was modified in order

to fit on 8 kB ROM cartridge.

The BBC published BBC BASIC,

developed for them by Acorn

Computers Ltd, incorporating many

extra structuring keywords.

Atari BASIC

Brief History of BASIC

As early as 1979 Microsoft was in

negotiations with IBM to supply them

with a version of BASIC. Microsoft

sold several versions of BASIC for

MS-DOS/ PC-DOS including BASICA,

GW-BASIC (a BASICA-compatible

version that did not need IBM's ROM)

and QuickBASIC.

Brief History of BASIC

IBM BASIC UI

Brief History of BASIC

Turbo Pascal & Turbo C++-publisher

Borland published Turbo BASIC 1.0 in

1985 (successor versions are still

being marketed by the original author

under the name PowerBASIC).

Brief History of BASIC

These languages introduced many

extensions to the original home

computer BASIC, such as improved

string manipulation and graphics

support, access to the file system and

additional data types. More important

were the facilities for structured

programming, including additional

control structures and proper

subroutines supporting local variables.

The Shift of BASIC into Visual

BASICThe Visual BASIC introduced by

Microsoft is difficult to consider to be

really the original BASIC, since of its

major shift towards being object-

oriented and event-driven in

perspective.

VB Version 3.0 is widely considered

the first relatively stable version.

Basic BASIC Syntax

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.

Program flow control

GOSUB: jumps to a numbered or labelled line, executes the code it finds there, but upon encountering the RETURN Command, it jumps back to the line following the line from which the jump occurred. This is used to implement subroutines.

ON ... GOTO/GOSUB: chooses where to jump based on the specified conditions. See Switch statement for other forms.

DEF FN: 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 subroutines, with a syntax on the model of DEF FND(x) = x*x at the beginning of a program. Function names were restricted to FN+oneletter.

I/O: 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 Syntax

REM: holds a programmer's comment or REMark; often used to give a title to the program and to help identify the purpose of a given section of code.

USR: transfers program control to a machine language subroutine, usually entered as an alphanumeric string or in a list of DATA statements.

TRON: turns on a visual, screen representation of the flow of BASIC commands by displaying the number of each command line as it is run. The TRON command, largely obsolete now, stood for, TRace ON. This meant that command line numbers were displayed as the program ran, so that the command lines could be traced. This command allowed easier debugging or correcting of command lines that caused problems in a program.

Miscellaneous Syntax

Problems included a program terminating without providing a desired result, a program providing an obviously erroneous result, a program running in a non-terminating loop, or a program otherwise having a non-obvious error. (The command TRON has also entered popular cultural with the name of the 1982 Disney movie, "TRON," with a subsequent movie, "TRON: Legacy," a television series, "TRON: Uprising," and two video games, "TRON: Legacy," and "TRON:Evolution." In each of these entertainments the TRON command is personified as a character that battles against evil elements in programs.)

TROFF: turns off the display of the number of each command line as command lines run after the command TRON has been used.

DATA TYPES AND VARIABLES

Minimal versions of BASIC had only integer variables and one-letter variable names. More powerful versions had floating-point arithmetic, and variables could be labelled with names six or more characters long.

String variables are usually distinguished in many microcomputer dialects by having $ suffixed to their name, and string values are typically enclosed in quotation marks.

Arrays in BASIC could contain integers, floating point or string variables.

Some dialects of BASIC supported matrices and matrix operations, useful for the solution of sets of simultaneous linear algebraic equations. These dialects would support matrix operations such as assignment, addition, multiplication (of compatible matrix types), and evaluation of a determinant. Microcomputer dialects often lacked this data type and required a programmer to provide subroutines to carry out equvalent operations.

BASIC (PROGRAMMING LANGUAGE) IS AN EARLIER VERSION OF VISUAL BASIC. VB IS MODIFIED FOR PC USER U CAN SAY IT IS A GUI VERSION OF BASIC.

Sample

BASIC

Implementatio

n

The next set of

discussions are

directly based on

the Original

Manual of the

BASIC

Programming

Language

designed for use

in the Darthmouth

Time-Sharing

System.

BASIC Programming

Observations

s

Expressions, Numbers and

Variables

Expressions, Numbers and

Variables

Expressions, Numbers and

Variables

Expressions, Numbers and

Variables

Expressions, Numbers and

Variables

Expressions, Numbers and

Variables

Parentheses

LET Function

Read and Data Functions

PRINT Functions

Print Functions

GO TO (Looping) & If-Then

GO TO (Looping) & If-Then

FOR and Next

FOR and Next

END Function

Revising Errors

Types of BASIC

Unstructured BASIC

Structured BASIC

Object-Oriented BASIC or Visual

BASIC

Unstructured BASIC

These are the first-generation BASIC languages such as MSX BASIC and GW BASIC.

Most support:

Simple Data Types

Loop Cycles

Arrays

10 PRINT "Hello World! "

20 GOTO 10

Sample Program for GW

BASIC

Hello World !Hello World! Hello World!

Hello World! Hello World! Hello World!

Hello World! Hello World! Hello World!

Hello World! Hello World! Hello World!

Hello World! Hello World! Hello World!

Hello World! Hello World! Hello World!

Hello World! Hello World! Hello World!

Hello World! Hello World! Hello World!

Hello World! Hello World! Hello World!

Hello World! Hello World! Hello World!

Hello World! Hello World! Hello World!

Hello World! Hello World! Hello World!

Hello World! Hello World! Hello World!

Hello World! Hello World! Hello World!

Hello World! Hello World! Hello World!

Hello World! Hello World! Hello World!

10 PRINT "Hello World! "

20 GOTO 10

This program prints the phrase “Hello

World! “ infinitely.

Sample Program for GW

BASIC

10 INPUT "ENTER TWO NUMBERS SEPARATED BY A COMMA:

20 LET S = N1 + N2

30 LET D = N1 - N2

40 LET P = N1 * N2

50 LET Q = N1 / N2

60 PRINT "THE SUM IS ", S

70 PRINT "THE DIFFERENCE IS ", D

80 PRINT "THE PRODUCT IS ", P

90 PRINT "THE QUOTIENT IS ", Q

100 END

Sample Program for GW

BASIC

ENTER TWO NUMBERS SEPARATED BY A COMMA:

THE SUM IS 6

THE DIFFERENCE IS 2

THE PRODUCT IS 8

THE QUOTIENT IS 2

Structured BASIC

Second Generation BASICs are structured and procedure-oriented programming.

Line numbering is omitted and then replaced with labels for GoTo and procedure.

QuickBASIC and PowerBASIC are examples.

Sample PowerBASIC

ProgramFunction PBMain

Print "Hello, World!"

Waitkey$

End Function

Sample QuickBASIC Program

#COMPILE EXE

Function PBMain() as Long

MsgBox "Hello World"

End Function

BASIC with Object-Oriented

featuresThird generation BASIC dialects such

as Visual Basic and StarOffice Basic

introduced features to support object-

oriented and event-driven

programming paradigm.

Most built-in procedures and functions

now represented as methods of

standard objects rather than operators

.

Visual BASIC

Visual basic is derived form the BASIC programming languages, it is a Microsoft window programming language, visual basic program are created in an integrated development environment (IDE), which allows the programmer to create run and design visual basic programs conveniently it’s also allow a programmer to create working programs in a fraction of time that normally takes to code programs without using IDES.

Visual BASIC

The wide spread use of BASIC Language with various types of computer (sometimes called hardware platform) led to many enhancement to the languages with the development of Microsoft windows graphical user interface (GUI) in the late 1980’s and the early 1990’s, the natural evolution of basic was visual basic which was created by Microsoft corporation in 1991.

Procedural BASIC: True

BASICTrue BASIC, C, Fortran, and Pascal are examples of procedural languages. Procedural languages change the state or memory of the machine by a sequence of statements. True BASIC is similar to F (a subset of Fortran 90) and has excellent graphics capabilities which are hardware independent. True BASIC programs can run without change on computers running the Macintosh, Unix, and Windows operating systems. We will consider version 3.0 (2.7 on the Macintosh) of True BASIC. Version 5 includes the ability to build objects such as buttons, scroll bars, menus, and dialog boxes. However, because we wish to emphasize the similarity between True BASIC and other procedural languages such as C, F, and Java, we do not consider these features.

Procedural BASIC: True

BASICPROGRAM product

! taken from Chapter 2 of Gould & Tobochnik

LET m = 2 ! mass in kilograms

LET a = 4 ! acceleration in mks units

LET force = m*a ! force in Newtons

PRINT force

END

Procedural BASIC: True

BASICThe features of True BASIC included

in the above program include:

The first statement is an optional

PROGRAM header. The inclusion of a

program header is good programming

style.

Procedural BASIC: True

BASICComment statements begin with ! and

can be included anywhere in the

program.

PROGRAM, LET, PRINT, and END

are keywords (words that are part of

the language and cannot be

redefined) and are given in upper

case. The case is insignificant (unlike

C, F, and Java). The DO FORMAT

command converts keywords to upper

case.

Procedural BASIC: True

BASICThe LET statement causes the expression to the right of the = sign to be evaluated and then causes the result to be assigned to the left of the = sign. (The LET statement reminds us that the meaning of the = symbol is not the same as equals.) It is not necessary to type LET, because the DO FORMAT command automatically inserts LET where appropriate. The LET statement can be omitted if the OPTION NOLET statement is included.

Procedural BASIC: True

BASICTrue BASIC does not distinguish between integer numerical variables and floating point numerical variables and recognizes only two types of data: numbers and strings (characters). The first character of a variable must be a letter and the last must not be an underscore.

The PRINT statement displays output on the screen.

The last statement of the program must be END.

Sample True BASIC with

inputPROGRAM product2

INPUT m

INPUT prompt "acceleration a (mks

units) = ": a

LET force = m*a ! force

in Newton's

PRINT "force (in Newtons) ="; force

END

Visual BASIC

Visual basic is the worlds most widely use RAD language, (Rapid Application Development (RAD) is the process of rapidly creating an application. Visual Basic provide a powerful features such as graphical user interface, events handling assess to Win 32 API, object-oriented features, error handling, structured programming and much more. Not until Visual Basic appeared, developing Microsoft windows based application was a difficult and cumbersome process. Visual basic greatly simplifies window application development. The advantages of visual basic programming language

Visual BASIC

VB 1.0 was introduced in 1991. The drag

and drop design for creating the user

interface is derived from a prototype form

generator developed by Alan Cooper and

his company called Tripod. Microsoft

contracted with Cooper and his

associates to develop Tripod into a

programmable form system for Windows

3.0, under the code name Ruby (no

relation to the Ruby programming

language).

Visual BASIC Features

Visual Basic gives a disciplined approach to writing programs that are clearer than unstructured programs, easier to test, debug and can be easily modify.

It allows for the creation of powerful and professional looking application with less time and coding. It allows for strong typing i.e. has wide variety of input data types and support Rapid Application Development (RAD).

Visual BASIC Features

It has a complete edifying and debugging facilities and has the ability to generate a Dynamic Link Libraries (DLL`S), it allows for easier management of document and it is easy to learn.

Visual Basic is a complete form of package for building user interface

Visual basic is a fairly easy language to pick up. However, it is generally not used to make very large applications. VB was also created for MS Windows.

Sample VB Program

Private Sub Form_Load()

' Execute a simple message box

that says "Hello, World!"

MsgBox "Hello, World!"

End Sub

Visual Basic Timeline

REMEMBER

Please do not be mistaken by BASIC and Visual BASIC.

BASIC (PROGRAMMING LANGUAGE) IS AN EARLIER VERSION OF VISUAL BASIC.

Visual BASIC is MODIFIED for personal computer users, so we can say that it is a GUI VERSION of BASIC.

Prepared by:

Jeffrey James L. Valerio

Shane Estavillo