Pascal/Turbo Pascal - Mostrar en pantalla un listado

 
Vista:
sin imagen de perfil

Mostrar en pantalla un listado

Publicado por Alejandro (15 intervenciones) el 25/10/2015 02:58:42
Hola que tal, tengo un problema con un ejercicio que me pide que imprima por pantalla los siguientes datos:
Nro de cliente.
Descripcion.
Cantidad.
Precio.

El tema es que debe mostrar de esta forma (sin los guiones, los puse para que muestre la separacion):

Nro. de cliente--------Descripcion--------Cantidad--------Precio
xxxx----------------------xxxxx-----------------xxx----------------xx,xx
xxxx----------------------xxxxx-----------------xxx----------------xx,xx
xxxx----------------------xxxxx-----------------xxx----------------xx,xx
xxxx----------------------xxxxx-----------------xxx----------------xx,xx

Pero cuando se ingresa algun numero, se desarma todo, porque si el numero es largo se corre mas, quedandome asi:

Nro. de cliente--------Descripcion--------Cantidad--------Precio
xx----------------------xxxxx-----------------xxx----------------xx,xx
xxxxxx----------------------xxxxx-----------------xxx----------------xx,xx
xxxx----------------------xx-----------------xxx----------------xx,xx
xxx----------------------xxx-----------------xxxxx----------------xx,xx

Mi pregunta es como puedo hacer para que quede todo debajo de uno, sin que se corran las lineas?

Yo lo hice de la siguiente forma

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
procedure mostrarArchivo;
begin
	abrirArchivo();
	writeln ('Nro. Cliente     Descripcion     Cantidad     Precio');
	while not eof (vf_arch) do
		begin
			read (vf_arch , vr_reg);
			write (vr_reg.NroCliente,'                   ');
			write (vr_reg.Descr,'            ');
			write (vr_reg.Cantidad,'              ');
			write (vr_reg.Precio:2:2,'                ');
			writeln;
		end;
	close (vf_arch);
end;
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

Mostrar en pantalla un listado

Publicado por ramon (2158 intervenciones) el 01/11/2015 16:30:10
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
{Mira si esto te sirve}
 
 program archivo;
  uses
    crt;
  type
     cliente = record
          numero : longint;
          descricion : string[50];
          cantidad : integer;
          precio : real;
        end;
  const
     nombrearchi = 'Datoscli.dat';
  var
    clien : cliente;
    archi : file of cliente;
 
   procedure guardadatos(c : cliente);
   begin
      assign(archi,nombrearchi);
  {$I-}  reset(archi); {$I+}
    if ioresult <> 0 then
    begin
       rewrite(archi);
       seek(archi,0);
       write(archi,c);
       close(archi);
    end
  else
     begin
       seek(archi,filesize(archi));
       write(archi,c);
       close(archi);
     end;
   end;
 
   procedure presentadatos;
   var
     h : longint;
   begin
       assign(archi,nombrearchi);
  {$I-}  reset(archi); {$I+}
    if ioresult <> 0 then
    begin
       writeln('    Error De Archivo O No Existe Pulse Una Tecla');
       readkey;
       halt(1);
    end
  else
      begin
         gotoxy(2,2);write('Nro. de cliente         escripcion        Cantidad        Precio');
         for h := 0 to filesize(archi) - 1 do
         begin
            seek(archi,h);
            read(archi,clien);
            gotoxy(3,3 + h);write(clien.numero);
            gotoxy(26,3 + h);write(clien.descricion);
            gotoxy(44,3 + h);write(clien.cantidad);
            gotoxy(60,3 + h);write(clien.precio:0:2);
         end;
         gotoxy(4,5 + h);write('Pulse Una Tecla');
         readkey;
         close(archi);
      end;
   end;
 
   procedure entradadatos;
   var
     tecla : char;
   begin
      clrscr;
      writeln('    ****** Entrada De Datos Cliente ******');
      writeln('    //////////////////////////////////////');
      writeln;
      write('    Entre N. Cliente  : ');
      readln(clien.numero);
      write('    Entre Descricion  : ');
      readln(clien.descricion);
      write('    Entre Cantidad    : ');
      readln(clien.cantidad);
      write('    Entre Precio      : ');
      readln(clien.precio);
      writeln;
      writeln('    Datos Correctos [S/N]');
      repeat
          tecla := upcase(readkey);
      until tecla in['S','N'];
      if tecla = 'S' then
      begin
         guardadatos(clien);
      end;
   end;
 
  procedure menu;
  var
   tec : char;
   sal : boolean;
  begin
     sal := false;
    repeat
       clrscr;
       writeln('    **** Menu Jeneral ****');
       writeln;
       writeln('  1 = Entrada Datos');
       writeln('  2 = Presenta Datos');
       writeln('  3 = Salir');
       writeln;
       writeln('   Elija Opcion');
     repeat
         tec := readkey;
     until tec in['1','2','3'];
     clrscr;
   case tec of
  '1' : entradadatos;
  '2' : presentadatos;
  '3' : sal := true;
   end;
    until sal = true;
  end;
 
 
  begin
     menu;
  end.
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar
sin imagen de perfil

Mostrar en pantalla un listado

Publicado por Alejandro (15 intervenciones) el 05/11/2015 18:12:08
Si funciono, muchas gracias por la ayuda!!
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar