FS#74 - UFunLib.pas : GetNbToken renvoi le mauvais nombre de token
Concerne le projet:
Framework 000 - COMMON
Ouverte par Loic Le Gallou (loic) - mercredi, 22 août 2007, 23:07 GMT+2
Dernière édition par Loic Le Gallou (loic) - mardi, 04 septembre 2007, 21:47 GMT+2
Ouverte par Loic Le Gallou (loic) - mercredi, 22 août 2007, 23:07 GMT+2
Dernière édition par Loic Le Gallou (loic) - mardi, 04 septembre 2007, 21:47 GMT+2
|
DétailsUFunLib.pas : GetNbToken renvoi le mauvais nombre de token si aucun token délimité
|
Cette tâche dépend de
Close par Loic Le Gallou (loic)
mardi, 04 septembre 2007, 21:47 GMT+2
La raison de la clôture est: Implemented
mardi, 04 septembre 2007, 21:47 GMT+2
La raison de la clôture est: Implemented
function CountField(src : string; sep : string) : integer;
Var
i : integer;
s : string;
begin
if (src = '') then
begin
result := 0;
exit;
end;
result := 1;
for i := 1 to length(src) do
begin
s := copy(src, i, length(sep));
if (s = sep) then
inc(result);
end;
end;
function GetField(src : string; sep : string; num_field : integer) : string;
Var
i,n : integer;
s : string;
begin
result := '';
if (CountField(src,sep) < num_field) then
exit;
s := src;
for i := 1 to num_field-1 do
begin
n := pos(sep, s);
if (n > -1) then
s := copy(s, n+length(sep), length(s) - n); // s := copy(s, n+1, length(s) - n);
end;
n := pos(sep, s);
if (n = 0) then
n := length(s)+1;
result := trim(copy(s, 0, n-1));
end;