home *** CD-ROM | disk | FTP | other *** search
/ Media Share 9 / MEDIASHARE_09.ISO / hamradio / wnode230.zip / UTILS.PAS < prev    next >
Pascal/Delphi Source File  |  1993-03-14  |  2KB  |  90 lines

  1. Unit Utils;
  2.                 { Very simple utilities for WNodelst.Pas }
  3.                 { and WNldemo.Pas.                       }
  4.                 { See WNodelst.Pas for references.       }
  5. Interface
  6. Function Word_Upcase(Frase:String):String;
  7. Function Val2(St:String):Longint;
  8. Function CmpSort(Stringa1,Stringa2:String):Byte;
  9. Function FileExists(Nome_Del_File:String):Boolean;
  10.  
  11. Implementation
  12. Uses
  13.    Dos;
  14.  
  15. Function FileExists(Nome_Del_File:String):Boolean;
  16. Var
  17.    SRec:SearchRec;
  18.  
  19. Begin
  20.    FindFirst(Nome_Del_File,Archive,SRec);
  21.    FileExists:=DosError=0
  22. end;
  23.  
  24. Function CmpSort(Stringa1,Stringa2:String):Byte;
  25. Var
  26.    Pos:Byte;
  27.    Exit:Byte;
  28.  
  29. Begin
  30.    Pos:=1;
  31.    Exit:=0;
  32.    While (Pos<=Length(Stringa1)) and (Pos<=Length(Stringa2))
  33.          and (Exit=0) do
  34.    Begin
  35.       If Stringa1[Pos]<Stringa2[Pos] then
  36.          Exit:=1
  37.       else
  38.       If Stringa1[Pos]>Stringa2[Pos] then
  39.          Exit:=2;
  40.       Inc(Pos);
  41.    end;
  42.    If Exit=0 then
  43.    Begin
  44.       If Length(Stringa1)<Length(Stringa2) then
  45.          Exit:=1
  46.       else
  47.       If Length(Stringa1)>Length(Stringa2) then
  48.          Exit:=2
  49.       else
  50.          Exit:=3;
  51.    end;
  52.    CmpSort:=Exit;
  53. end;
  54.  
  55. Function Val2(St:String):Longint;
  56. Const
  57.    StrNum:Array[0..9] of Char=('0','1','2','3','4','5','6','7','8','9');
  58.  
  59. Var
  60.    Conta,Conta1:Byte;
  61.    Res,Pot:Longint;
  62.  
  63. Begin
  64.    Res:=0;
  65.    Pot:=1;
  66.    For Conta:=Length(St) downto 1 do
  67.    Begin
  68.       Conta1:=0;
  69.       While (UpCase(St[Conta])<>(StrNum[Conta1])) and (Conta1<11) do
  70.          Inc(Conta1);
  71.       If Conta<>Length(St) then
  72.          Pot:=Pot*10;
  73.       Res:=Res+Pot*(Conta1);
  74.    end;
  75.    Val2:=Res;
  76. end;
  77.  
  78. Function Word_Upcase(Frase:String):String;
  79. Var
  80.    Kunta:Integer;
  81.  
  82. Begin
  83.    For Kunta:=1 to Length(Frase) do
  84.       Frase[Kunta]:=UpCase(Frase[Kunta]);
  85.    Word_UpCase:=Frase;
  86. end;
  87.  
  88. Begin
  89. end.
  90.