home *** CD-ROM | disk | FTP | other *** search
/ Chip 2001 September / Chip_2001-09_cd1.bin / zkuste / delphi / kolekce / d6 / RX275D6.ZIP / Units / STR16.PAS < prev    next >
Pascal/Delphi Source File  |  1999-10-12  |  2KB  |  106 lines

  1. {*******************************************************}
  2. {                                                       }
  3. {         Delphi VCL Extensions (RX)                    }
  4. {         For 16-bit applications only                  }
  5. {                                                       }
  6. {         Copyright (c) 1995, 1996 AO ROSNO             }
  7. {                                                       }
  8. {*******************************************************}
  9.  
  10. unit Str16;
  11.  
  12. interface
  13.  
  14. {$IFNDEF WIN32}
  15.  
  16. {$I RX.INC}
  17.  
  18. type
  19.   ShortString = string;
  20.   PShortString = ^ShortString;
  21.   AnsiChar = Char;
  22.   PAnsiChar = ^AnsiChar;
  23.  
  24. { System32 unit functions and procedures }
  25. procedure SetLength(var S: string; NewLength: Byte);
  26. procedure SetString(var S: string; Buffer: PChar; Len: Byte);
  27. procedure UniqueString(var S: string);
  28.  
  29. { SysUtils32 unit functions and procedures }
  30. function Trim(const S: string): string;
  31. function TrimLeft(const S: string): string;
  32. function TrimRight(const S: string): string;
  33. function QuotedStr(const S: string): string;
  34.  
  35. {$ENDIF WIN32}
  36.  
  37. implementation
  38.  
  39. {$IFNDEF WIN32}
  40.  
  41. uses SysUtils;
  42.  
  43. procedure SetLength(var S: string; NewLength: Byte);
  44. begin
  45.   S[0] := Char(NewLength);
  46. end;
  47.  
  48. procedure SetString(var S: string; Buffer: PChar; Len: Byte);
  49. begin
  50.   S[0] := Char(Len);
  51.   if Buffer <> nil then begin
  52.     if StrLen(Buffer) < Len then Len := StrLen(Buffer);
  53.     Move(Buffer^, S[1], Len);
  54.   end;
  55. end;
  56.  
  57. procedure UniqueString(var S: string);
  58. begin
  59. end;
  60.  
  61. function Trim(const S: string): string;
  62. var
  63.   I, L: Byte;
  64. begin
  65.   L := Length(S);
  66.   I := 1;
  67.   while (I <= L) and (S[I] <= ' ') do Inc(I);
  68.   if I > L then Result := ''
  69.   else begin
  70.     while S[L] <= ' ' do Dec(L);
  71.     Result := Copy(S, I, L - I + 1);
  72.   end;
  73. end;
  74.  
  75. function TrimLeft(const S: string): string;
  76. var
  77.   I, L: Byte;
  78. begin
  79.   L := Length(S);
  80.   I := 1;
  81.   while (I <= L) and (S[I] <= ' ') do Inc(I);
  82.   Result := Copy(S, I, 255);
  83. end;
  84.  
  85. function TrimRight(const S: string): string;
  86. var
  87.   I: Byte;
  88. begin
  89.   I := Length(S);
  90.   while (I > 0) and (S[I] <= ' ') do Dec(I);
  91.   Result := Copy(S, 1, I);
  92. end;
  93.  
  94. function QuotedStr(const S: string): string;
  95. var
  96.   I: Byte;
  97. begin
  98.   Result := S;
  99.   for I := Length(Result) downto 1 do
  100.     if Result[I] = '''' then Insert('''', Result, I);
  101.   Result := '''' + Result + '''';
  102. end;
  103.  
  104. {$ENDIF WIN32}
  105.  
  106. end.