Yes Mark, you rigth.

This code is working now, Problem was space char in EDT_IP.Text, it comes from format. This is normal, but at this time, why "Trim" function NOT DELETE space char ????? is this bug ?


var Q : String;
Const WhiteSpace = [#0..' '];

    function My_Trim(S : string): String;
    var I: Integer;
    begin
      Result := S;
      Try
       I := 1;
       while I<Length(S)do Begin
        if S[I]in WhiteSpace then Delete(S,I,1)
        else Inc(I,1);
       end;    // while
       Result := S;
      Except
      end;
    end;

//copied from /fpc271/rtl/objpas/sysutils/sysstr.inc  line 524
    function Trim_(const S: string): string;
    var Ofs, Len: integer;
    begin
      len := Length(S);
      while (Len>0) and (S[Len] in WhiteSpace) do
       dec(Len);
      Ofs := 1;
      while (Ofs<=Len) and (S[Ofs] in WhiteSpace) do
       Inc(Ofs);
      result := Copy(S, Ofs, 1 + Len - Ofs);
    end ;
begin
  Q := Trim(EDT_IP.Text);// space not deleted
  Q := Trim_(EDT_IP.Text);// space not deleted
  Q := My_Trim(EDT_IP.Text); // space DELETED
  if IP4OK(Q)then begin
..............




24-10-2013 16:18 tarihinde, Mark Morgan Lloyd yazdı:
FreeMan wrote:
Hello,
Lazarus Revision 43315
TRegExpr class in "/opt/lazarus/components/synedit/synregexpr.pas"

I need check IP address, my IP4OK function for this. If I sent variable result is false, but sent parameter like '127.0.0.1' result is true, what is wrong?


EDT_IP: TMaskEdit;
......
EDT_IP.EditMask:= '!999.999.999.999;1; ';

I'd suggest checking /exactly/ what you're passing in the initial test case, i.e. make sure there's no leading spaces etc.



--
_______________________________________________
Lazarus mailing list
[email protected]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply via email to