Ignore:
Timestamp:
Apr 26, 2007, 1:53:33 PM (18 years ago)
Author:
RBRi
Message:

Pchar utils added

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/NewView/CharUtilsUnit.pas

    r112 r117  
    2727  Function CharIsAlpha(const aChar : char) : boolean;
    2828
     29
     30  // ---------------
     31  // ---- PChar ----
     32  // ---------------
     33
     34 
     35  // Converts a PChar into a String like StrPas
     36  // but conversts at least the first aLength chars
     37  Function StrPasWithLength(const aPChar: PChar; const aLength: integer) : String;
     38
     39  // Returns the difference of the pointers
     40  Function PCharPointerDiff(const aMinuend: PChar; const aSubtrahend : PChar ) : Longword;
     41
    2942Implementation
    3043
     
    4356
    4457
     58  // ---------------
     59  // ---- PChar ----
     60  // ---------------
     61
     62
     63  // Converts a PChar into a String like StrPas
     64  // but conversts at least the first aLength chars
     65  Function StrPasWithLength(const aPChar: PChar; const aLength: integer) : String;
     66  var
     67    i: integer;
     68  begin
     69    Result := '';
     70    i := 0;
     71    while (aPChar[i] <> #0) and (i < aLength) do
     72    begin
     73      Result := Result + aPChar[i];
     74      inc( i );
     75    end;
     76  end;
     77
     78
     79  Function PCharPointerDiff(const aMinuend: PChar; const aSubtrahend : PChar ) : Longword;
     80  begin
     81    Result := Longword(aMinuend) - Longword(aSubtrahend);
     82  end;
     83
     84
    4585END.
Note: See TracChangeset for help on using the changeset viewer.