home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PASCAL / FORUM25C.ZIP / CONFIGSR.ZIP / CONFIG.PAS next >
Encoding:
Pascal/Delphi Source File  |  1989-02-08  |  19.4 KB  |  906 lines

  1. program config;
  2.  
  3. {$R-,S+,I-,D+,V-,B-,N-,L+ }
  4. {$M 16384,5000,5000 }
  5.  
  6. uses crt,
  7.      scrnunit,scrninpt,general,prompts,
  8.      gentypes,configrt;
  9.  
  10. const normalcolor=6;
  11.       boldcolor=2;
  12.       barcolor=$1f;
  13.       inputcolor=3;
  14.       choicecolor=6;
  15.       datacolor=15;
  16.  
  17. var prompt:promptset;
  18.  
  19. procedure writeconfig;
  20. var q:file of configsettype;
  21. begin
  22.   assign (q,'Forum.CFG');
  23.   rewrite (q);
  24.   write (q,configset);
  25.   close (q)
  26. end;
  27.  
  28. procedure formatconfig;
  29. var cnt:integer;
  30. begin
  31.   versioncode:=thisversioncode;
  32.   longname[0]:=chr(0);
  33.   shortname[0]:=chr(0);
  34.   sysopname[0]:=chr(0);
  35.   getdir (0,forumdir);
  36.   if forumdir[length(forumdir)]<>'\' then forumdir:=forumdir+'\';
  37.   textdir:=forumdir+'text\';
  38.   uploaddir:=forumdir+'files\';
  39.   boarddir:=forumdir+'boards\';
  40.   overlaypath[0]:=#0;
  41.   asciidownload[0]:=#0;
  42.   textfiledir:=forumdir+'textfile\';
  43.   doordir:=forumdir+'doors\';
  44.   modemsetupstr:='ATS0=1|';
  45.   modemhangupstr:='+++~~~ATH|';
  46.   modemdialprefix:='ATDT';
  47.   modemdialsuffix:='|';
  48.   defbaudrate:=1200;
  49.   usecom:=1;
  50.   anonymouslevel:=5;
  51.   numwelcomes:=1;
  52.   mintimeout:=5;
  53.   sysoplevel:=10;
  54.   defudlevel:=0;
  55.   defudpoints:=0;
  56.   normbotcolor:=6;
  57.   normtopcolor:=2;
  58.   outlockcolor:=5;
  59.   splitcolor:=4;
  60.   statlinecolor:=3;
  61.   uploadfactor:=5;
  62.   private:=false;
  63.   autologin:=false;
  64.   useconmode:=true;
  65.   escinmsgs:=false;
  66.   bkspinmsgs:=true;
  67.   requireforms:=false;
  68.   dotchar:='.';
  69.   supportedrates:=[b1200];
  70.   downloadrates:=supportedrates;
  71.   availtime:='10:00 am';
  72.   unavailtime:='10:00 pm';
  73.   xmodemopentime:='3:00 am';
  74.   xmodemclosetime:='3:00 am';
  75.   for cnt:=1 to 100 do usertime[cnt]:=60;
  76.   level2nd:=1;
  77.   udlevel2nd:=0;
  78.   udpoints2nd:=0;
  79.   postlevel:=2;
  80.   anonymousstr:='Anonymous';
  81.   systempassword[0]:=#0;
  82.   remotedoors:=false;
  83.   allowdoors:=true;
  84.   eventtime[0]:=#0;
  85.   eventbatch[0]:=#0;
  86.   directvideomode:=true;
  87.   checksnowmode:=true;
  88.   NewUserLevel:=1;
  89.   Overlay_size := 0;
  90.   Keep_top_ten := TRUE;
  91.   User_name_prompt := 'Please enter your name [enter ''NEW'' if newuser]:';
  92.   MaxLoginTries := 4;
  93.   DataBaseLevel := 0;
  94.   VotingLevel := 0;
  95.   FileLevel := 0;
  96.   EmailLevel := 0;
  97.   BulletinLevel := 0;
  98.   AboutLevel := 0;
  99.   writeconfig
  100. end;
  101.  
  102.  
  103. type ttypetype=(TInteger,Tsstr,Tmstr,Tlstr,TBoolean,TChar,TBaudset,
  104.                 TPath,TTime,TAttrib,Tusertime,Badtype);
  105.      ptrset=record
  106.        case integer of
  107.          0:(i:^integer);
  108.          1:(l:^lstr);
  109.          2:(b:^boolean);
  110.          3:(k:^char);
  111.          4:(baudsetptr:^baudset)
  112.      end;
  113.      thing=record
  114.        text:mstr;
  115.        descrip:lstr;
  116.        ttype:ttypetype;
  117.        p:pointer;
  118.        r1,r2:integer
  119.      end;
  120.  
  121. const ttypestr:array [ttypetype] of sstr=
  122.   ('Int','sstr','mstr','lstr','Boo','Char','Baud','Path','Time',
  123.    'Attrib','Usertime','!!!!????');
  124.       colorstr:array [0..15] of mstr=
  125.   ('Black','Blue ','Green ','Cyan ','Red ','Magenta ','Brown ','White ',
  126.    'Gray ','BLUE!','GREEN!','CYAN!','RED!','MAGENTA!','Yellow','WHITE!');
  127.  
  128. const maxthings=100;
  129.       dcol=30;
  130.  
  131. var top,bot,page,numpages,numthings:integer;
  132.     things:array [1..maxthings] of thing;
  133.  
  134. procedure cb;
  135. begin
  136.   setcolor (boldcolor)
  137. end;
  138.  
  139. procedure c4;
  140. begin
  141.   setcolor (4)
  142. end;
  143.  
  144. procedure cn;
  145. begin
  146.   setcolor (normalcolor)
  147. end;
  148.  
  149. procedure c7;
  150. begin
  151.   setcolor (7)
  152. end;
  153.  
  154. function match(a1,a2:anystr):boolean;
  155. var cnt:integer;
  156. begin
  157.   match:=false;
  158.   while a1[length(a1)]=' ' do a1[0]:=pred(a1[0]);
  159.   while a2[length(a2)]=' ' do a2[0]:=pred(a2[0]);
  160.   if length(a1)<>length(a2) then exit;
  161.   for cnt:=1 to length(a1) do
  162.     if upcase(a1[cnt])<>upcase(a2[cnt]) then exit;
  163.   match:=true
  164. end;
  165.  
  166. function yesnostr (var b:boolean):sstr;
  167. begin
  168.   if b and (ord(b)<>ord(true)) then b:=true;
  169.   if b then yesnostr:='Yes' else yesnostr:='No'
  170. end;
  171.  
  172. function strr (n:integer):mstr;
  173. var q:mstr;
  174. begin
  175.   str (n,q);
  176.   strr:=q
  177. end;
  178.  
  179. function valu (q:mstr):integer;
  180. var i,s:integer;
  181. begin
  182.   val (q,i,s);
  183.   if s=1
  184.     then valu:=0
  185.     else valu:=i
  186. end;
  187.  
  188. function whichpage (n:integer):integer;
  189. begin
  190.   whichpage:=((n-1) div 20)+1
  191. end;
  192.  
  193. function whichline (n:integer):integer;
  194. begin
  195.   whichline:=n-20*(whichpage(n)-1)+2
  196. end;
  197.  
  198. function getbaudstr (var q:baudset):lstr;
  199. var w:lstr;
  200.     cnt:baudratetype;
  201. begin
  202.   w[0]:=chr(0);
  203.   for cnt:=firstbaud to lastbaud do
  204.     if cnt in q then w:=w+strr(baudarray[cnt])+' ';
  205.   if length(w)=0 then w:='None';
  206.   getbaudstr:=w
  207. end;
  208.  
  209. function varstr (n:integer):string;
  210. var pu:pointer;
  211.     p:ptrset absolute pu;
  212. begin
  213.   pu:=things[n].p;
  214.   case things[n].ttype of
  215.     tinteger:varstr:=strr(p.i^);
  216.     tlstr,tmstr,tsstr,tpath,ttime:varstr:=p.l^;
  217.     tboolean:varstr:=yesnostr(p.b^);
  218.     tchar:varstr:=p.k^;
  219.     tbaudset:varstr:=getbaudstr (p.baudsetptr^);
  220.     tattrib:varstr:=colorstr[p.i^];
  221.     tusertime:varstr:='(Choose this choice to configure user daily time)';
  222.     else varstr:='??!?!?!'
  223.   end
  224. end;
  225.  
  226. procedure writevar (n:integer);
  227. begin
  228.   cb;
  229.   write (varstr(n));
  230.   cn; clreol;
  231.   writeln
  232. end;
  233.  
  234. procedure gotopage (p:integer);
  235. var cnt,cy:integer;
  236. begin
  237.   if p<1 then p:=1;
  238.   if p>numpages then p:=numpages;
  239.   if p<>page then begin
  240.     if page<>0 then freeprompts (prompt);
  241.     page:=p;
  242.     gotoxy (1,1);
  243.     cn; write ('Page ');
  244.     cb; write (page);
  245.     cn; write (' of ');
  246.     cb; write (numpages);
  247.     cn; writeln (':  ');
  248.     writeln;
  249.     top:=(page-1)*20+1;
  250.     bot:=top+19;
  251.     if bot>numthings then bot:=numthings;
  252.     beginprompts (prompt);
  253.     for cnt:=top to top+19 do begin
  254.       cy:=cnt-top+3;
  255.       gotoxy (1,cy);
  256.       cn; clreol;
  257.       if cnt<=bot then begin
  258.         addprompt (prompt,command,prompt,5,cnt-top+3,things[cnt].text+':');
  259.         setinputwid (prompt,0);
  260.         drawprompt (prompt);
  261.         gotoxy (1,cy);
  262.         cn; write (cnt:2,'. ');
  263.         gotoxy (dcol,wherey);
  264.         writevar (cnt)
  265.       end
  266.     end
  267.   end
  268. end;
  269.  
  270. procedure readdata;
  271. var q:text;
  272.     t:mstr;
  273.  
  274.   procedure dataerror (n:lstr);
  275.   begin
  276.     writeln ('Record ',numthings,': '+n);
  277.     halt
  278.   end;
  279.  
  280.   procedure illtype;
  281.   begin
  282.     dataerror ('Invalid type: '+t)
  283.   end;
  284.  
  285.   procedure getrange (t:mstr; var r1,r2:integer);
  286.   var sp,da,n1,n2:integer;
  287.   begin
  288.     sp:=pos(' ',t);
  289.     r1:=-32767;
  290.     r2:=32767;
  291.     if sp=0 then exit;
  292.     t:=copy(t,sp+1,255);
  293.     if length(t)<1 then exit;
  294.     da:=pos('-',t);
  295.     if (da=1) and (length(t)=1) then exit;
  296.     if da=0 then begin
  297.       r1:=valu(t);
  298.       r2:=r1;
  299.       exit
  300.     end;
  301.     n1:=valu(copy(t,1,da-1));
  302.     n2:=valu(copy(t,da+1,255));
  303.     if da=1 then begin
  304.       r2:=n2;
  305.       exit
  306.     end;
  307.     r1:=n1;
  308.     if da=length(t) then exit;
  309.     r2:=n2
  310.   end;
  311.  
  312.   procedure gettype (t:mstr; var tt:ttypetype);
  313.   var sp:integer;
  314.       fw:mstr;
  315.   begin
  316.     tt:=ttypetype(0);
  317.     sp:=pos(' ',t);
  318.     if sp=0
  319.       then fw:=t
  320.       else fw:=copy(t,1,sp-1);
  321.     while tt<>badtype do
  322.       begin
  323.         if match(fw,ttypestr[tt]) then exit;
  324.         tt:=succ(tt)
  325.       end;
  326.     tt:=badtype;
  327.     illtype
  328.   end;
  329.  
  330. begin
  331.   assign (q,'Config.Dat');
  332.   reset (q);
  333.   numthings:=0;
  334.   if ioresult<>0 then dataerror ('File CONFIG.DAT not found!');
  335.   while not eof(q) do begin
  336.     numthings:=numthings+1;
  337.     with things[numthings] do begin
  338.       readln (q,text);
  339.       readln (q,descrip);
  340.       readln (q,t);
  341.       gettype (t,ttype);
  342.       if ttype=tinteger then getrange (t,r1,r2)
  343.     end
  344.   end;
  345.   close (q)
  346. end;
  347.  
  348. procedure assignptrs;
  349. var cnt:integer;
  350.  
  351.   procedure s (var q);
  352.   begin
  353.     cnt:=cnt+1;
  354.     things[cnt].p:=@q
  355.   end;
  356.  
  357. begin
  358.   cnt:=0;
  359.   s (longname);
  360.   s (shortname);
  361.   s (sysopname);
  362.   s (autologin);
  363.   s (textdir);
  364.   s (boarddir);
  365.   s (uploaddir);
  366.   s (textfiledir);
  367.   s (doordir);
  368.   s (overlaypath);
  369.   s (Overlay_size);
  370.   s (supportedrates);
  371.   s (downloadrates);
  372.   s (defbaudrate);
  373.   s (usecom);
  374.   s (modemsetupstr);
  375.   s (modemhangupstr);
  376.   s (modemdialprefix);
  377.   s (modemdialsuffix);
  378.   s (sysoplevel);
  379.   s (anonymouslevel);
  380.   s (numwelcomes);
  381.   s (private);
  382.   s (directvideomode);
  383.   s (checksnowmode);
  384.   s (useconmode);
  385.   s (escinmsgs);
  386.   s (bkspinmsgs);
  387.   s (normbotcolor);
  388.   s (normtopcolor);
  389.   s (outlockcolor);
  390.   s (splitcolor);
  391.   s (statlinecolor);
  392.   s (usertime);
  393.   s (mintimeout);
  394.   s (dotchar);
  395.   s (asciidownload);
  396.   s (defudlevel);
  397.   s (defudpoints);
  398.   s (NewUserLevel);
  399.   s (level2nd);
  400.   s (udlevel2nd);
  401.   s (udpoints2nd);
  402.   s (postlevel);
  403.   s (uploadfactor);
  404.   s (availtime);
  405.   s (unavailtime);
  406.   s (xmodemopentime);
  407.   s (xmodemclosetime);
  408.   s (systempassword);
  409.   s (anonymousstr);
  410.   s (requireforms);
  411.   s (remotedoors);
  412.   s (allowdoors);
  413.   s (eventtime);
  414.   s (eventbatch);
  415.   s (Keep_top_ten);
  416.   s (User_name_prompt);
  417.   s (MaxLoginTries);
  418.   s (DataBaseLevel);
  419.   s (VotingLevel);
  420.   s (FileLevel);
  421.   s (EmailLevel);
  422.   s (BulletinLevel);
  423.   s (AboutLevel);
  424.   if cnt<>numthings then begin
  425.     writeln ('Error in number of items of CONFIG.DAT');
  426.     writeln ('Expected: ',numthings);
  427.     writeln ('Actual:   ',cnt);
  428.     halt
  429.   end
  430. end;
  431.  
  432. procedure byebye;
  433. begin
  434.   clearwindow (normalcolor);
  435.   gotoxy (38,24);
  436.   cb; writeln ('Bye!');
  437.   halt
  438. end;
  439.  
  440. procedure abortyn;
  441. var q:sstr;
  442. begin
  443.   gotoxy (1,24);
  444.   c4;
  445.   write ('Confirm abort [Y/N]: ');
  446.   cn;
  447.   clreol;
  448.   buflen:=1;
  449.   readln (q);
  450.   if length(q)>0 then if upcase(q[1])='Y' then byebye
  451. end;
  452.  
  453. procedure getinput (n:integer; editit:boolean);
  454. var y:integer;
  455.     inp:lstr;
  456.     t:thing;
  457.     pu:pointer;
  458.     p:ptrset absolute pu;
  459.  
  460.   procedure reshow;
  461.   begin
  462.     gotoxy (dcol,y);
  463.     writevar (n)
  464.   end;
  465.  
  466.   procedure showintrange;
  467.   begin
  468.     c7;
  469.     with t do
  470.       if r1=-32767
  471.         then if r2=32767
  472.           then write ('No range limitation.')
  473.           else write ('Maximum value: ',r2)
  474.         else if r2=32767
  475.           then write ('Minimum value: ',r1)
  476.           else write ('Valid values range from ',r1,' to ',r2);
  477.     cn
  478.   end;
  479.  
  480.   procedure doint;
  481.   var n,s:integer;
  482.       k:char;
  483.   begin
  484.     val (inp,n,s);
  485.     gotoxy (1,24);
  486.     if s<>0
  487.       then
  488.         begin
  489.           c4;
  490.           writeln ('Invalid number!  A number must be from -32767 to 32767.');
  491.           cn;
  492.           write ('Press any key...');
  493.           clreol;
  494.           k:=bioskey
  495.         end
  496.       else if (n>=t.r1) and (n<=t.r2)
  497.         then p.i^:=n
  498.         else
  499.           begin
  500.             c4;
  501.             writeln ('Range error!  Must be within the above limits!  ');
  502.             cn;
  503.             write ('Press any key...');
  504.             clreol;
  505.             k:=bioskey
  506.           end
  507.   end;
  508.  
  509.   procedure dostr;
  510.   begin
  511.     if (inp='N') or (inp='n') then inp:='';
  512.     p.l^:=inp
  513.   end;
  514.  
  515.   procedure doboolean;
  516.   begin
  517.     case upcase(inp[1]) of
  518.       'Y':p.b^:=true;
  519.       'N':p.b^:=false
  520.     end
  521.   end;
  522.  
  523.   procedure dochar;
  524.   begin
  525.     p.k^:=inp[1]
  526.   end;
  527.  
  528.   procedure dopath;
  529.   var lc:char;
  530.       cur:lstr;
  531.       n:integer;
  532.   begin
  533.     lc:=inp[length(inp)];
  534.     if (length(inp)<>1) or (upcase(lc)<>'N')
  535.       then if (lc<>':') and (lc<>'\') then inp:=inp+'\';
  536.     dostr;
  537.     if inp[length(inp)]='\' then inp[0]:=pred(inp[0]);
  538.     getdir (0,cur);
  539.     chdir (inp);
  540.     n:=ioresult;
  541.     chdir (cur);
  542.     if n=0 then exit;
  543.     c4; gotoxy (1,24);
  544.     write ('Path doesn''t exist!  ');
  545.     cn; write ('Create it now? '); clreol;
  546.     readln (cur);
  547.     if length(cur)=0 then exit;
  548.     if upcase(cur[1])<>'Y' then exit;
  549.     mkdir (inp);
  550.     if ioresult=0 then exit;
  551.     gotoxy (1,24);
  552.     c4; write ('Error creating directory!  ');
  553.     cn; write ('Press any key...');
  554.     clreol;
  555.     lc:=bioskey
  556.   end;
  557.  
  558.   procedure dotime;
  559.   var c,s,l:integer;
  560.       d1,d2,d3,d4:char;
  561.       ap,m:char;
  562.  
  563.     function digit (k:char):boolean;
  564.     begin
  565.       digit:=ord(k) in [48..57]
  566.     end;
  567.  
  568.   begin
  569.     l:=length(inp);
  570.     if l=1 then begin
  571.       if upcase(inp[1])='N' then dostr;
  572.       exit
  573.     end;
  574.     if (l<7) or (l>8) then exit;
  575.     c:=pos(':',inp);
  576.     if c<>l-5 then exit;
  577.     s:=pos(' ',inp);
  578.     if s<>l-2 then exit;
  579.     d2:=inp[c-1];
  580.     if l=7
  581.       then d1:='0'
  582.       else d1:=inp[1];
  583.     d3:=inp[c+1];
  584.     d4:=inp[c+2];
  585.     ap:=upcase(inp[s+1]);
  586.     m:=upcase(inp[s+2]);
  587.     if d1='1' then if d2>'2' then d2:='!';
  588.     if (d1>='0') and (d1<='1') and digit(d2) and (d3>='0') and (d3<='5')
  589.        and digit(d4) and ((ap='A') or (ap='P')) and (m='M') then dostr
  590.   end;
  591.  
  592.   procedure dobaud;
  593.   var inp:lstr;
  594.       n:integer;
  595.       cnt:baudratetype;
  596.   label bfound,again;
  597.   begin
  598.     gotoxy (1,24);
  599.     repeat
  600.       gotoxy (wherex,24);
  601.       write ('Baud rate to toggle [CR to quit]: ');
  602.       clreol;
  603.       buflen:=4;
  604.       readln (inp);
  605.       gotoxy (1,24);
  606.       if length(inp)=0 then exit;
  607.       n:=valu(inp);
  608.       for cnt:=b110 to b9600 do if n=baudarray[cnt] then goto bfound;
  609.       cb; write ('Not supported!  '); cn;
  610.       goto again;
  611.       bfound:
  612.       if cnt in p.baudsetptr^
  613.         then p.baudsetptr^:=p.baudsetptr^-[cnt]
  614.         else p.baudsetptr^:=p.baudsetptr^+[cnt];
  615.       reshow;
  616.       again:
  617.     until 0=1
  618.   end;
  619.  
  620.   procedure dousertime;
  621.   var input:lstr;
  622.       n:integer;
  623.       buffer:array [1..4096] of byte;
  624.       b:block;
  625.  
  626.     procedure refresh;
  627.     var cnt:integer;
  628.     begin
  629.       clearwindow (normalcolor);
  630.       gotoxy (1,1);
  631.       cn;
  632.       writeln('Level Time | Level Time | Level Time | Level Time | Level Time');
  633.       writeln('-----------|------------|------------|------------|-----------');
  634.       gotoxy (1,3);
  635.       for cnt:=1 to 100 do begin
  636.         write (cnt:4,': ',usertime[cnt]:4);
  637.         if (cnt mod 5)=0 then writeln else write (' | ')
  638.       end
  639.     end;
  640.  
  641.     procedure setone (n,v:integer);
  642.     var x,y:integer;
  643.     begin
  644.       x:=((n-1) mod 5)*13+7;
  645.       y:=((n-1) div 5)+3;
  646.       gotoxy (x,y);
  647.       write (v:4);
  648.       usertime[n]:=v
  649.     end;
  650.  
  651.     procedure getone (n:integer);
  652.     var x,y,v:integer;
  653.     begin
  654.       x:=((n-1) mod 5)*13+7;
  655.       y:=((n-1) div 5)+3;
  656.       gotoxy (x,y);
  657.       write ('    ');
  658.       gotoxy (x,y);
  659.       buflen:=4;
  660.       readln (input);
  661.       v:=valu(input);
  662.       if (v<1) or (v>1000) then v:=usertime[n];
  663.       setone (n,v)
  664.     end;
  665.  
  666.     function getn (txt:lstr):integer;
  667.     var input:lstr;
  668.     begin
  669.       gotoxy (1,23);
  670.       write (txt,': ');
  671.       clreol;
  672.       buflen:=4;
  673.       readln (input);
  674.       getn:=valu(input)
  675.     end;
  676.  
  677.     function getlvl (txt:lstr):integer;
  678.     var n:integer;
  679.     begin
  680.       n:=getn (txt);
  681.       if (n<1) or (n>100) then n:=0;
  682.       getlvl:=n
  683.     end;
  684.  
  685.     procedure pattern;
  686.     var st,en,ba,se,cn:integer;
  687.     begin
  688.       st:=getlvl ('Starting level of pattern');
  689.       if st=0 then exit;
  690.       en:=getlvl ('Ending level of pattern');
  691.       if en<st then exit;
  692.       ba:=getn ('Time for level '+strr(st));
  693.       if (ba<1) or (ba>1000) then exit;
  694.       se:=getn ('Additional time per level');
  695.       if (se<0) or (se>1000) then exit;
  696.       cn:=st;
  697.       repeat
  698.         setone (cn,ba);
  699.         if ba+se<1000
  700.           then ba:=ba+se
  701.           else ba:=1000;
  702.         cn:=cn+1
  703.       until cn>en
  704.     end;
  705.  
  706.   var k:char;
  707.   begin
  708.     setblock (b,1,1,80,25);
  709.     readblock (b,buffer);
  710.     refresh;
  711.     repeat
  712.       repeat
  713.         gotoxy (1,24);
  714.         write ('Number to change, [P] for a pattern, or [Q] to quit: ');
  715.         clreol;
  716.         readln (input)
  717.       until length(input)>0;
  718.       k:=upcase(input[1]);
  719.       n:=valu(input);
  720.       if (n>=1) and (n<=100) then getone(n) else
  721.         case k of
  722.           'P':pattern
  723.         end
  724.     until k='Q';
  725.     writeblock (b,buffer)
  726.   end;
  727.  
  728.   procedure showattribhelp;
  729.   var cnt:integer;
  730.  
  731.     procedure demo;
  732.     begin
  733.       setcolor (cnt);
  734.       write (cnt:2,')',colorstr[cnt],' ')
  735.     end;
  736.  
  737.   begin
  738.     gotoxy (1,23);
  739.     for cnt:=0 to 7 do demo;
  740.     gotoxy (1,24);
  741.     for cnt:=8 to 15 do demo;
  742.     cn
  743.   end;
  744.  
  745.   procedure doattrib;
  746.   var cnt,v:integer;
  747.       k:char;
  748.   begin
  749.     v:=valu(inp);
  750.     if ((v=0) and (inp[1]<>'0')) or (v<0) or (v>15) then begin
  751.       v:=-1;
  752.       for cnt:=0 to 15 do if match (inp,colorstr[cnt]) then v:=cnt;
  753.       if v=-1 then exit
  754.     end;
  755.     p.i^:=v
  756.   end;
  757.  
  758. begin
  759.   t:=things[n];
  760.   pu:=t.p;
  761.   gotopage (whichpage(n));
  762.   y:=whichline(n);
  763.   if not (t.ttype in [tbaudset,tusertime]) then begin
  764.     gotoxy (1,23);
  765.     clreol;
  766.     writeln;
  767.     clreol;
  768.     writeln;
  769.     write (t.descrip);
  770.     clreol;
  771.     gotoxy (1,24);
  772.     case t.ttype of
  773.       tinteger:
  774.         begin
  775.           buflen:=6;
  776.           showintrange
  777.         end;
  778.       tsstr,ttime:buflen:=15;
  779.       tmstr:buflen:=30;
  780.       tlstr,tpath:buflen:=80;
  781.       tboolean,tchar:buflen:=1;
  782.       tattrib:showattribhelp
  783.     end;
  784.     if buflen+dcol>79 then buflen:=79-dcol;
  785.     gotoxy (dcol,y);
  786.     clreol;
  787.     if editit then setdefaultinput (varstr(n));
  788.     readln (inp)
  789.   end else inp[0]:=^A;
  790.   if length(inp)<>0 then
  791.     case t.ttype of
  792.       tinteger:doint;
  793.       tsstr,tmstr,tlstr:dostr;
  794.       tboolean:doboolean;
  795.       tchar:dochar;
  796.       tbaudset:dobaud;
  797.       tpath:dopath;
  798.       ttime:dotime;
  799.       tattrib:doattrib;
  800.       tusertime:dousertime
  801.     end;
  802.   reshow;
  803.   gotoxy (1,23);
  804.   clreol;
  805.   writeln;
  806.   clreol;
  807.   writeln;
  808.   clreol;
  809.   t.p:=pu;
  810.   things[n]:=t
  811. end;
  812.  
  813. procedure changenum (ns:integer; editit:boolean);
  814. var n:integer;
  815. begin
  816.   n:=ns+top-1;
  817.   if (n<1) or (n>numthings) then exit;
  818.   getinput (n,editit)
  819. end;
  820.  
  821. procedure maybemakeconfig;
  822. var f:file of configsettype;
  823.     s,w:integer;
  824. begin
  825.   s:=ofs(filler)-ofs(versioncode);
  826.   w:=sizeof(configsettype);
  827.   if s>w then begin
  828.     writeln;
  829.     writeln ('****** ERROR: CONFIGSETTYPE is too short!');
  830.     writeln ('              Size of configuration is: ',s);
  831.     writeln ('                   Bytes being written: ',w);
  832.     writeln;
  833.     halt
  834.   end;
  835.   assign (f,'Forum.CFG');
  836.   reset (f);
  837.   if ioresult=0 then begin
  838.     close (f);
  839.     exit
  840.   end;
  841.   fillchar (configset,sizeof(configset),0);
  842.   formatconfig
  843. end;
  844.  
  845. var command:sstr;
  846.     i:integer;
  847. begin
  848.   textmode (BW80);
  849.   initscrnunit;
  850.   curwindowptr^.normalcolor:=normalcolor;
  851.   curwindowptr^.boldcolor:=boldcolor;
  852.   curwindowptr^.barcolor:=barcolor;
  853.   curwindowptr^.inputcolor:=inputcolor;
  854.   curwindowptr^.choicecolor:=choicecolor;
  855.   curwindowptr^.datacolor:=datacolor;
  856.   gotoxy (1,1);
  857.   writeln ('One moment...');
  858.   readdata;
  859.   assignptrs;
  860.   maybemakeconfig;
  861.   readconfig;
  862.   i:=ioresult;
  863.   numpages:=whichpage(numthings);
  864.   page:=0;
  865.   gotopage (1);
  866.   repeat
  867.     setfilter (checksnowmode);
  868.     gotoxy (1,24);
  869.     write ('F1: Edit entry  F10: Save/exit  PgUp: Last page  PgDn: Next page  Esc: Abort');
  870.     i:=useprompts(prompt);
  871.     if bioslook in [#32..#126]
  872.       then changenum (i,false)
  873.       else case bioskey of
  874.         #187:begin          gotoxy (1,1);
  875.             write (i);
  876.             changenum (i,true);
  877.         end;
  878.         #196:begin
  879.                writeconfig;
  880.                byebye
  881.              end;
  882.         #27:abortyn;
  883.         #13:changenum (i,false);
  884.         #201:gotopage (page-1);
  885.         #209:gotopage (page+1)
  886.       end
  887.   until 0=1
  888. end.
  889.  
  890.  
  891.  
  892. (* Types are:
  893.      Int #-#           Integer in the range specified
  894.      Lstr              80 char string
  895.      Mstr              30 char string
  896.      Sstr              15 char string
  897.      Char              Single character
  898.      Boo               Boolean (y/n)
  899.      Path              Directory path
  900.      Baud              Set of baud rates
  901.      Time              Time of day
  902.      Attrib            Attribute, Black, Blue, etc.
  903.      Usertime          Special usertime per day type, doesn't print
  904. *)
  905.  
  906.