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

Respuesta
 
Herramientas Buscar en Tema Desplegado
  #1  
Antiguo 02-12-2005
Luis Alberto Luis Alberto is offline
Miembro
 
Registrado: ago 2005
Posts: 149
Poder: 21
Luis Alberto Va por buen camino
Creo que no es lo que necesariamente necesito pero gracias deja acomodar las ideas para explicar dicho asunto...
Responder Con Cita
  #2  
Antiguo 02-12-2005
Avatar de vtdeleon
vtdeleon vtdeleon is offline
Miembro
 
Registrado: abr 2004
Ubicación: RD & USA
Posts: 3.236
Poder: 26
vtdeleon Va por buen camino
Saludos

Tengo este codigo
Código Delphi [-]
function rspace(Atext:string; Long:integer; Spac:char = ' '): String;
var
  X:integer;
begin
  Atext:=trim(Atext);
  if long < 0 then
    long:=0;
  x:=long-Length(AText);
  Result:=StringOfChar(Spac,X)+Atext;
end;
{ rspac('8',3,'0')
 el resultado sera ==>  '008'
}
No estoy seguro si es lo que quieres
__________________
Van Troi De León
(Not) Guía, Code vB:=Delphi-SQL, ¿Cómo?
Viajar en el tiempo no es teóricamente posible, pues si lo fuera, ya estarían aqui contándonos al respecto!
Responder Con Cita
  #3  
Antiguo 02-12-2005
Avatar de delphi.com.ar
delphi.com.ar delphi.com.ar is offline
Federico Firenze
 
Registrado: may 2003
Ubicación: Buenos Aires, Argentina *
Posts: 5.964
Poder: 29
delphi.com.ar Va camino a la fama
Creo que este hilo puede servirte: http://www.clubdelphi.com/foros/showthread.php?t=12673

Saludos!
__________________
delphi.com.ar

Dedique el tiempo suficiente para formular su pregunta si pretende que alguien dedique su tiempo en contestarla.
Responder Con Cita
  #4  
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
  #5  
Antiguo 02-12-2005
Avatar de FunBit
FunBit FunBit is offline
Miembro
 
Registrado: jun 2005
Posts: 572
Poder: 22
FunBit Va por buen camino
Código Delphi [-]
 
 procedure CerosDelante(var Cadena: String; longitud: integer);
 begin
 
   Cadena:=Copy(Pad('0',longitud),0,longitud-Length(Cadena))+Cadena;
    
 end;
 
 procedure CerosDetras(var Cadena: String; longitud: integer);
 begin
 
   Cadena:=Cadena+Copy(Pad('0',longitud),0,longitud-Length(Cadena));
 
 end;
 
 function Pad(S: String; WantLength:integer): String;
 begin
   if Length(S) > WantLength then begin
     Result := copy(S,1,WantLength);
   end else begin
     Result := S + space(WantLength-length(S));
   end;
 end;

function Space(spacelength:integer): String;
  var i:integer;
begin
  Result := '';
  for i := 1 to spacelength do begin
    Result := Result + ' ';
  end;
end;

CerosDelante -> concatena tantos ceros delante de la cadena como la diferencia entre la longitud especificada en la función y la real de la cadena.
CerosDetras -> Lo mismo pero por detrás.

Para colaborar con la causa!

Espero que te sirva.

Saludos!!

Última edición por FunBit fecha: 02-12-2005 a las 15:19:20.
Responder Con Cita
  #6  
Antiguo 02-12-2005
Avatar de FunBit
FunBit FunBit is offline
Miembro
 
Registrado: jun 2005
Posts: 572
Poder: 22
FunBit Va por buen camino
Por cierto! Si quieres que en vez de 0 te ponga espacios en blanco, sólo tienes que cambiar el 1r parámetro de la funcion Pad de '0' a ' '.

Saludos!!
Responder Con Cita
  #7  
Antiguo 02-12-2005
fidel fidel is offline
Miembro
 
Registrado: mar 2005
Posts: 381
Poder: 22
fidel Va por buen camino
Hola:

Para rellenar hasta 12 caracteres (con ceros delane)

entero := 345
cadenadoce := RightStr ( '000000000000' + IntToStr ( entero ) , 12 );

Para rellenar hasta 20 caracteres (con .... por detrás)

texto := 'Aragón'
cadenaveinte := LeftStr ( texto + '....................' , 20 );

Un saludo.
Responder Con Cita
Respuesta


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 02:34:54.


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