Begin a := b + c; Insertar(a); end; "# $ % # '# () )* # "+,$ # "--$ ' #. "//$.# (* Todo este trozo es un comentario *) begin{esto también es un comentario} a := b + c; // aquí se esta haciendo una suma Insertar(a); end; 0 () 12
" 3 1 5 ) 5% 52 5. #1 2" $.6 0 "1 $ Const pi = 3.11592; Const B = 18; Const anio = 2001; Const tamano = 12; 0 ) ' ) ' 7 Var Nombrevariable1 : tipo; Nombrevariable2 : tipo; 5 0 " $ 8"9$: ":'01$ 3) 2;<7== 1 2>*7?@A*7?@? B 2<@==*=
C 2>7DE?FEA*@EA 0 7DE?FEA*@E? 3 2<7DE?FEA*@E? 9 2 ( 2 9 1 3 Var Edad : byte; Nombre : string; DNI : cardinal; Curso : byte; Puntuación : real; Varon : boolean; 3 9 1C:'01 5G '1CH5'3CI5 )) # 8 JK 2 7 J7EK 5JL( G FK 'JDM7K 9J?M7K 0 G ( M 1 JDMEK
N 9 JA>7K - O J7-D?K / ( JDE/*K 2 ( ( JDE *K 2 O 9 JDE*K % 0 8 1 K 1 K K ( " $ Var Fichapersona : record Nombre: string; Edad: byte; Telefono: longint; End; ( : )* 5 % : )5JL( G :FK : )J77K : )J?==<D@EK O'9C31 %
0 56 PDDD7D*Q K ( R ) PDD<QK PDD<<D7<QSK PDD<DD<DD<QK G%9'3CG513G53'(5'1 0 N% M% 5JL( FK ' JLG FK 53JMLLM K 9N% (" $K ( 2 JLTUFK "@D<$K D< @ LF 3G5891CI5(C%G1
G% L*F) JK R * L*F# 2 % N 2 S 9 2 )2 5) K K DAV*EK J"$K//JD 1CN% # 2 1 2 K K JLD7*FK J1C"$K//JD7* C1N % 2 K K JD7K JLLMC1"$K//JL D7F 1939'1((3C1CI5
1 1 # ) D 7K ( $%"$ )' '()"$ (("$ CJ)JD J7K CJ) JDK J7K J*K J=K J*K J<K K 0 CJ) JDK J7K J*K K
W%91CG51GG0'5'1 % # # # D 7 # 0 () ( *(+$+$),( X X Y YE XJ XJ* YJ YJ? YX YX< J JE 0 # (+$) *(+$+$),( "X$"Y*$ "X$"Y*$ "J$ # * " ) Z
)[0 #$ "-" " 3 2. )C\ 1 D D<7D= *7< *< # % ) )O 0 # ) " "# "# $ # % ( % ) 1.
" 2 ) () # * +(. /N1 2 1 # " #' % D< ( +(.$()/N1 1 # ) # #' * )* (* **(
+(.(($/N1 ) +',#' - # * +'.* **( - * D< " # $% " # $ *0 () ; % 1 / 0/0 '/0 ' $' 1 2 ( % % '(%) *'(+(,)-( (2. / 3
3.3(53 ( ) 2 ) 670 3 8 670 38 6( 69 0 * 2 0 ; 1. / 2 2 :0*0' :/;0 *< <=00 * ;>? 0@ ;>;"A B 2@ :0*0' :/</ <=0>C@ :/%0
<=0>? 0;"A B 2@ :/;' <=0>1#@ </ %0 ;'
" 0 Z] [% :0*0' ://. D6 / 0 ( Z3 [V * 2 1 :0*0' ://D. D6 / " # ' ()* #
1" 0 '"E </" ' </"' </"' $ :0 ' / ' 0 '' %0< ; D:6F"' % %(.1 % :$ 0>:;G2@ :$9 ' 0
" 3 % / '', :" %0< ; H :/ / 00< / I/ O ) %1%. 3. ) F"$%0>F"JG@ 1 ) % * 31 () ) () 1%. ' 3 B *7 *7N 13 C3 C
('3 (33 1 ;(' ( 33 ]3 ( 3 B *D3 B S*DD 1'. ' W' W 31 () ; C G5.G0 ***"" 3. 0 0. ) 0 )O ^O
00 2
0 3%O ) :( T )'% # T ; ) % 2"3 0( # ( # 8 B )') # ## # 0 O.
2 0 ;1 0 ) ) ( *(+$+$) O O O2 % % 2 2 0 O 3)^# 9 # 3 # 3. 3 8 3 G 0 # 3 3# 3 3 % # 1 ) % % # 2. 1 < )2 % O O 3
# 1 ( H# O % 9 H O % % % H 1 ; 1 1 2 C C % 1 # # # #. 1) : ( " *1 0 )%Z3 ) [) 170
0" B S B S *0" 0 ) 2 1
21 ) #% # 2( 5"3 ; # # 3 5 /6% **0" 0 C 2"3 ) 2"37 ) #O 6G 2"3 5 G^ 3 ' 9 C R *(+$+$) 2 G^ 3 ' 9"9 $ C"C$ R
5 ' 5
3 9 T 3 ; 3 CT 3 / 83 9 :; procedure TForm1.Button1Click(Sender: TObject); begin close; {Esta orden cierra el formulario} end; "0"
B S % 2 #. @0 1 :<1 () 1 =61 % 21 ) 1 1 " 3 3 1 ^2/ > : ; =# 0 '# 0
() % :>/% 7 K ) ' ). 2 %. () ) ) ' ) -*** 3? 5S 2:
7 =/ # 2 # 1 =/ # # (*************************************** Ejemplo de declaración de una unidad **************************************** *) Unit Mensajes; {El nombre del fichero, pero sin.pas} Interface //Solo cabeceras de las funciones y proc.
procedure Di (mensaje:string); function PreguntaNombre:String; Implementation //Implementación de las rutinas procedure Di(mensaje:String); Begin //Muestra en pantalla el mensaje que se pasa por parámetro Showmessage(mensaje); End; Function PreguntaNombre:String; Begin PreguntaNombre := Inputbox('Identificación', 'Teclee su nombre', '(Desconocido)'); End; end. 3? Program Ejemplo; Uses Mensajes, Calculos; Var a : Word; Begin Di ( Hola ); a := logaritmo(10); End; "( $ O% ) )? "5 1
2 / >% # @. / > # # = %. @ % #. 32 O 3/ >% 9(/ >% # / >8
/ >3 2(";/ >68 # # / >6O 2.; / >68 / >63) :6% C 1 + % 2 ^2. 32,- % :2. @:2.,' 1 7 1 3. 2. 1 2 ^ 32. *,'1 # / >2/ > ) % ^ @. / >2/ >
. O 2 % ^23? + 3 () ^ 2. / ) * -"* 3 # ) )..H ) % 9>1 ) 3 () # ) 1 3 :% "5 1 2 )(# *
/ >9 () )2 ) ). / >1 ) ) 2(";8 % *" "* 0 2/ >: = A % @9 % 2(: 1'. 7C () "5 3 % @9 / 0 ) @ B%? B ' W 2: % 1 #% (2 =
@ () ). 2"39(/1 2. / /( / @: #' 9-7% 5"# B) ; " () 7 9 1 () ) 9 9>1 ) 1. % () ) * "- # 1 () ; ) ())(+$+$)6 0 7 C D% 2. 9(;## )
1) ^. 0 7. %. Procedure Form.Ejemplo; Begin Showmessage( Hola ) //aquí no hay punto y coma Showmessage( Hola otra vez ); // aquí da el error End; '. (Error)Ejemplo.pas(0): Missing operator or semicolon in Form.Ejemplo #6EFE F1 Procedure Form.Ejemplo; Var v:byte; Begin v := h ; //v solo puede almacenar números, no caracteres Showmessage( Hola ); End; '. (Error)Ejemplo.pas(50): Incompatible types: Byte and Char? # 6E(F ) ) % ) Procedure Form.Ejemplo; Var MiNombre: string; Direccion:sting; // string mal escrito Begin MiNombe := David Osornio Fernández ; // MiNombre mal escrito
Telefono := 755-01-6 ; End; //Variable no definida '. (Error)Ejemplo.pas(0): Undeclared identifier: sting (Error)Ejemplo.pas(2): Undeclared identifier: MiNombe (Error)Ejemplo.pas(3): Undeclared identifier: Telefono EGF(/@:91?@9 Procedure Form.Ejemplo; Begin Showmessage( Hola ); End // aquí falta el unto y coma Procedure Form.Ejemplo2; // aquí da el error Begin Showmessage( Hola otra vez ); End; '. (Error)Ejemplo.pas(5): ; expected but found PROCEDURE EGF(EF ) //estamos definiendo los métodos del objeto MiObjeto Procedure MiObjeto.Ejemplo2; // nombre de clase mal escrito Begin Showmessage( Hola ); End; '. (Error)Ejemplo.pas(50): ; expected but, found.6e(f ) G ) #
//tenemos las unidades unidad1 y unidad2 Uses Crt, unidad1, uidad2, unidad3; // Unidad2 mal escrita // Unidad3 no existe Procedure MiObjeto.Ejemplo2; Begin... '. (Error)Ejemplo.pas(10): File not found uidad2 ; (Error)Ejemplo.pas(10): File not found unidad3 ; 1 (6E(FC ) 91 "7$89$): '() %. #;() ) EBF ) Procedure Form.Ejemplo; Var v : byte; // Definimos v, pero no la usamos Begin Showmessage( Hola ); End; '. (Hint)Ejemplo.pas(0): Variable v is declared but never used in Form.Ejemplo EBF )
Procedure Form.Ejemplo; Var v : byte; Begin v := 1; //damos un valor pero no volvemos a usar v Showmessage( Hola ); End; '. (Hint)Ejemplo.pas(0): Value assigned to v never used in Form.Ejemplo / E(F *1- # ) )) ) *0. 1 1- )....
" ;9 % ^2@ 5"9( " "<*0 ) # 3 9( # @ # ) 3'. H1 < " ( ) # ) 6 % 9(0 0 # Try Bloque peligroso Except
Bloque alternativo End; ( % < Try a := b/c; Except Showmessage( error al dividir ); End; 10 0 R ) 0*" 9 () @ # ) # _%H_%HO%C3GB:BO: 2" % % #% /( 2 # 0 % C2 % 7 / ]) ) 1 ; ; ) 09 ;
2 0 2" ) ))( 0$(=$+ 13 3. 1 19 9 191 3 199 9 11 3 '.2" /0 3 3 7 5"') 2 $)$%$+ %1 %() %( %()(. %()((. %3 1 0 / ) " )0 " 3 2
( 3 3 ( 3 :( 1 T 8 $)$%$+ 9. 1 9. 9. 9. ) 3 9.) 9. " " 2 *( 7 2" ) # : 0 0 00 9 )0 $)$%$+ :*(" $ : :.) :.) :. :. ) 26]7 0S 9 $)$%$+ 0 0 0 0 3 ; () 0 3 =
$( *(+$+$) ) ) : % # % % (. %% % %# O
'3 ) 0 = *(+$+$),( ( "D<7<D<<D=<$K 9 ' ( '"D<7<D<<D=<D<7<7<<7<<$K 9 O ( O"==$K 0 ( 0 "D<<D<<$K. ) 9 ( 9"D<D<A<=<$K
#G ) C # #G"D<D<FTF$K +$+*()7 1 1 "(%6IJH (6# 6JH 9($'6IJH ) :/ Procedure Tformulario.FormPaint(Sender:Tobject); Var x:word; Begin Imagen.canvas.pen.color := clblue; {Color de borde azul} Imagen.canvas.ellipse(120,12,220,220); {elipse} Imagen.canvas.pen.color := clred; {Color de borde rojo} Imagen.canvas.rectangle(200,150,280,300); {Rectángulo} Imagen.canvas.pen.color := clpurple; {Color de borde púrpura} Imagen.canvas.brush.color := clpurple; {Color de relleno púrpura} Imagen.canvas.brush.style := bsfdiagonal; {estilo de relleno líneas diagonales} Imagen.canvas.ellipse(300,100,600,150); {Elipse}
Imagen.canvas.pen.width := 3; {Figura de borde ancho} Imagen.canvas.brush.color := clred; {Color de relleno rojo} Imagen.canvas.brush.style := bsdiagcross; {diagonales cruzadas} Imagen.canvas.pen.color := clyellow; {Color de borde amarillo} Imagen.canvas.ellipse(10,200,150,300); {Elipse} Imagen.canvas.brush.style := bssolid; {Relleno sólido} Imagen.canvas.pen.color := clgreen; {color de borde verde} Imagen.canvas.pen.width := 1; {Borde fino} For x:=1 to 100 do begin {línea que va de (x*10,10) a (300-x*10,80)} imagen.canvas.moveto (x*10,10); imagen.canvas.lineto (300-x*10,80); end; Imagen.canvas.brush.color := clnone; {Sin color de relleno} imagen.canvas.font.color := clblack; {Color de texto negro} imagen.canvas.font.size := 16; {Tamaño de texto 16} imagen.canvas.textout(100,300, Hola esta es una demostración de Canvas ); End; 2 % 3 ) 2. %.. Image1.canvas.ellipse(20,50,10,20) %. Canvas.ellipse(20,50,10,20) " $)
0 $( 3 H) O 0 1 *(+$+$) # H 1 # # % 1 # # % () ^' ^' ^3 ^3 ^T ^C ^5 ^G^ ^9 ^R ' () 3 H) **20 % ; 1 3 9 K T )JHH 59 % 2 B )LHH
1 3 ".$ 35" 0 H 5/1> H T )M H B )M H 1 0H 5 1> H T )M H B )M H ') ` ; 0MJH 52 M H T )MH B ) H 1 Procedure Teditor.BotonSalirClic(Sender: Tobject); Begin Close; End; 1 R 3 0MJH 5 H T )MH B ) H
1. 3 D 0MJH 5 NH T )MH B ) H 1 R 3 9 0MJH 59 MH T )MH B ) H 1; = ) ) ( $( )( )(> )(? )(@ )(A 0 MJH MOH MPH JH JIH 5 / /@> / / / 3 ') ') ') ') ') 3 @ A ; 5" HH HH HH HH HH T ) H H H H H B ) H H H H H ( ; Private ColorFigura:TColor; Figura:byte; XRaton, Yraton:word; O E )
77 Procedure Teditor.AreaDibujoMouseMove(Sender: Tobject; Shift: TShiftState; X, Y: Integer); Begin XRaton:=x; YRaton:=y; End; R ) Procedure Teditor.BotonCuadradoClic(Sender: TObject); Begin Figura:=0; End; 3. Procedure Teditor.BotonCirculoClic(Sender: TObject); Begin Figura:=1; End; R Procedure Teditor.BotonElipseClic(Sender: TObject); Begin Figura:=2; End; '. = Procedure TEditor.PanelAzulClic(Sender: Tobject); Begin ColorFigura:=clBlue; End; 0 "9^ B) $
( Procedure TEditor.AreaDibujoClic(Sender: TObject); Begin AreaDibujo.canvas.pen.color:=colorfigura; AreaDibujo.canvas.brush.color:=colorfigura; Case figura of 0: AreaDibujo.canvas.rectangle(xraton- 50,yraton-50, xraton+50, yraton+50); 1: AreaDibujo.canvas.ellipse(xraton-50, yraton-50, xraton+50, yraton+50); 2: AreaDibujo.canvas.ellipse(xraton-100, yraton-20, xraton+100, y raton+100); end; End; : Procedure TEditor.FormCreate(Sender: TObject); Begin Figura:=0 {Figura por defecto, cuadrado} Colorfigura :=clblue; {color por defecto, azul} End; ""* 0 ) 1 ;
"**" 9 () 0 ; ;B *73 ) '8C 7/ ;13 )S ",/0%,. #.' # '8C 0. '.. 0. )'8C @52. 3 ) 2. C. D. 2. C. <. ) 1 9 :'01 1 :'01
5B S# ) ) () 2 )'8C%' # *(+$+$) 3: ) 3: 8 ) (: 8 ) 9 8 ) : 3 : : ) : : 9 : 8 ) 1 D G1 " * " () ) 3(F )S O(C# 7 3 1. 3O3C"7 # $3 % ) O3C O O % O3C())
% ( 1 B1 1 '8C8 3(' OOO ( 8 8 ( 839 (' G 1 G) '1 *(+$+$) ' "B'8$ 1 O(C 8 '8C 3( "2 $ ' OOO 8.( 8.3( 8 3 1. ( G 1 0 C ) B'8OC( O V ) 0 $( *(+$+$) ' 3 %% 'G 1 9 '9S 1 9 3 % ( O %2 ( %
% : 5 5 ) 8 % 1. G 1O % G3: # O %) 'GK 9 0. O % 3(F '8C ' % : O : ))( 0 O O : 3 O 1 O TO1 T O1: O O1: % 1O%7E 1O%7E 1O%7= 1O%7= 1O%*< 1O%*< 1O%*<( 1O%7V 0 O1:O1:TO1 %
0)+$) B( *(7(7( O3C6TO16TG9 TO1 #) TO1 O3C6TO16OC5 TO1 # TO1 O3C6TO1613G5( TO1 # TO1 O3C6O1:6OC5 O1: # O1: O3C6O1:613G5( O1: # O1: O3C6O1:6:9'O O1: # O1: O3C6O1:69'3` O1: # O1: O3C6O1:6OC5 O1: # O1: O3C6O1:613G5( O1: # O1: O3C6O1:6:9'O O1: # O1: )# ) % % ="3 ; ;. % /O 0). % ;% # % ;/ '.^% P<Q <^% P=Q =
% ;=" '.^0)P7Q 7