home *** CD-ROM | disk | FTP | other *** search
/ The Equalizer BBS / equalizer-bbs-collection_2004.zip / equalizer-bbs-collection / DEMOSCENE-STUFF / UORA51.ZIP / UOSYS.PAS < prev    next >
Pascal/Delphi Source File  |  1996-02-07  |  3KB  |  125 lines

  1. {***************************************************************************
  2. **
  3. **                             -=( UOsys )=-
  4. **                   (c) CopyRight LiveSystems 1992, 1993
  5. **
  6. ** Author    : Gerhard Hoogterp
  7. ** FidoNet   : 2:283/7.33
  8. **             2:282/10.5
  9. ** Internet  : Gerhard@frappe.iaf.nl
  10. **
  11. **
  12. **    This unit is part of the UserOn package and may be used freely in
  13. **    other programs.
  14. **
  15. **    Under no circumstances will the author (me) be held responsible for any
  16. **    damage as result of using this library. Use this unit at your own risk!
  17. **    Comments and remarks are welcome at one of the above addresses.
  18. **
  19. **    If you use this source or when you support UserDoes and SysDoes files
  20. **    a reference to LiveSystems UserOn, UserOn/PRO and HandyMan would be
  21. **    appriciated.
  22. **
  23. ****************************************************************************}
  24.  
  25. Unit UOSys;
  26. Interface
  27. Uses Dos;
  28.  
  29.  
  30. Type UserDoesString = String[75];
  31.      UserDoesObject = Object
  32.                         DoesWhat : UserDoesString;    { The string to write   }
  33.                         SemDir   : PathStr;           { Where to write        }
  34.                         Node     : Byte;              { The nodenumber        }
  35.                         Name     : String[12];        { The UsedDoes filename }
  36.  
  37.                         { Prepare the userdoes object                         }
  38.                         Procedure Init( _Node : Byte;
  39.                                         _Does : UserDoesString;
  40.                                         _Where: PathStr);
  41.  
  42.                         { Write the _Does string to the semafore directory    }
  43.                         Procedure SetIt;
  44.  
  45.                         { Change the UserDoes string in the semaphore         }
  46.                         { directory                                           }
  47.                         Procedure ReSetIt(_Does : UserDoesString);
  48.  
  49.                         { Remove the UserDoes file                            }
  50.                         Procedure ClearIt;
  51.  
  52.                         { Read the UserDoes file from disk                    }
  53.                         Procedure GetIt(Def : UserDoesString);
  54.  
  55.                       End;
  56.  
  57. Implementation
  58.  
  59. Var Tmp : Text;
  60.  
  61.  
  62. Function Nr2Str(Nr : Word;Len : Byte):String;
  63. Var Temp : String[20];
  64. Begin
  65. Str(Nr:Len,Temp);
  66. Nr2Str:=Temp;
  67. End;
  68.  
  69. Procedure UserDoesObject.Init( _Node : Byte;
  70.                                _Does : UserDoesString;
  71.                                _Where: PathStr);
  72. Begin
  73. Node:=_Node;
  74. DoesWhat:=_Does;
  75. SemDir:=_Where;
  76. Name:='USERDOES.'+Nr2Str(Node,0);
  77. End;
  78.  
  79.  
  80. Procedure UserDoesObject.SetIt;
  81. Begin
  82. Assign(Tmp,SemDir+Name);
  83. Rewrite(Tmp);
  84. WriteLn(Tmp,DoesWhat);
  85. Close(Tmp);
  86. If IoResult<>0
  87.    Then;
  88. End;
  89.  
  90. Procedure UserDoesObject.ReSetIt(_Does : UserDoesString);
  91. Begin
  92. DoesWhat:=_Does;
  93. SetIt;
  94. End;
  95.  
  96. Procedure UserDoesObject.ClearIt;
  97. Var Try : Byte;
  98. Begin
  99. Try:=3;
  100. Repeat
  101.  Assign(Tmp,SemDir+Name);
  102.  Erase(Tmp);
  103.  If IoResult<>0
  104.     Then Dec(Try)
  105.     Else Try:=0;
  106. Until Try=0;
  107. End;
  108.  
  109. Procedure UserDoesObject.GetIt(Def : UserDoesString);
  110. Begin
  111. Assign(Tmp,SemDir+Name);
  112. Reset(Tmp);
  113. If IoResult=0
  114.    Then Begin
  115.         ReadLn(Tmp,DoesWhat);
  116.         Close(Tmp);
  117.         End
  118.    Else DoesWhat:=Def;
  119. If IoResult<>0
  120.    Then;
  121. End;
  122.  
  123. End.
  124.  
  125.