home *** CD-ROM | disk | FTP | other *** search
/ DP Tool Club 9 / CD_ASCQ_09_1193.iso / news / 558 / field3 / old3demo.pas < prev    next >
Pascal/Delphi Source File  |  1993-07-11  |  5KB  |  159 lines

  1. Program old_demo;  { OLD3DEMO.PAS }
  2.  
  3. Uses Crt,Dos,field3;
  4.  
  5. { This program is a rewrite of Michael H. Hughes original demo TESTKEY.PAS
  6.   to use FIELD3.PAS.  It illustrates the use of the field3 functions to
  7.   generate a screen display and to allow input.  It has no other purpose.
  8.   If you compare OLD3DEMO.PAS with FLD3DEMO.PAS, you will note that the
  9.   styles are different.  It follows that the unit field3 is a rather basic
  10.   building block and can be used in many different ways. }
  11.  
  12. Type linestring = String[80];
  13.  
  14. Var pickcount,titlenumber,fldnum,maxfldnum,keyreturn: Byte;
  15.     title1,items1,title2,items2,title3,items3: Byte;
  16.     pointer,marker: Char;
  17.     title,path,description: linestring;
  18.     picklist: Array[1..10] Of String[30];
  19.     paperlength: Integer;
  20.     rate,amount: Real;
  21.     justify,pitch,lines: Byte;
  22.  
  23. Procedure writepicklist(col,row,maxpick,titlenumber: Byte);
  24.  
  25. Begin
  26.   GotoXY(col,row);
  27.   Write(picklist[titlenumber]);
  28.   For pickcount:=1 To maxpick Do
  29.     Begin
  30.       GotoXY(col+1,row+pickcount);
  31.       Write(marker,' ',picklist[titlenumber+pickcount])
  32.     End;
  33. End;
  34.  
  35. Begin  { Demo program }
  36.   reversevideo:=False;
  37.   zerovoid:=True;
  38.   hitxtcolor:=Yellow;
  39.   lotxtcolor:=LightGray;
  40.   txtbkgnd:=Black;
  41.   pointer:=chr(pickpointer);
  42.   marker:=chr(pickmarker);
  43.   cursor(hidden);
  44.   TextMode(CO80);
  45.   TextColor(lotxtcolor);
  46.   TextBackground(txtbkgnd);
  47.   ClrScr;
  48.  
  49.   { Display headings and default values }
  50.   title:='Interactive Data Entry Demonstration';
  51.   GotoXY(39-(length(title) Div 2),2);Write(title);
  52.  
  53.   path:=''; description:='';
  54.   paperlength:=66;
  55.   rate:=0.0; amount:=0.0;
  56.   justify:=1; pitch:=1; lines:=1;
  57.   GotoXY(9,10); Write('Path: ');
  58.   GotoXY(2,11); Write('Description: ');
  59.   GotoXY(5,13); Write('Page (paper) Length:     ',paperlength:3);
  60.   GotoXY(18,14); Write('Amount: ',amount:7:2);
  61.   GotoXY(20,15); Write('Rate:   ',rate:5:3);
  62.  
  63.   { Define picklists }
  64.   picklist[1]:='Format';
  65.   picklist[2]:='Unjustified';
  66.   picklist[3]:='Justified';
  67.   title1:=1;
  68.   items1:=2;
  69.   picklist[4]:='Pitch';
  70.   picklist[5]:='10';
  71.   picklist[6]:='12';
  72.   picklist[7]:='16';
  73.   title2:=4;
  74.   items2:=3;
  75.   picklist[8]:='Lines/Inch';
  76.   picklist[9]:='Six';
  77.   picklist[10]:='Eight';
  78.   title3:=8;
  79.   items3:=2;
  80.  
  81.   { Write pick lists }
  82.   writepicklist(53,8,items1,title1);
  83.   writepicklist(53,12,items2,title2);
  84.   writepicklist(53,17,items3,title3);
  85.  
  86.   { Step through fields }
  87.   maxfldnum:=8;
  88.   fldnum:=1;
  89.   firstpass:=True;
  90.  
  91.   Repeat { Until screen accepted or canceled }
  92.  
  93.     Repeat { Until data entry or editing completed }
  94.  
  95.       { Execute the next field function }
  96.       Case fldnum Of
  97.         1: keyreturn:=editfield(15,10,30,0,caplet,optional,path);
  98.         2: keyreturn:=editfield(15,11,30,0,alsymb,manditory,description);
  99.         3: keyreturn:=editfield(30,13,3,0,usnint,optional,paperlength);
  100.         4: keyreturn:=editfield(26,14,7,2,sgndec,optional,amount);
  101.         5: keyreturn:=editfield(28,15,5,3,usndec,manditory,rate);
  102.         6: keyreturn:=getpick(53,9,items1,justify,picklist[title1+1]);
  103.         7: keyreturn:=getpick(53,13,items2,pitch,picklist[title2+1]);
  104.         8: keyreturn:=getpick(53,18,items3,lines,picklist[title3+1]);
  105.         Else
  106.       End;  { fldnum Case statement }
  107.  
  108.       { Select the next fldnum based on keyreturn }
  109.       Case keyreturn Of
  110.         enterkey:
  111.             If fldnum < maxfldnum
  112.             Then inc(fldnum)
  113.             Else fldnum:=0;
  114.         uparrowkey:
  115.             If fldnum > 1
  116.             Then dec(fldnum)
  117.             Else fldnum:=maxfldnum;
  118.         dnarrowkey:
  119.             If fldnum < maxfldnum
  120.             Then inc(fldnum)
  121.             Else fldnum:=1;
  122.         tabkey:
  123.             ; { no action }
  124.         shiftabkey:
  125.             ; { no action }
  126.         esckey:
  127.             If firstpass
  128.             Then Write(char(7))
  129.             Else fldnum:=0
  130.         Else
  131.       End;  { keyreturn Case statement}
  132.  
  133.     Until fldnum = 0; { Data entry or editing completed }
  134.  
  135.     note('END to Accept, ENTER to Edit, ESC to exit!');
  136.     Repeat
  137.       keyreturn:=getspecialkey;
  138.       If (keyreturn <> endkey) And
  139.          (keyreturn <> enterkey) And
  140.          (keyreturn <> esckey)
  141.       Then
  142.         errmsg('Must be END (Accept), ENTER (Edit), Or ESC (Exit)!');
  143.     Until
  144.          (keyreturn = enterkey) Or
  145.          (keyreturn = endkey) Or
  146.          (keyreturn = esckey);
  147.     If keyreturn = enterkey Then
  148.       Begin
  149.         firstpass:=false;
  150.         fldnum:=1
  151.       End;
  152.  
  153.   Until
  154.        (keyreturn = endkey) Or { Screen accepted }
  155.        (keyreturn = esckey);   { Screen cancled  }
  156.   cursor(underline); { cursor on }
  157.   NormVideo;
  158. End. { Demo }
  159.