GCode Principles and ConceptsI

Document Sample
GCode Principles and ConceptsI Powered By Docstoc
					  Principles and Concepts I
G- Code Learning Group (#3)

          Jonathan Remo
         Mayank Srivastava
           Zhigang Wang

   History of Computer Programming

   Visual Basic Concepts

   Application of Visual Basic
What is a Program?

• Program is a specific set of ordered operations for a computer to perform.

What is a Complier ?

• A special program that processes statements written in a particular programming
  processor uses.
Charles Babbage’s Difference Engine

  The earliest form of a computer language was physical
  The tasks were executed by changing the gears which
  performed the calculations.
Electronic Numerical Integrator (ENIAC)

   Calculations were performed using electrical signals in
   stead of physical motion.
   "Programmed" by presetting switches and rewiring the
   entire system for each new "program" or calculation.
          John Von Neumann

Shared-program technique
Conditional control transfer
   Conditional control transfer the brought about the idea computer code
    should be able to branch based on logical statements such as IF
    (expression) THEN, and looped such as with a FOR statement.
   Conditional control transfer also gave rise to the idea of libraries.
                 Short Code

Short Code was the first computer language for
electronic devices.
Required the programmer to change its statements into
0's and 1's by hand.
Grace Hooper and the Complier

A compiler is a program that turns the language's
statements into 0's and 1's for the computer to understand.
Lead to faster programming
                    Auto Code

The AutoCode-compiler, which compiles symbolic assembler
language on a Manchester Mark I computer.

The first of the major languages.
Developed by IBM for scientific computing.
Language included IF, DO, and GOTO statements.
The basic types of data in use today got their start in
FORTRAN, these included logical variables (TRUE or
FALSE), and integer, real, and double-precision numbers.

Designed for Artificial Intelligence (AI) research.
The difference between this language and other languages
is that the basic and only type of data is the list, denoted by
a sequence of items enclosed by parentheses.
LISP programs themselves are written as a set of lists, so
that LISP has the unique ability to modify itself, and hence
grow on its own.
            Algorithmic Language

Independent of specific type of hardware.
Language was carefully and formally designed.
Algol’s major contribution is being the basis for Pascal, C,
C++, and Java.
It was also the first language with a formal grammar, known
as Backus-Naar Form or BNF.
COmmon Business Oriented Language
   Designed from the ground up as the language for
   Data types were numbers and strings of text.
   It allowed for the data to be grouped into arrays and
   records, so that data could be tracked and organized better.
  BASIC (Beginners' All-purpose Symbolic
              Instruction Code)

John Kemeny and Thomas Kurtz invents BASIC
and its compiler. It was developed at Dartmouth
College as a teaching tool

Pascal was developed mainly out of necessity for a good teaching tool.
Designed in a very orderly approach, it combined many of the best
The combination of features, input/output and solid mathematical features,
made it a highly successful language.
Pascal also improved the "pointer" data type, a very powerful feature of
any language that implements it.
It also added a CASE statement that allowed instructions.
C was developed the Unix system. Unix gives C such
advanced features as dynamic variables (e.g. variant),
multitasking, interrupt handling, forking, and strong, low-
level, input-output.
Because of this, C is very commonly used to program
operating systems such as Unix, Windows, the MacOS,
and Linux.
                OOP and C++
In the late 1970's and early 1980's, Object Oriented Programming, or
OOP was developed.
Objects are pieces of data that can be packaged and manipulated by the
In 1983 developed into the language C++
 C++ was designed to organize the raw power of C using OOP, maintain
          Visual Basic (VB)

Evolved from BASIC
With the development of Microsoft windows graphical user
interface (GUI) in the late 1980s and the early 1990s,
BASIC evolved into VB.
VB is developed on using forms and windows using in
which a programs drags and drops into the program.
Netscape licensed Java for use in their internet browser.
Has optimization problems
Java may wind up as the instructional language of
tomorrow as it is truly object-oriented and implements
advanced techniques such as true portability of code and
garbage collection.
Visual Basic Concepts

 VB is windows based programming language that
 allows a programmer to build applications running
 under Windows.
    VB constructs the necessary building blocks that a Windows
     application needs
    Hence, very little coding needs to be performed
 Integrated development environment (IDE) allows the
 programmer to create, run and debug Windows
 programs in one application
 VB is a EVENT driven language
    Code is written to respond to specific events
    Allows code to be short and is compartmentalized by events.
Visual Basic Environment
How to start Visual Basic?
Visual Basic Environment

 Integrated Environment Screen
     Menu Bar: lists of commands
     Tool Bar: quick access to mostly common used
     Form:window where the application is designed
     Project Explorer: a list of forms,modules, classes
      or ActiveX components
     Properties Window: a list of the property settings
      for a control
     Tool Box: a set of tools designing applications
     Form Layout: set the forms screen position
                 Menu Bar

                 Tool Bar



Toolbox   Form

Selection Tool          Picture Box

Label                   Text Box
Frame                   Command Button
Check Box
                        Option Button
Combo Box
                        List Box
Horizontal Scroll Bar
                        Vertical Scroll Bar
                        Drive Box
Directory List
                        File list
Image Box
                        Data Control
OLE Control
Operations on a Project

How to Open?
   Choose the file open icon on the toolbar or
    the file open menu
   Type in or choose the name of the file to
   Same as other MS software
Operations on a Project

   How to Save?
       A VB project consists of many forms, modules,
        and graphics, and all of them are saved within
        separate files within the project
       Project File Extensions
          Design-time Files
          Miscellaneous Development Files
          Run-time Files
       Saving a project
          Saving a form or module
          Automatic saving of project files and forms
       Using help
Using Controls on a Form

Adding a control to a form
Selecting a control
Resizing a control
Deleting a control
Moving a control
Setting control properties
   Object Box – displays the name of the selected
   Properties List – displays a scrollable list of all
    properties for the selected control
Adding code to controls
Option Explicit – error preventing statement
Adding Comments to Code

Comments are useful to remind the
programmer about the purpose of the code or
any problems with it
Text within the code window are color coded
  Green – comments

  Blue – valid VB commands

  Black – programmer’s code
Building A Visual Basic Application

Step 1: Draw the interface

Step 2: Set properties

Step 3: Write codes

Step 4: Execute the program
Controlling the Program Flow
Conditional Operator
 Operator         Meaning
  =              Equal to
  >              More than
  <              Less Than
  >=             More than and equal
  <=             Less than and equal
  <>             Not Equal to
  Controlling the Program Flow
 Logical Operators
Operator       Meaning
 And       Both sides must be true
  Or       One side or other must be
 Xor       One side or other must be
           true but not both
 Not       Negates truth
Controlling the Program Flow
If – Then - Else statement
If conditions Then VB expressions
VB expressions
End If
Case Select Statement
 Select Case expression
 Case value1
    Block of one or more VB statements
 Case value2
    Block of one or more VB Statements
      Declaring a Variable
Dim Variable as Variable Type

Dim r as Integer
Dim pi as Double
If variable is not declared the program will
consider it as an variant
                        VB Codes
Program for finding the volume of a cone and a

Dim r as double
Dim h as double
Dim pi as double
Dim v as double
r = Val(radius.Text)
h = Val(hght.Text)
Pi = 22 / 7
v = Pi * (r ^ 2) * h
volume.Text = Str$(v)
The general format of a function is:

 where arguments are values that are passed on
 to the functions
Visual Basic
       Problem Statement
 Calculate the commission
Sales Volume($)    Commissions
 <500                3%
 <1000               6%
 <2000               9%
 <5000               12%
 >5000               15%
            Macro in Excel
Function Comm(Sales_V As Variant) as Variant
If Sales_V <500 Then
Elseif Sales_V>=500 and Sales_V<1000 Then
Elseif Sales_V>=1000 and Sales_V<2000 Then
Elseif Sales_V>=200 and Sales_V<5000 Then
Elseif Sales_V>=5000 Then
End If
End Function

Shared By: