begin process at 2008 07 25 21:09:07
1 216 493 membres
446 nouveaux aujourd'hui
14 182 membres club

Vous ne trouvez pas de réponse à votre problème ? Alors posez la question dans le forum.
Souvenez-vous qu'il n'y a jamais de question bête, mais rester dans l'ignorance parce que l'on n'ose pas poser une question, ça c'est une erreur !

CONVERSIONS D'ADRESSES EN LIEN HTML


Information sur la source

Catégorie :Texte Niveau : Débutant Date de création : 30/07/2003 Date de mise à jour : 31/07/2003 04:38:34 Vu : 2 385

Note :
Aucune note

Commentaire sur cette source (0)
Ajouter un commentaire et/ou une note


Description

Bon ben, le texte veut tout dire, cette petite fonction permet de modifier une string par exemple 'cyrille2@free.fr http://www.visiomaster.net/' en '<a href="mailto:cyrille2@free.fr">cyrille2@free.fr</a> <a href="http://www.visiomaster.net/">http://www.visiomaster.net/</a>". Pour l'appeler il suffit de faire

mastring := HandleProtocols(mastring,['http://','ftp://']); par exemple!  

Source

  • procedure ExplodeConcat(Source, Splitter : String; ConcatStart : Integer ; var SList : TStringDynArray);
  • var SplitPos : integer;
  • SLenght : Integer;
  • begin
  • SetLength(SList,1);
  • SLenght := 1;
  • SList[0] := Source;
  • repeat
  • SplitPos := posfull(Splitter,Source,True)-1;
  • Inc(SLenght);
  • SetLength(Slist,SLenght);
  • SList[SLenght-1] := Copy(Source,1,SplitPos);
  • Delete(Source,1,SplitPos+1);
  • until (Source = '') or (SLenght = ConcatStart);
  • if ConcatStart = SLenght Then
  • begin
  • SetLength(SList,ConcatStart+1);
  • SList[ConcatStart] := Source;
  • end
  • else
  • if ConcatStart > SLenght Then
  • begin
  • SetLength(SList,ConcatStart);
  • For SLenght := SLenght+1 to ConcatStart-1 Do
  • SList[SLenght] := '';
  • end;
  • end;
  • function HandleProtocols(Mess : String; protocols: array of string) : String;
  • var Strings : TStringDynArray;
  • I, J : integer;
  • Pos1 :integer;
  • begin
  • ExplodeConcat(Mess,' ',-1,Strings);
  • For I := 1 To length(Strings)-1 Do // mess complet
  • begin
  • Pos1 := pos('@',Strings[I]);
  • if not (Pos1 = 0) and not (PosFrom('.',strings[I],Pos1) = 0) Then
  • Strings[I] := '<a href="mailto:'+StringReplace(Strings[I],'"','',[rfReplaceAll])+'">'+Strings[I]+'</a>'
  • else
  • For J := 0 to Length(protocols)-1 Do
  • begin
  • Pos1 := Pos(protocols[J],Strings[I]);
  • if Pos1 = 1 Then
  • begin
  • Strings[I] := '<a href="'+StringReplace(Strings[I],'"','',[rfReplaceAll])+'">'+Strings[I]+'</a>';
  • Break;
  • end;
  • end;
  • Result := Result+' '+strings[I];
  • end;
  • SetLength(Strings,0);
  • end;
procedure ExplodeConcat(Source, Splitter : String; ConcatStart : Integer ; var SList : TStringDynArray);
var SplitPos : integer;
    SLenght : Integer;
begin
    SetLength(SList,1);
    SLenght := 1;

    SList[0] := Source;

    repeat
        SplitPos := posfull(Splitter,Source,True)-1;

        Inc(SLenght);
        SetLength(Slist,SLenght);

        SList[SLenght-1] := Copy(Source,1,SplitPos);
        Delete(Source,1,SplitPos+1);
    until (Source = '') or (SLenght = ConcatStart);

    if ConcatStart = SLenght Then
    begin
        SetLength(SList,ConcatStart+1);
        SList[ConcatStart] := Source;
    end
    else
        if ConcatStart > SLenght Then
        begin
            SetLength(SList,ConcatStart);

            For SLenght := SLenght+1 to ConcatStart-1 Do
                SList[SLenght] := '';
        end;
end;


function HandleProtocols(Mess : String; protocols: array of string) : String;
var Strings : TStringDynArray;
    I, J : integer;
    Pos1 :integer;
begin
    ExplodeConcat(Mess,' ',-1,Strings);

    For I := 1 To length(Strings)-1 Do // mess complet
    begin
        Pos1 := pos('@',Strings[I]);

        if not (Pos1 = 0) and not (PosFrom('.',strings[I],Pos1) = 0) Then
            Strings[I] := '<a href="mailto:'+StringReplace(Strings[I],'"','',[rfReplaceAll])+'">'+Strings[I]+'</a>'
        else
            For J := 0 to Length(protocols)-1 Do
            begin
                Pos1 := Pos(protocols[J],Strings[I]);

                if Pos1 = 1 Then
                begin
                    Strings[I] := '<a href="'+StringReplace(Strings[I],'"','',[rfReplaceAll])+'">'+Strings[I]+'</a>';
                    Break;
                end;
            end;

        Result := Result+' '+strings[I];
    end;

    SetLength(Strings,0);
end;  

Conclusion

Bon conding ^^  
    Aucun commentaire pour le moment.

Ajouter un commentaire

Pub



Appels d'offres

Serveur et client mess...
Budget : 2 000€
Animation Flash alimen...
Budget : 6 000€
Intranet client pour t...
Budget : 5 000€

CalendriCode

Juillet 2008
LMMJVSD
 123456
78910111213
14151617181920
21222324252627
28293031   

VS Express FR Gratuit !

VS Express en français et 100% gratuit !

Boutique

Boutique de goodies CodeS-SourceS