home *** CD-ROM | disk | FTP | other *** search
/ The Education Master 1994 (4th Edition) / EDUCATIONS_MASTER_4TH_EDITION.bin / files / windties / paprexps / wfplus.pas < prev   
Pascal/Delphi Source File  |  1991-11-26  |  3KB  |  126 lines

  1. {WFPLUS - Function Extensions to ObjectWindows Copyright (C) Doug Overmyer 7/1/91}
  2. unit WFPlus;
  3. {************************  Interface       **********************}
  4. interface
  5. uses WinTypes, WinProcs, WinDos, Strings, WObjects,StdDlgs;
  6. function Max(I,J:Integer):Integer;
  7. function Min(I,J:Integer):Integer;
  8. function GetDateTime(szDateTime:PChar):Boolean;
  9. function ExpandTabs(InStr,OutStr:PChar;Tabsize:Integer):Boolean;
  10. function CheckCC(InStr,OutStr:PChar):Boolean;
  11. {************************  Implementation  ***************************}
  12. implementation
  13. {*************************  Max           ****************************}
  14. function Max(I,J:Integer):Integer;
  15. begin
  16.     if I > J then
  17.         Max := I
  18.     else
  19.         Max := J;
  20. end;
  21. {************************  Min            ****************************}
  22. function Min(I,J:Integer):Integer;
  23. begin
  24.     if I < J then
  25.        Min := I
  26.   else
  27.        Min := J;
  28. end;
  29.  
  30. function  GetDateTime(szDateTime:PChar):Boolean;
  31. var
  32.   m,d,y,dw: Word;
  33.   temp,tag: string[4];
  34.   tStr: String;
  35. Begin
  36.   tStr := '';
  37.   GetTime(y,m,d,dw);
  38.   if (y > 12) then begin
  39.     y := (y - 12);
  40.     tag := 'pm';
  41.   End else
  42.     tag := 'am';
  43.   str(y,temp);
  44.   if (y < 10) then
  45.     temp := '0' + Temp;
  46.   tStr := tStr + temp + ':';
  47.   str(m,Temp);
  48.   tStr := tStr + temp + ':';
  49.   str(d,temp);
  50.   tStr := tStr + temp + tag + '     ';
  51.   GetDate(y,m,d,dw);
  52.   str(m,Temp);
  53.   if (m < 10) then
  54.     temp := '0' + temp;
  55.   tStr := tStr + temp + '/';
  56.   str(d,Temp);
  57.   if (d < 10) then
  58.     Temp := '0' + temp;
  59.   tStr := tStr + Temp + '/';
  60.   str(y,temp);
  61.   tStr := tStr + temp;
  62.   strPcopy(szDateTime,tStr);
  63.   GetDateTime := True;
  64. End;
  65.  
  66. function ExpandTabs(InStr,OutStr:PChar;Tabsize:Integer):Boolean;
  67. var
  68.     IndxIn,IndxOut,IndxTab:Integer;
  69.    NextTab:Integer;
  70. begin
  71.     IndxIn := 0;IndxOut:= 0;IndxTab:= 0;
  72.   For IndxIn := 0 to (StrLen(InStr) -1) do
  73.     case InStr[IndxIn] of
  74.         #9:
  75.           begin
  76.           NextTab := ((IndxOut div TabSize) +1) * TabSize;
  77.         for IndxTab := 1 to (NextTab - IndxOut) do
  78.             begin
  79.           OutStr[IndxOut] := #32;
  80.           Inc(IndxOut);
  81.           end;
  82.         end;
  83.       #0..#31:
  84.           begin
  85.         OutStr[IndxOut] := #32;
  86.         Inc(IndxOut);
  87.         end;
  88.       else
  89.           begin
  90.         OutStr[IndxOut] := InStr[IndxIn];
  91.         Inc(IndxOut);
  92.         end;
  93.     end;
  94.   OutStr[IndxOut] := #0;
  95.   ExpandTabs := TRUE;
  96. end;
  97.  
  98. function CheckCC(InStr,OutStr:PChar):Boolean;
  99. var
  100.     IndxIn,IndxOut:Integer;
  101. begin
  102.     IndxIn := 0;IndxOut:= 0;
  103.   For IndxIn := 0 to (StrLen(InStr) -1) do
  104.     case InStr[IndxIn] of
  105.         #9:                             {retain tabs}
  106.         begin
  107.         OutStr[IndxOut] := #9;
  108.         Inc(IndxOut);
  109.         end;
  110.       #0..#31:
  111.           begin
  112.         OutStr[IndxOut] := #32;
  113.         Inc(IndxOut);
  114.         end;
  115.       else
  116.           begin
  117.         OutStr[IndxOut] := InStr[IndxIn];
  118.         Inc(IndxOut);
  119.         end;
  120.     end;
  121.   OutStr[IndxOut] := #0;
  122.   CheckCC := TRUE;
  123. end;
  124.  
  125. end.
  126.