Exemplos

Iniciado por Watila, 20 de Setembro , 2007, 03:20:10 PM

tópico anterior - próximo tópico

0 Membros e 1 Visitante estão vendo este tópico.

Watila

Estrutura de seleção

case of


caso 1: blabla
caso 2: tatata
caso 3: haha

end;


//Botão OK//

Case strtoint (edit1.text) of
   0..12: edit2.text:='criança';
   13..18: edit2.text:='adolescente';
   19..60: edit2.text:='adulto';
   61..150: edit2.text:='idoso';
   
   end;



Watila

//TTimer//

randomize;
case random (6) of

   0:shape1.shape:=stcircle;
   1:shape1.shape:=stroundsquare;
   2:shape1.shape:=strectangle;
   3:shape1.shape:=streactangle;
   4:shape1.shape:=stroundraect;
   5:shape1.shape:=stellipse

   end;

//LIGA//

timer1.enabled:=true;





Para adicionar mais formas ai SHAPE...

//TTimer//

randomize;
case random (6) of

   0:shape1.shape:=stcircle;
   1:shape1.shape:=stroundsquare;
   2:shape1.shape:=strectangle;
   3:shape1.shape:=streactangle;
   4:shape1.shape:=stroundraect;
   5:shape1.shape:=stellipse

   end;

case random ( 8 ) of

0:shape1.brush.style:=bssolid;
1:shape1.brush.style:=bsbdiagonal;
3:shape1.brush.style:=bscross;
4:shape1.brush.style:=bsdiagcross;
5:shape1.brush.style:=bsvertical;
6:shape1.brush.style:=bshorizontal;
7:shape1.brush.style:=bsclear;

end;

shape1.brush.color:=rgb(random(255), random (255), random(255));

shape1.pen.color:=rgb(random(255), random (255), random(255));

(lembrando que o case random é igual o anterior, só muda a adição do case random "8")


Watila

Estrutura de repetição


repeat
   declarações
until

exemplo:


//button//

var x:real;
begin
   repeat
      memo1.lines.add(floattostr(x));
      x:=x+1;
      until (x>6);





Watila

Vetores e matrizes

 
(estáticos e dinâmicos)



sintaxe:

Estático


var

v: array [0..10] of integer;

                                    string;

                                    real;

                                    .                     

                                    .                     

                                    .

 

m: array [0..10,0..5] of integer;

                                    string;

                                    real;

                                    .

                                    .

                                    .

 

 
Dinamicos
 

Var

v: array of integer;

                        string;

                        real;

                        .                     

                        .                     

                        .

 

m: array of integer;

                        string;

                        real;

                        .

                        .

                        .

 

begin

setlength (v,11);

setlength (m, 11, 6);

 

 

//Button Estático//

 

var

m: array [0..100] of integer;

i: integer;

begin

for i:= 0 to 100 do

            begin

            m :=i ;

            memo1.lines.add (inttostr(m));

            end;

end;

 

 

//Button Dinâmico//

 

var

m: array of integer;

i, t: integer;

begin

 

t:= strtoint (inputbox('Novo tamanho:','Digite o tamanho:','100'));

setlength  (m, t);

for i:= 0 to t do

begin

m := i;

memo1.lines.add (inttostr(m));

end;

end;


{espero q gostem e ajude a alguem...}
abração, fui!!!

Casanova

Não poderia deixar de passar aqui e não te parabenizar pelo tuto !!
Parabéns Watila !!!!
Bem explicado !!!!