unit uStringsUtils;

interface

uses
  Classes;

const
  DISPLAY_EUROS2 = '#,0.00 €';
  DISPLAY_PORCENTAJE = '#,0.00%';  

procedure StringToStrings(Source:string; Delimiter:char; Target:TStrings);
function StringsToString(Source:TStrings; Delimiter:char):string;
function EsCadenaVacia(const S: AnsiString): Boolean; overload;
function EsCadenaVacia(const S: Variant): Boolean; overload;
function EsNumerico(Cadena: String) : Boolean;


implementation

uses
  Variants, SysUtils;

{ Convierte una cadena con items separados con un delimitador en un TString }
procedure StringToStrings(Source:string; Delimiter:char; Target:TStrings);
var i: integer;
begin
  for i:=1 to length(Source) do
    if Source[ i ] = Delimiter then Source[ i ]:=#10;
  Target.Text:=Source;
end;

{ Convierte un TString en una cadena de items separados con un delimitador }
function StringsToString(Source:TStrings; Delimiter:char):string;
var i: integer;
begin
  Result:='';
  for i:=0 to Source.Count-1 do
    Result:=Result + Delimiter + Source[ i ];
  if Result<>'' then Delete(Result, 1, 1)
end;

function EsCadenaVacia(const S: AnsiString): Boolean;
begin
  Result := (Length(Trim(S)) = 0)
end;

function EsCadenaVacia(const S: Variant): Boolean; overload;
begin
  Result := True;
  if VarIsNull(S) then
    Exit;
  Result := EsCadenaVacia(VarToStr(S));
end;

function EsNumerico(Cadena: String) : Boolean;
var
  Codigo: Integer;
  Valor: Double;
begin
  Val(Cadena, Valor, Codigo);
  Result := (Codigo = 0)
end;


end.
