Framework 000 - COMMON

Liste des tâches

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
Type de tâche Anomalie
Catégorie Backend / Core
Etat Closes
Assignée à Personne
Système d'exploitation All
Sévérité Basse
Priorité Normale
Basée sur la version 1.0b3
Due pour la version 1.0b4
Date d'échéance Non décidé
Pourcentage achevé: 100%
Votes 0
Privée Non

Détails

UFunLib.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
Commentaire de Loic Le Gallou (loic) - vendredi, 24 août 2007, 09:35 GMT+2
// Renvoi le nombre de sous-chaine séparé par sep dans src
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;