Club Delphi  
    Paypal   FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Principal > Varios
Registrarse FAQ Miembros Calendario Guía de estilo Buscar Temas de Hoy Marcar Foros Como Leídos

Coloboración Paypal con ClubDelphi

 
 
Herramientas Buscar en Tema Desplegado
  #6  
Antiguo 02-12-2005
Avatar de turekon
turekon turekon is offline
Registrado
 
Registrado: nov 2005
Posts: 5
Poder: 0
turekon Va por buen camino
hola puedes utilizar esta funcion que permite ajustar el tamaño de la cadena que se pasa por parametro, llenando los espacios con el caracter requerido, así como ajustar la alineacion de la cadena.

Código Delphi [-]
function FormatString(Cad, Str :String; Largo, Justi :Integer):String;
    var
       StrCad : String;
       CadO   : String;
       i,Tam  : Integer;
    begin
       StrCad := Cad;
       if StrCad = '' then
       begin
         StrCad := ' ';
       end;
       CadO := StrCad;
       if Largo > Length(StrCad) then
       begin
          Case Justi of
              1 : begin
                   for i := 1 to (Largo - Length(CadO)) do
                   begin
                       StrCad := StrCad + Str;
                   end;
                 end;
             2 : begin
                   for i := 1 to (Largo - Length(CadO)) do
                   begin
                       StrCad := Str + StrCad;
                   end;
                 end;
             3 : begin
                   Tam := (Largo - Length(CadO)) div 2;
                   for i := 1 to Tam do
                   begin
                    StrCad := Str + StrCad + Str;
                   end;
                   if (Largo-Length(CadO) mod 2 <> 0) then
                   begin
                       StrCad := StrCad;
                   end;
                 end;
          end;
        end
          else
           if Largo < Length(StrCad) then
          begin
              StrCad:=Copy(StrCad,1,Largo);
          end;
        FormatString:=StrCad;
    end;

espero sirva, para mis reportes y logs de seguimiento ha sido muy util.

asi lo utilizo:

Código Delphi [-]
         Writeln(ReporteF, FormatString( 'Nombre Archivo', ' ', 35, 1) +
                                  FormatString( 'Tamaño_Archivo', ' ', 20, 1) +
                            FormatString( 'Fecha', ' ', 20, 1) +
                            FormatString( 'Hora', ' ', 20, 1) +
                            FormatString( 'Estado Archivo', ' ', 15, 1));
          Writeln(ReporteF, FormatString( '-', '-', 35, 1) +
                                  FormatString( '-', '-', 20, 1) +
                            FormatString( '-', '-', 20, 1) +
                            FormatString( '-', '-', 20, 1) +
                            FormatString( '-', '-', 15, 1));
 
          for Ind:=0 to FileBox.Items.Count-1 do
          begin
             Writeln(ReporteF, FormatString( FileBox.Items.Strings[Ind], ' ', 35, 1) +
                                     FormatString( IntToStr(Tamanyo(FileBox.Items.Strings[Ind])), ' ', 20, 1) +
                               FormatString( FormatDateTime('yyyy-mm-dd', Now), ' ', 20, 1) +
                               FormatString( FormatDateTime('hh:mm:ss', Now), ' ', 20, 1) +
                               FormatString( 'Procesado', ' ', 15, 1));
          end;

un ejemplo de como quedaria el reporte.

Código Delphi [-]
  Nombre Archivo                     Tamaño_Archivo      Fecha               Hora                Estado Archivo 
  --------------------------------------------------------------------------------------------------------------
  00000123452005112815-34-29.LIS     293408              2005-12-01          15:06:29            Procesado

Última edición por turekon fecha: 02-12-2005 a las 15:17:21.
Responder Con Cita
 


Herramientas Buscar en Tema
Buscar en Tema:

Búsqueda Avanzada
Desplegado

Normas de Publicación
no Puedes crear nuevos temas
no Puedes responder a temas
no Puedes adjuntar archivos
no Puedes editar tus mensajes

El código vB está habilitado
Las caritas están habilitado
Código [IMG] está habilitado
Código HTML está deshabilitado
Saltar a Foro


La franja horaria es GMT +2. Ahora son las 13:11:07.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi
Copyright 1996-2007 Club Delphi