2
0

insthelp.pas 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. {
  2. Helper routines for installer
  3. This file is part of the Free Pascal installer.
  4. Copyright (c) 1993-2005 by Florian Klaempfl
  5. member of the Free Pascal development team
  6. See the file COPYING.FPC, included in this distribution,
  7. for details about the copyright.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  11. **********************************************************************}
  12. unit insthelp;
  13. interface
  14. function RTrim(const S: string): string;
  15. function LTrim(const S: string): string;
  16. function Trim(const S: string): string;
  17. function CompareText(S1, S2: string): integer;
  18. function ExtOf(const S: string): string;
  19. function DirAndNameOf(const S: string): string;
  20. function DirOf(const S: string): string;
  21. implementation
  22. uses
  23. dos;
  24. function RTrim(const S: string): string;
  25. var
  26. i : longint;
  27. begin
  28. i:=length(s);
  29. while (i>0) and (s[i]=' ') do
  30. dec(i);
  31. RTrim:=Copy(s,1,i);
  32. end;
  33. function LTrim(const S: string): string;
  34. var
  35. i : longint;
  36. begin
  37. i:=1;
  38. while (i<length(s)) and (s[i]=' ') do
  39. inc(i);
  40. LTrim:=Copy(s,i,255);
  41. end;
  42. function Trim(const S: string): string;
  43. begin
  44. Trim:=RTrim(LTrim(S));
  45. end;
  46. function CompareText(S1, S2: string): integer;
  47. var R: integer;
  48. begin
  49. S1:=Upcase(S1);
  50. S2:=Upcase(S2);
  51. if S1<S2 then R:=-1 else
  52. if S1>S2 then R:= 1 else
  53. R:=0;
  54. CompareText:=R;
  55. end;
  56. function ExtOf(const S: string): string;
  57. var D: DirStr; E: ExtStr; N: NameStr;
  58. begin
  59. FSplit(S,D,N,E);
  60. ExtOf:=E;
  61. end;
  62. function DirAndNameOf(const S: string): string;
  63. var D: DirStr; E: ExtStr; N: NameStr;
  64. begin
  65. FSplit(S,D,N,E);
  66. DirAndNameOf:=D+N;
  67. end;
  68. function DirOf(const S: string): string;
  69. var D: DirStr; E: ExtStr; N: NameStr;
  70. begin
  71. FSplit(S,D,N,E);
  72. DirOf:=D;
  73. end;
  74. end.