Añadida función uStringsUtils.pas
git-svn-id: https://192.168.0.254/svn/Proyectos.LuisLeon_FactuGES/trunk@246 c93665c3-c93d-084d-9b98-7d5f4a9c3376
This commit is contained in:
parent
97a2eda409
commit
8539f98d10
@ -100,6 +100,7 @@ contains
|
|||||||
MD5 in 'Utiles\MD5.pas',
|
MD5 in 'Utiles\MD5.pas',
|
||||||
uPasswordUtils in 'Utiles\uPasswordUtils.pas',
|
uPasswordUtils in 'Utiles\uPasswordUtils.pas',
|
||||||
uInfoProjectUtils in 'Utiles\uInfoProjectUtils.pas',
|
uInfoProjectUtils in 'Utiles\uInfoProjectUtils.pas',
|
||||||
uInformeRegistryUtils in 'ClassRegistry\uInformeRegistryUtils.pas';
|
uInformeRegistryUtils in 'ClassRegistry\uInformeRegistryUtils.pas',
|
||||||
|
uStringsUtils in 'Utiles\uStringsUtils.pas';
|
||||||
|
|
||||||
end.
|
end.
|
||||||
|
|||||||
Binary file not shown.
71
Source/Base/Utiles/uStringsUtils.pas
Normal file
71
Source/Base/Utiles/uStringsUtils.pas
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
unit uStringsUtils;
|
||||||
|
|
||||||
|
interface
|
||||||
|
|
||||||
|
uses
|
||||||
|
Classes;
|
||||||
|
|
||||||
|
const
|
||||||
|
DISPLAY_EUROS2 = '#,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;
|
||||||
|
function EscaparCadena (Cadena: String): String;
|
||||||
|
|
||||||
|
implementation
|
||||||
|
|
||||||
|
uses
|
||||||
|
Variants, SysUtils, JclStrings;
|
||||||
|
|
||||||
|
{ 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;
|
||||||
|
|
||||||
|
function EscaparCadena (Cadena: String): String;
|
||||||
|
begin
|
||||||
|
Result := StringReplace(Cadena, '''', '\\''', []);
|
||||||
|
Result := StrStringToEscaped(Result);
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
end.
|
||||||
Reference in New Issue
Block a user