home *** CD-ROM | disk | FTP | other *** search
/ Beijing Paradise BBS Backup / PARADISE.ISO / software / BBSDOORW / RADOOR30.ZIP / DOORSYS.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1994-04-10  |  9.5 KB  |  352 lines

  1. {╔═════════════════════════════════════════════════════════════════════════╗
  2.  ║                                                                         ║
  3.  ║                   (c) CopyRight LiveSystems 1990, 1994                  ║
  4.  ║                                                                         ║
  5.  ║ Author    : Gerhard Hoogterp                                            ║
  6.  ║ FidoNet   : 2:282/100.5   2:283/7.33                                    ║
  7.  ║ BitNet    : GERHARD@LOIPON.WLINK.NL                                     ║
  8.  ║                                                                         ║
  9.  ║ SnailMail : Kremersmaten 108                                            ║
  10.  ║             7511 LC Enschede                                            ║
  11.  ║             The Netherlands                                             ║
  12.  ║                                                                         ║
  13.  ║        This module is part of the RADoor BBS doorwriters toolbox.       ║
  14.  ║                                                                         ║
  15.  ╚═════════════════════════════════════════════════════════════════════════╝}
  16. {---------------------------------------------------------------------------|
  17.  Description:
  18.  
  19.  This unit contains general procedures and functions which are common to
  20.  most doors. The routines have access to the information in GlobalInfo
  21.  so they can adjust themself to the users settings.
  22.  
  23. |--------------------------------------------------------------------------}
  24.  
  25. Unit DOORSys;
  26. Interface
  27. Uses DOS,
  28.      CRT,
  29.      KeyDefs,   { Keyboard definitions             }
  30.      GlobInfo,  { Global system info               }
  31.      LowLevel,  { Lowlevel procedures and functions}
  32.      FileObj,   { Binary file handling routines    }
  33.      Fossil;    { Fossil routines                  }
  34.  
  35.  
  36.  
  37.  
  38. {----------------------------------------------------------------------------|
  39.   Display Routines:
  40.  
  41.     DisplayFile   Displays a single file to the remote console. YOU have to
  42.                   give the right path and extention, DisplayFile only copy's
  43.                   it to the comport. (And to the local console)
  44.                   The procedure responds to the [S] Stop and [P] pause
  45.                   keys. With pause ANY key will restart sending.
  46.                   The fossil output filter is turned off while displaying.
  47.  
  48.  
  49.     Display       Displays a file according the the users GRAPHICS (ANSI)
  50.                   AVATAR or ASCII settings. It uses DisplayFile for the
  51.                   actual displaying.
  52.                   You should only give the path and the filename without
  53.                   extention. If no file is found and nothing is displayed
  54.                   the function returns FALSE, otherwise it returns TRUE.
  55.  
  56.     ShowTextFile  This procedure is intended to show textfiles. It uses the
  57.                   users ScreenLength, UseClrScr and UseMoreYN toggles.
  58.                   Again, the fossils output filter is turned off while
  59.                   displaying the contents of the file, but is on while showing
  60.                   the PressEnterPrompt and the TitleLine.
  61.                   The [P] pause and [S] stop keys are recognised. ANY key
  62.                   will resume displaying after a Pause.
  63.                   You must give the complete path, filename and extention
  64.                   of the file to show.
  65.  
  66.     ShowHelpFile  Shows a helpfile. Translates the $$ into pagefeeds
  67.                   etc.
  68.  
  69. |----------------------------------------------------------------------------}
  70.  
  71.  
  72.  
  73.  
  74. Function DisplayFile( Foss     : FossilObject;
  75.                       FileName : ComStr):Boolean;
  76.  
  77. Procedure Display( Foss     : FossilObject;
  78.                    FileName : ComStr);
  79.  
  80. Procedure ShowTextFile( Foss     : FossilObject;
  81.                         FileName : ComStr;
  82.                         Title    : String);
  83.  
  84. Procedure ShowHelpFile( Foss     : FossilObject;
  85.                         FileName : ComStr;
  86.                         Title    : String);
  87.  
  88.  
  89.  
  90. Implementation
  91.  
  92.  
  93. {---- Display functions ----------------------------------------------------}
  94.  
  95. Procedure Display( Foss     : FossilObject;
  96.                    FileName : ComStr);
  97.  
  98. Const MaxBuf = 256;
  99.  
  100. Var AAAFile : FileObject;
  101.     Buffer  : Array[1..MaxBuf] Of Char;
  102.     BufPtr  : Word;
  103.     BufUsage: Word;
  104.     Stop    : Boolean;
  105.  
  106. Begin
  107.  
  108. AAAFile.Open(FileName,1,ReadOnly+ShareDenyNone);
  109. If AAAFile.Error<>0
  110.    Then Exit;
  111.  
  112. Foss.OutputFilterOff;
  113.  
  114. BufUsage:=MaxBuf;
  115. Stop:=False;
  116.  
  117. While (Not Stop) And (BufUsage=MaxBuf) Do
  118.  Begin
  119.  AAAFile.ReadBuffer(Buffer,BufUsage);
  120.  BufPtr:=1;
  121.  While (Not Stop) And (BufPtr<=BufUsage) Do
  122.   Begin
  123.   Case Buffer[BufPtr] Of
  124.    #01  : Begin
  125.           Foss.OutPutFilterOn;
  126.           Foss.PressEnter;
  127.           Foss.OutputFilterOff;
  128.           End;
  129.    #16  :
  130.           Delay(1000);
  131.     Else  Foss.WriteF(Buffer[BufPtr]);
  132.   End;
  133.   Inc(BufPtr);
  134.   If Foss.KeyPressedF
  135.      Then Begin
  136.           Case Upcase(Foss.ReadKeyF) Of
  137.            'S' : Stop:=True;
  138.            'P' : Foss.PressANYKey;
  139.           End; {Case}
  140.           End;
  141.   End;
  142.  End;
  143. AAAFile.Close;
  144.  
  145. Foss.OutputFilterOn;
  146. End;
  147.  
  148. Function DisplayFile( Foss     : FossilObject;
  149.                       FileName : ComStr):Boolean;
  150. Begin
  151. DisplayFile:=True;
  152. If GlobalInfo.UseGraphics And
  153.    GlobalInfo.UseAvatar And
  154.    ExistFile(FileName+'.AVT')
  155.    Then Begin
  156.         Display(Foss,FileName+'.AVT');
  157.         Exit;
  158.         End;
  159.  
  160. If GlobalInfo.UseGraphics And
  161.    ExistFile(FileName+'.ANS')
  162.    Then Begin
  163.         Display(Foss,FileName+'.ANS');
  164.         Exit;
  165.         End;
  166.  
  167. If ExistFile(FileName+'.ASC')
  168.    Then Display(Foss,FileName+'.ASC')
  169.    Else DisplayFile:=False;
  170. End;
  171.  
  172. Procedure ShowTextFile( Foss     : FossilObject;
  173.                         FileName : ComStr;
  174.                         Title    : String);
  175.  
  176. Var STFile  : Text;
  177.     TextBuf : Array[0..1023] Of Char;
  178.     Stop    : Boolean;
  179.     Lines   : Word;
  180.     Line    : String;
  181. Begin
  182. FileMode:=ReadOnly+ShareDenyNone;
  183. If Not ExistFile(FileName)
  184.    Then Exit;
  185.  
  186. Assign(STFile,FileName);
  187. SetTextBuf(STFile,TextBuf);
  188. Reset(STFile);
  189. If IoResult<>0
  190.    Then Exit;
  191.  
  192. Stop:=False;
  193.  
  194. Lines:=0;
  195. If Title<>''
  196.    Then Begin
  197.         Foss.WriteF('^0');
  198.         Foss.ClrScrF;
  199.         Foss.WriteLnF(Title);
  200.         Foss.WriteLnF('');
  201.         Inc(Lines,2);
  202.         End;
  203.  
  204. While Not (Stop Or Eof(STFile)) Do
  205.  Begin
  206.  ReadLn(STFile,Line);
  207.  Foss.WriteLnF(Line);
  208.  Inc(Lines);
  209.  
  210.  If Foss.KeyPressedF
  211.     Then Begin
  212.          Case Upcase(Foss.ReadKeyF) Of
  213.           'S' : Stop:=True;
  214.           'P' : Foss.PressAnyKey;
  215.          End;
  216.          End;
  217.  
  218.  If GlobalInfo.UseMoreYN And
  219.     (Lines= (GlobalInfo.ScreenLength -2)) { For the press enter line.. }
  220.     Then Begin
  221.  
  222.          Lines:=0;
  223.          Foss.WriteLnF('');
  224.          Stop:=Foss.PressEnterOrStop;
  225.          If (Not Stop) and
  226.             (Title<>'')
  227.             Then Begin
  228.                  Foss.WriteF('^0');
  229.                  Foss.ClrScrF;
  230.                  Foss.WriteLnF(Title);
  231.                  Foss.WriteLnF('');
  232.                  Inc(Lines,2);
  233.                  End;
  234.  
  235.          End;
  236.  End;
  237.  
  238. Close(StFile);
  239. If Not Stop
  240.    Then Begin
  241.         While Lines<=(GlobalInfo.ScreenLength-2) Do
  242.           Begin
  243.           Foss.WriteLnF('');
  244.           Inc(Lines);
  245.           End;
  246.         Foss.PressEnter;
  247.         End;
  248. Foss.WriteF('^0');
  249. End;
  250.  
  251. Procedure ShowHelpFile( Foss     : FossilObject;
  252.                         FileName : ComStr;
  253.                         Title    : String);
  254.  
  255. Var STFile  : Text;
  256.     TextBuf : Array[0..1023] Of Char;
  257.     Stop    : Boolean;
  258.     Lines   : Word;
  259.     Line    : String;
  260. Begin
  261. FileMode:=ReadOnly+ShareDenyNone;
  262. If Not ExistFile(FileName)
  263.    Then Exit;
  264.  
  265. Assign(STFile,FileName);
  266. SetTextBuf(STFile,TextBuf);
  267. Reset(STFile);
  268. If IoResult<>0
  269.    Then Exit;
  270.  
  271. Stop:=False;
  272.  
  273. Lines:=0;
  274. If Title<>''
  275.    Then Begin
  276.         Foss.ClrScrF;
  277.         Foss.WriteLnF(Title);
  278.         Foss.WriteLnF('');
  279.         Inc(Lines,2);
  280.         End;
  281.  
  282. While Not (Stop Or Eof(STFile)) Do
  283.  Begin
  284.  ReadLn(STFile,Line);
  285.  If Pos('$$',Line)=1
  286.     Then Begin
  287.          While Lines<=(GlobalInfo.ScreenLength-2) Do
  288.           Begin
  289.           Foss.WriteLnF('');
  290.           Inc(Lines);
  291.           End;
  292.          Stop:=Foss.PressEnterOrStop;
  293.          If (Not Stop) and
  294.             (Title<>'')
  295.             Then Begin
  296.                  Foss.WriteF('^0');
  297.                  Foss.ClrScrF;
  298.                  Foss.WriteLnF(Title);
  299.                  Foss.WriteLnF('');
  300.                  Lines:=2;
  301.                  End;
  302.          End
  303.     Else Begin
  304.          Foss.WriteLnF(Line);
  305.          Inc(Lines);
  306.          End;
  307.  
  308.  If Foss.KeyPressedF
  309.     Then Begin
  310.          Case Upcase(Foss.ReadKeyF) Of
  311.           'S' : Stop:=True;
  312.           'P' : Foss.PressAnyKey;
  313.          End;
  314.          End;
  315.  
  316.  If GlobalInfo.UseMoreYN And
  317.     (Lines= (GlobalInfo.ScreenLength -2)) { For the press enter line.. }
  318.     Then Begin
  319.  
  320.          Lines:=0;
  321.          Foss.WriteLnF('');
  322.          Stop:=Foss.PressEnterOrStop;
  323.          If (Not Stop) and
  324.             (Title<>'')
  325.             Then Begin
  326.                  Foss.WriteF('^0');
  327.                  Foss.ClrScrF;
  328.                  Foss.WriteLnF(Title);
  329.                  Foss.WriteLnF('');
  330.                  Inc(Lines,2);
  331.                  End;
  332.  
  333.          End;
  334.  End;
  335.  
  336. Close(StFile);
  337. If Not Stop
  338.    Then Begin
  339.         While Lines<=(GlobalInfo.ScreenLength-2) Do
  340.           Begin
  341.           Foss.WriteLnF('');
  342.           Inc(Lines);
  343.           End;
  344.         Foss.PressEnter;
  345.         End;
  346. Foss.WriteF('^0');
  347. End;
  348.  
  349. End.
  350.  
  351.  
  352.