Ver Mensaje Individual
  #4  
Antiguo 22-12-2007
Avatar de dec
dec dec is offline
Moderador
 
Registrado: dic 2004
Ubicación: Alcobendas, Madrid, España
Posts: 13.107
Reputación: 34
dec Tiene un aura espectaculardec Tiene un aura espectacular
Hola,

Se me adelanto Domingo, pero, ya tenía escrito esto...

Código Delphi [-]
(**
 * Put one or more separator into a string.
 *
 * Call example:
 *
 * PutStringSeparator('214KGDHJHENB123BAD', '-', 3)
 *
 * Example result:
 *
 * 214-KGD-HJH-ENB-123-BAD
 *
 * @param String aString String to put separators into it
 * @param String separator Separator to put into the string
 * @param Integer interval Interval characters to put the separator
 * @result String Entry string with the appropiate separator(s)
 *
 *)
function PutStringSeparator(aString,
 separator: string; interval: integer): string;
var
  i, j, strLen: integer;
begin
  j := 1;
  strLen := Length(aString);
  for i := 1 to strLen do begin
    result := result + aString[i];
    if (j = interval) then begin
      if (i < strLen) then begin
        result := result + separator;
      end;
      j := 0;
    end;
    Inc(j);
  end;
end;
__________________
David Esperalta
www.decsoftutils.com
Responder Con Cita