Transcript
Page 1: Introduction to Delphi - June 2004

LINGUAGEM DE PROGRAMAÇÃO I

DELPHI

CENTRO FEDERAL DE EDUCAÇÃO TECNOLÓGICA - ALAGOASPROFESSOR : JARBAS ALVES CAVALCANTE

ALUNO : MICHEL ALVES DOS SANTOS

17 de Junho de 2004

Page 2: Introduction to Delphi - June 2004

PROGRAMAÇÃO ORIENTADA A EVENTOSPROGRAMAÇÃO ORIENTADA A EVENTOS

PARADIGMAS DE PROGRAMAÇÃO

LPRO I – LINGUAGEM DE PROGRAMAÇÃO I

PROGRAMAÇÃO ORIENTADA A OBJETOSPROGRAMAÇÃO ORIENTADA A OBJETOSDIFERENÇA ENTRE ALGUMAS LINGUAGENSDIFERENÇA ENTRE ALGUMAS LINGUAGENSEXEMPLOS : VISUAL BASIC E DELPHI

Page 3: Introduction to Delphi - June 2004

ABSTRAÇÃOHERANÇAENCAPSULAMENTOPOLIMORFISMO

PARADIGMAS DA OO

LPRO I – LINGUAGEM DE PROGRAMAÇÃO I

Page 4: Introduction to Delphi - June 2004

O QUE É ?QUANDO SURGIU ?ONDE É ENCONTRADO ?

O OBJETO PASCAL

LPRO I – LINGUAGEM DE PROGRAMAÇÃO I

Page 5: Introduction to Delphi - June 2004

O OBJETO PASCAL – Condicional

LPRO I – LINGUAGEM DE PROGRAMAÇÃO I

{Condição simples} if (condicao) then begin ... Instrucoes ... end;

{condicao composta} if ( condicao ) then begin

... Instrucoes ...

end else begin

... Instrucoes ...

end;

{Estrutura case} case (objetoDeComparacao) of begin opcao1 : begin ... Instrucoes ... end; opcao2 : ... Instrucoes ... else ... Instrucoes ... end;

Page 6: Introduction to Delphi - June 2004

O OBJETO PASCAL – Laços

LPRO I – LINGUAGEM DE PROGRAMAÇÃO I

{Laço incremental} for I:= 1 to MAXIMO do begin ... Instrucoes ... end;

{Laço decremental} for I := MAXIMO downto 1 do begin ... Instrucoes ... end;

{Laço condicional - instrução previamente checada} while (condicao) do begin ... Instrucoes ... end;

{Laço condicinal - instrução tardiamente checada} repeat

... Instrucoes ...

until(condição);

Page 7: Introduction to Delphi - June 2004

O OBJETO PASCAL – Outras ...

LPRO I – LINGUAGEM DE PROGRAMAÇÃO I

{Estrutura with} with objeto do begin .codigo = "20"; .nome = "Zé das tantas ..." .cpf = "111.111.111-11" end;

{procedimento} procedure nomeDoProcedimento(argumento : tipo; var argumento : tipo); var variavelLocal : tipo; begin .... intruçoes .... end;

{função} function nomeDaFuncao (argumento : tipo; argumento : tipo) : Retorno var variavelLocal : tipo; begin .... intruçoes .... result := retornoDaFuncao; end;

Page 8: Introduction to Delphi - June 2004

O OBJETO PASCAL – Comentários

LPRO I – LINGUAGEM DE PROGRAMAÇÃO I

Object Pascal suporta três tipos de comentários: comentários com chaves, comentários com parênteses/asterisco; e comentários com barras duplas no estilo do C++. Abaixo, exemplos dos três tipos de comentários:

{ Comentários usando chaves }(* Comentários usando parênteses e asteriscos*)// Comentário no estilo C++

Page 9: Introduction to Delphi - June 2004

O OBJETO PASCAL – Variáveis

LPRO I – LINGUAGEM DE PROGRAMAÇÃO I

Object Pascal permite que a você agrupar mais do que uma variável do mesmo tipo juntamente na mesma linha com a seguinte sintaxe:Var1, Var2 : AlgumTipo;Uma característica da linguagem introduzida no Delphi 2.0 permite que você inicialize variáveis globais dentro de um bloco var. Exemplos demonstrando a sintaxe para fazer isso são mostrados a seguir:var i: Integer = 10; S: string = 'Olá mundo'; D: Double = 3.141579; Nota: Pré-inicialização de variáveis é apenas permitida para variáveis globais e não para variáveis locais a um procedimento ou função.

Page 10: Introduction to Delphi - June 2004

O OBJETO PASCAL – Constantes

LPRO I – LINGUAGEM DE PROGRAMAÇÃO I

Constantes em Pascal são definidas na cláusula const, que comporta-se similarmente a palavra reservada const do C. Aqui está um exemplo de três declarações de constantes em C:const float ANumeroDecimal = 3.14;const int i = 10;const char * ErrorString = 'Perigo, Perigo, Perigo'; Outra forma de declaração de constantes :const ADecimalNumber = 3.14; i = 10; ErrorString = 'Danger, Danger, Danger!';

Page 11: Introduction to Delphi - June 2004

O OBJETO PASCAL – Operadores

LPRO I – LINGUAGEM DE PROGRAMAÇÃO I

Operador de Atribuição :Exemplo: Number1 := 5; Operador de Comparação :Exemplo: if x = y then fazerAlgo; if x <> y then fazerAlgo;Operador Lógicos : if (condicao1) and (condicao2) then fazerAlgo; if (condicao1) or (condicao2) then fazerAlgo; if not (condicao1) then fazerAlgo;

Atribuição : :=Comparação : =, <>, >,<,>= , <=Lógicos : and, or, notAritméticos : +, - , *, /, mod, div

Page 12: Introduction to Delphi - June 2004

O OBJETO PASCAL – Tipos

LPRO I – LINGUAGEM DE PROGRAMAÇÃO I

ShortInt, Byte , SmallInt, Word , Integer, Longint, Cardinal, LongWord, Int64, Single, Real48, Double, Extended, currency, Variant, OleVariant, TvarData, Char, WideChar, ShortString, AnsiString, Pchar, PwideChar, WideString, Boolean, ByteBool, WordBool, BOOL, LongBoolNota: Se você possui um código de 16-bit do Delphi 1.0, esteja avisado de que o tamanho dos tipos Integer e Cardinal aumentou de 16 para 32 bits. Na verdade, isto é pouco preciso: no Delphi 2.0 e 3 o tipo Cardinal foi tratado como um inteiro não sinalizado de 31-bit para preservar a precisão aritmética (porque Delphi 2 e 3 careciam de um verdadeiro inteiro não sinalizado de 32-bit). No Delphi 4, Cardinal é um verdadeiro inteiro não sinalizado de 32-bit

Page 13: Introduction to Delphi - June 2004

O OBJETO PASCAL – Vetores

LPRO I – LINGUAGEM DE PROGRAMAÇÃO I

Arrays : Array estático : var //melhor começar com zero ... a : Array [1..7] of String; Array dinâmico : var //array dinamico sempre inicia no zero ... a : Array of String; begin //aloca 33 posições para o array SetLength(a,33);

Page 14: Introduction to Delphi - June 2004

O OBJETO PASCAL – Objetos

LPRO I – LINGUAGEM DE PROGRAMAÇÃO I

Pense em objetos como registros que também contém funções e procedimentos.Um objeto é definido como segue:

TypeTObjetoFilho = class(TObjetoPai);AlgumaVar: Integer;procedure AlgumProc;end; // Definição de método ...procedure TObjetoFilho.AlgumProc;begin{ o código do procedimento vem aqui }end;

Page 15: Introduction to Delphi - June 2004

O OBJETO PASCAL – Casting

LPRO I – LINGUAGEM DE PROGRAMAÇÃO I

Na sintaxe seguinte, um typecast é requerido para converter c em um byte. Um typecast fala ao compilador que você realmente sabe o que você está fazendo e quer converter um tipo para outro:

var //Declaração de variaveis ... c: char; b: byte;begin c := 's'; b := byte(c); // o compilador ficará feliz com esta linhaend.

Page 16: Introduction to Delphi - June 2004

O AMBIENTE DELPHI

LPRO I – LINGUAGEM DE PROGRAMAÇÃO I

A IDE RAD do Delphi ...

Page 17: Introduction to Delphi - June 2004

O OBJECT INSPECTOR

LPRO I – LINGUAGEM DE PROGRAMAÇÃO I

A janela seletiva de propriedades ...

O QUE É ?SERVE PARA QUE?

Page 18: Introduction to Delphi - June 2004

O OBJECT TREEVIEW

LPRO I – LINGUAGEM DE PROGRAMAÇÃO I

A janela seletiva de objetos ...

O QUE É ?SERVE PARA QUE?

Page 19: Introduction to Delphi - June 2004

A PALETA DE COMPONENTES

LPRO I – LINGUAGEM DE PROGRAMAÇÃO I

A paleta de componentes padrão ...

A paleta de componentes adicionais ...

A paleta de componentes WIN32 ...

A paleta de componentes ADO ...

Page 20: Introduction to Delphi - June 2004

FERRAMENTAS ESPECIALIZADAS

LPRO I – LINGUAGEM DE PROGRAMAÇÃO I

DATABASE DESKTOPBDE – BORLAND DATABASE ENGINE

IMAGE EDITORINTERBASESQL EXPLORER

Page 21: Introduction to Delphi - June 2004

OPÇÕES DE CONECTIVIDADE

LPRO I – LINGUAGEM DE PROGRAMAÇÃO I

BDE – NATIVO E ODBC

IBX – ACESSO NATIVO INTERBASE

ADO – ACESSO VIA OLEDB

DBEXPRESS

Page 22: Introduction to Delphi - June 2004

OPÇÕES DE RELATÓRIO

LPRO I – LINGUAGEM DE PROGRAMAÇÃO I

QUICK REPORTRAVE REPORTCOMPONENTES

ESPECIALIZADOS DE IMPRESSÃO

Page 23: Introduction to Delphi - June 2004

O DELPHI PROJECT

LPRO I – LINGUAGEM DE PROGRAMAÇÃO I

O QUE É DPR ?O DPR PODE SER

PROGRAMADO ?PARA QUE SERVE ?

Page 24: Introduction to Delphi - June 2004

O PRIMEIRO PROGRAMA !

LPRO I – LINGUAGEM DE PROGRAMAÇÃO I

HELLO WORLD !

OBJETOS USADOS : FORM, EDIT, BUTTON

TEdit

TButton

Page 25: Introduction to Delphi - June 2004

REFERÊNCIAS BIBLIOGRÁFICAS

LPRO I – LINGUAGEM DE PROGRAMAÇÃO I

Usando Visual Basic 5. Editora Campus - McKelvy, Mike et al. ; Páginas 9 a 32, 85 a 98.Java 2 : Fundamentos, Swing e JDBC. Alta Books –

Mecenas, Ivan; Páginas 10 a 21.Usando Java. Editora Campus – Alexandre

Newman et al; Páginas 163 a 190.

Referências eletrônicas :www.borland.comwww.clubedelphi.com.brwww.guiadodelphi.com.brwww.macoratti.net


Top Related