home *** CD-ROM | disk | FTP | other *** search
/ ftp.wwiv.com / ftp.wwiv.com.zip / ftp.wwiv.com / pub / MISC / TGARTS.ZIP / SAMPLE.ZIP / TGCONFIG.PAS < prev    next >
Pascal/Delphi Source File  |  1998-12-19  |  5KB  |  152 lines

  1.  
  2.  
  3. Program TGConfig;
  4.  
  5. Uses Crt;
  6.  
  7. {$I Telegard.inc} (* Includes the Telegard structures for use *)
  8.  
  9. Var Cfg_File : File of Configrec;
  10.     Cfg_Record : configrec; (* Stores the record here *)
  11.     Key  : Char;
  12.  
  13. Procedure Read_Record;  { This reads the record into memory }
  14. Begin
  15.    Assign(Cfg_File,'Config.tg');
  16.    Reset(Cfg_File);
  17.    Read(Cfg_File,Cfg_Record);  (* only 1 record to read so read it *)
  18.    {Cfg_record contains the config.tg after it was read}
  19.    Close(Cfg_File);
  20. end;
  21.  
  22. Procedure BBS_Info;
  23. Var Vstring,V2 : String;
  24.     Name : String;
  25. Begin
  26.   Clrscr;GotoXY(10,10);  {Shows the TG version}
  27.   Textcolor(10);  Write('Telegard version : v');
  28.   Str(lo(cfg_record.versionid),vstring); (* Convert the word into strings *)
  29.   Str(hi(cfg_record.versionid),v2);      (* using hi and lo functions     *)
  30.   {See Lo and Hi functions for details but it takes parts of the word}
  31.   If lo(cfg_record.versionid)<10 then Vstring := '.0'+vstring;
  32.   Textcolor(11);  Writeln(v2+vstring);
  33.   Writeln;
  34.   Textcolor(15);  Write('           BBS Name :');
  35.   Textcolor(14);  Writeln(cfg_record.bbsname);
  36.   Textcolor(15);  Write('   BBS Phone Number :');
  37.   Textcolor(14);  Writeln(cfg_record.bbsphone);
  38.   Textcolor(15);  Write('       BBS Location :');
  39.   Textcolor(14);  Writeln(cfg_record.bbslocation);
  40.   Textcolor(15);  Write(' Sysop''s Name/Alias :');
  41.   Textcolor(14);  Writeln(cfg_record.sysopname);
  42.   Writeln;Textcolor(12);
  43.   Writeln('        Let''s rename your BBS');
  44.   Writeln;Textcolor(13);
  45.   Writeln('Enter your new BBS Name below (or enter for current name)');
  46.   Writeln('Max of 80 characters only!');
  47.   Textcolor(9);Write(':');
  48.   Readln(Name);
  49.   If Name='' then Name := Cfg_record.bbsname;
  50.   Textcolor(11);Writeln('Current BBS Name :'+Name);
  51.   Writeln('Press any key to continue...');
  52.   Repeat until Keypressed;
  53.   Cfg_record.bbsname := Name; (* Hold the new value *)
  54. end;
  55.  
  56. Procedure Paths;
  57. Var PathData : String;
  58. Begin
  59.   Clrscr;GotoXY(10,1);
  60.   Textcolor(15);  Writeln('Telegard Current Paths');
  61.   Writeln('Paths are listed in this order:');
  62.   Writeln('Data, Text, Language, Menu, Logs, Msg, semaphore, attaches');
  63.   Writeln('swap path, archiver, protocol, File, and script path.');
  64.   Gotoxy(1,6);Textcolor(14);
  65.  
  66.   Writeln(':'+cfg_record.datapath);
  67.   Writeln(':'+cfg_record.textpath);
  68.   Writeln(':'+cfg_record.langpath);
  69.   Writeln(':'+cfg_record.menupath);
  70.   Writeln(':'+cfg_record.logspath);
  71.   Writeln(':'+cfg_record.msgpath);
  72.   Writeln(':'+cfg_record.semaphore);
  73.   Writeln(':'+cfg_record.attachpath);
  74.   Writeln(':'+cfg_record.swappath);
  75.   Writeln(':'+cfg_record.arcpath);
  76.   Writeln(':'+cfg_record.protpath);
  77.   Writeln(':'+cfg_record.filepath);
  78.   Writeln(':'+cfg_record.scriptpath);
  79.   Textcolor(13);Writeln('I bet your Script path is empty :)');
  80.   Textcolor(12);Writeln('Let''s change your path to your menus.');
  81.   Writeln;Textcolor(13);
  82.   Writeln('Enter your new menu path below (or enter for current name)');
  83.   Writeln('Max of 79 characters only! Do not forget trailing \.');
  84.   Textcolor(9);Write(':');
  85.   Readln(PathData);
  86.   If PathData ='' then PathData:= Cfg_record.menupath;
  87.   Textcolor(11);Writeln('Current Menus Path below');
  88.   Writeln(':'+pathdata);
  89.   Writeln('Press any key to continue...');
  90.   Repeat until Keypressed;
  91.   Cfg_record.menupath := Pathdata; (* Hold new value *)
  92. end;
  93.  
  94. Procedure Write_Data;
  95. Begin
  96.   Clrscr;Gotoxy(10,10);
  97.   Textcolor(12);
  98.   Writeln('If you want to change the data then press Y otherwise hit any key');
  99.   Repeat until keypressed;
  100.   Key := Readkey;Key:=Upcase(key);
  101.   If Key='Y' then
  102.   Begin
  103.     (* This section of code will actually write the new data *)
  104.     Assign(Cfg_File,'config.tg');
  105.     Reset(cfg_file);
  106.     Write(Cfg_file, cfg_record);  (* Simply rewrites the data to file *)
  107.     Close(cfg_file);
  108.   end;
  109.   Textcolor(15);Writeln;
  110.   If Key='Y' then
  111.   Begin
  112.     Writeln('Data has been changed!!!');
  113.     Writeln('Try to quit and come back in view to verify the changes');
  114.   end else
  115.   Begin
  116.     Writeln('Data has NOT been changed!!!');
  117.   end;
  118.   Writeln('Press any key to continue...');
  119.   Repeat until keypressed;
  120. end;
  121.  
  122. Procedure Display_Menu;
  123.  
  124. Begin
  125.   ClrScr;GotoXY(10,10);Textcolor(14);
  126.   Writeln('Config.tg Demo');
  127.   Writeln('    ** Menu **');
  128.   Writeln(' A.  Show BBS Info');
  129.   Writeln(' B.  Show Paths');
  130.   Writeln(' C.  Write the new data (save changed data)');
  131.   Writeln(' Q.  Quit');
  132.   Writeln;
  133.   Writeln('Press A-C or Q please');
  134.   Repeat
  135.     Key := Readkey;Key := Upcase(Key);
  136.   Until (Keypressed) or (Key>=chr(65)) and (Key<=chr(67)) or (key='Q');
  137.   Case Key of
  138.     'A': BBS_Info;
  139.     'B': Paths;
  140.     'C': Write_Data;
  141.   end;
  142. end;
  143.  
  144. Begin
  145.   Read_Record;
  146.   Repeat
  147.     Display_Menu
  148.   until Key = 'Q';
  149.   Writeln; Writeln('Bye Bye now!');
  150. End.
  151.  
  152.