home *** CD-ROM | disk | FTP | other *** search
- {TUG PDS CERT 1.01 (Pascal)
-
- ==========================================================================
-
- TUG PUBLIC DOMAIN SOFTWARE CERTIFICATION
-
- The Turbo User Group (TUG) is recognized by Borland International as the
- official support organization for Turbo languages. This file has been
- compiled and verified by the TUG library staff. We are reasonably certain
- that the information contained in this file is public domain material, but
- it is also subject to any restrictions applied by its author.
-
- This diskette contains PROGRAMS and/or DATA determined to be in the PUBLIC
- DOMAIN, provided as a service of TUG for the use of its members. The
- Turbo User Group will not be liable for any damages, including any lost
- profits, lost savings or other incidental or consequential damages arising
- out of the use of or inability to use the contents, even if TUG has been
- advised of the possibility of such damages, or for any claim by any
- other party.
-
- To the best of our knowledge, the routines in this file compile and function
- properly in accordance with the information described below.
-
- If you discover an error in this file, we would appreciate it if you would
- report it to us. To report bugs, or to request information on membership
- in TUG, please contact us at:
-
- Turbo User Group
- PO Box 1510
- Poulsbo, Washington USA 98370
-
- --------------------------------------------------------------------------
- F i l e I n f o r m a t i o n
-
- * DESCRIPTION
- This program illustrates the use of the field functions to generate a
- screen display and to allow input.
-
- * ASSOCIATED FILES
- FIELD.PAS
- FLDDEMO.PAS
- FLDTEST.PAS
- OLDDEMO.PAS
- FIELD.TXT
-
- * CHECKED BY
- DRM 08/08/88
-
- * KEYWORDS
- TURBO PASCAL V4.0
-
- ==========================================================================
- }
- Program fieldtest;
-
- Uses Crt,Dos,field;
-
- { This program illustrates the use of the field functions to generate
- a screen display and to allow input. It has no other purpose. }
-
- Type linestring = String[80];
- direction = (up,down,left,right);
- fieldnumber = 1..11;
-
- Const nextfldnum: Array[fieldnumber,direction] Of Byte
- = ((3,2,9,4),
- (1,3,9,5),
- (2,1,10,6),
- (6,5,1,7),
- (4,6,2,8),
- (5,4,3,8),
- (8,8,4,9),
- (7,7,5,10),
- (10,10,7,1),
- (9,9,8,3),
- (10,1,10,1));
-
- Var pickcount,titlenumber,fldnum,maxfldnum,keyreturn: Byte;
- title1,items1,title2,items2,title3,items3: Byte;
- title4,items4,title5,items5,title6,items6: Byte;
- title7,items7,title8,items8,title9,items9: Byte;
- title10,items10,col,row,len,decpla: Byte;
- rv,ft,rq,cl,fl,rw,dp,zv,hitc,lotc: Byte;
- required: Boolean;
- pointer,marker: Char;
- title,strbuf: linestring;
- intbuf: Integer;
- decbuf: Real;
- fldtype: fldtypes;
- picklist: Array[1..62] Of String[30];
-
- Procedure writepicklist(col,row,maxpick,titlenumber: Byte);
-
- Begin
- GotoXY(col,row);
- Write(picklist[titlenumber]);
- For pickcount:=1 To maxpick Do
- Begin
- GotoXY(col+1,row+pickcount);
- Write(marker,' ',picklist[titlenumber+pickcount])
- End;
- End;
-
- Begin { Demo program }
- reversevideo:=False;
- zerovoid:=True;
- hitxtcolor:=Yellow;
- lotxtcolor:=LightGray;
- txtbkgnd:=Black;
- pointer:=chr(pickpointer);
- marker:=chr(pickmarker);
- cursor(hidden);
- TextMode(CO80);
- TextColor(lotxtcolor);
- TextBackground(txtbkgnd);
- ClrScr;
-
- { Display headings and default values }
- title:='Test Program for FIELD.TPU';
- GotoXY(39-(length(title) Div 2),1);Write(title);
-
- { Define picklists }
- picklist[1]:='Display Styles:';
- picklist[2]:='Inverse Video';
- picklist[3]:='Marker Blocks';
- title1:=1;
- items1:=2;
- rv:=2;
- picklist[4]:='Field Types:';
- picklist[5]:='All Symbols';
- picklist[6]:='Lower ASCII';
- picklist[7]:='Capital Letters';
- picklist[8]:='Digets (String)';
- picklist[9]:='Integer';
- picklist[10]:='Signed Integer';
- picklist[11]:='Unsigned Real';
- picklist[12]:='Real (Signed)';
- title2:=4;
- items2:=8;
- ft:=8;
- picklist[13]:='Field Input:';
- picklist[14]:='Optional';
- picklist[15]:='Manditory';
- title3:=13;
- items3:=2;
- rq:=1;
- picklist[16]:='Column:';
- picklist[17]:=' 1';
- picklist[18]:='21';
- picklist[19]:='41';
- picklist[20]:='61';
- title4:=16;
- items4:=4;
- cl:=1;
- picklist[21]:='Decimal Places:';
- picklist[22]:=' 0';
- picklist[23]:=' 1';
- picklist[24]:=' 2';
- picklist[25]:=' 3';
- picklist[26]:=' 4';
- picklist[27]:=' 5';
- title5:=21;
- items5:=6;
- dp:=1;
- picklist[28]:='Zero Input:';
- picklist[29]:='Accepted';
- picklist[30]:='Rejected';
- title6:=28;
- items6:=2;
- zv:=1;
- picklist[31]:='Rows:';
- picklist[32]:='20';
- picklist[33]:='21';
- picklist[34]:='22';
- picklist[35]:='23';
- title7:=31;
- items7:=4;
- rw:=2;
- picklist[36]:='Field Length:';
- picklist[37]:=' 1';
- picklist[38]:=' 2';
- picklist[39]:=' 3';
- picklist[40]:=' 4';
- picklist[41]:=' 5';
- picklist[42]:=' 6';
- picklist[43]:=' 7';
- picklist[44]:=' 8';
- picklist[45]:=' 9';
- picklist[46]:='10';
- title8:=36;
- items8:=10;
- fl:=6;
- picklist[47]:='Hi Text Color';
- picklist[48]:='White';
- picklist[49]:='Yellow';
- picklist[50]:='Magenta';
- picklist[51]:='Red';
- picklist[52]:='Cyan';
- picklist[53]:='Green';
- picklist[54]:='Blue';
- title9:=47;
- items9:=7;
- hitc:=2;
- picklist[55]:='Lo Text Color';
- picklist[56]:='White';
- picklist[57]:='Brown';
- picklist[58]:='Magenta';
- picklist[59]:='Red';
- picklist[60]:='Cyan';
- picklist[61]:='Green';
- picklist[62]:='Blue';
- title10:=55;
- items10:=7;
- lotc:=1;
-
- { Initialize buffers }
- strbuf:='';
- intbuf:=0;
- decbuf:=0;
-
- Repeat
-
- { Write pick lists }
- writepicklist(1,3,items1,title1);
- writepicklist(1,7,items2,title2);
- writepicklist(1,17,items3,title3);
- writepicklist(24,3,items4,title4);
- writepicklist(24,9,items5,title5);
- writepicklist(24,17,items6,title6);
- writepicklist(43,3,items7,title7);
- writepicklist(43,9,items8,title8);
- writepicklist(62,3,items9,title9);
- writepicklist(62,12,items10,title10);
-
- { Step through fields }
- maxfldnum:=11;
- fldnum:=1;
- firstpass:=True;
-
- Repeat { Until screen accepted or canceled }
-
- Repeat { Until data entry or editing completed }
-
- { Execute the next field function }
- Case fldnum Of
-
- 1: Begin
- keyreturn:=getpick(1,4,items1,rv,picklist[title1+1]);
- If rv =1 Then reversevideo:=True
- Else reversevideo:=False
- End;
- 2: Begin
- keyreturn:=getpick(1,8,items2,ft,picklist[title2+1]);
- If ft = 1 Then fldtype:=alsymb;
- If ft = 2 Then fldtype:=ascii;
- If ft = 3 Then fldtype:=caplet;
- If ft = 4 Then fldtype:=digits;
- If ft = 5 Then fldtype:=usnint;
- If ft = 6 Then fldtype:=sgnint;
- If ft = 7 Then fldtype:=usndec;
- If ft = 8 Then fldtype:=sgndec
- End;
- 3: Begin
- keyreturn:=getpick(1,18,items3,rq,picklist[title3+1]);
- If rq =1 Then required:=False
- Else required:=True
- End;
- 4: Begin
- keyreturn:=getpick(24,4,items4,cl,picklist[title4+1]);
- If cl = 1 Then col:=1;
- If cl = 2 Then col:=21;
- If cl = 3 Then col:=41;
- If cl = 4 Then col:=61
- End;
- 5: Begin
- keyreturn:=getpick(24,10,items5,dp,picklist[title5+1]);
- decpla:=dp-1
- End;
- 6: Begin
- keyreturn:=getpick(24,18,items6,zv,picklist[title6+1]);
- If zv = 1 Then zerovoid:=False
- Else zerovoid:=True
- End;
- 7: Begin
- keyreturn:=getpick(43,4,items7,rw,picklist[title7+1]);
- row:=rw+19
- End;
- 8: Begin
- keyreturn:=getpick(43,10,items8,fl,picklist[title8+1]);
- len:=fl
- End;
- 9: Begin
- keyreturn:=getpick(62,4,items9,hitc,picklist[title9+1]);
- If hitc = 1 Then hitxtcolor:=White;
- If hitc = 2 Then hitxtcolor:=Yellow;
- If hitc = 3 Then hitxtcolor:=LightMagenta;
- If hitc = 4 Then hitxtcolor:=LightRed;
- If hitc = 5 Then hitxtcolor:=LightCyan;
- If hitc = 6 Then hitxtcolor:=LightGreen;
- If hitc = 7 Then hitxtcolor:=LightBlue
- End;
- 10: Begin
- keyreturn:=getpick(62,13,items10,lotc,picklist[title10+1]);
- If lotc = 1 Then lotxtcolor:=LightGray;
- If lotc = 2 Then lotxtcolor:=Brown;
- If lotc = 3 Then lotxtcolor:=Magenta;
- If lotc = 4 Then lotxtcolor:=Red;
- If lotc = 5 Then lotxtcolor:=Cyan;
- If lotc = 6 Then lotxtcolor:=Green;
- If lotc = 7 Then lotxtcolor:=Blue
- End;
- 11: Begin
- If fldtype < usnint Then
- keyreturn:=editfield
- (col,row,len,decpla,fldtype,required,strbuf)
- Else If fldtype < usndec Then
- keyreturn:=editfield(col,row,len,decpla,fldtype,required,intbuf)
- Else
- keyreturn:=editfield(col,row,len,decpla,fldtype,required,decbuf)
- End;
- Else
- End; { fldnum Case statement }
-
- { Select the next fldnum based on keyreturn }
- Case keyreturn Of
- enterkey:
- If fldnum < maxfldnum
- Then inc(fldnum)
- Else fldnum:=0;
- uparrowkey:
- fldnum:=nextfldnum[fldnum,up];
- dnarrowkey:
- fldnum:=nextfldnum[fldnum,down];
- tabkey:
- fldnum:=nextfldnum[fldnum,right];
- shiftabkey:
- fldnum:=nextfldnum[fldnum,left];
- esckey:
- If firstpass
- Then Write(char(7))
- Else If fldnum = 11
- Then fldnum:=0
- Else fldnum:=11;
- Else
- End; { keyreturn Case statement}
-
- Until fldnum = 0; { Data entry or editing completed }
-
- note('HOME to Restart, ENTER to Edit, ESC to exit!');
- Repeat
- keyreturn:=getspecialkey;
- If (keyreturn <> homekey) And
- (keyreturn <> enterkey) And
- (keyreturn <> esckey)
- Then
- errmsg('Must be HOME (Restart), ENTER (Edit), Or ESC (Exit)!');
- Until
- (keyreturn = enterkey) Or
- (keyreturn = homekey) Or
- (keyreturn = esckey);
- If keyreturn = enterkey Then
- Begin
- firstpass:=false;
- fldnum:=1
- End;
-
- Until
- (keyreturn = homekey) Or { Screen restart }
- (keyreturn = esckey); { Screen cancled }
- If keyreturn = homekey Then
- Begin
- col:=1;
- For row:=21 To 24 Do
- Begin
- GotoXY(col,row);
- ClrEol
- End
- End;
- Until keyreturn = esckey;
- cursor(underline); { cursor on }
- NormVideo;
- End. { Demo }