home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
DP Tool Club 9
/
CD_ASCQ_09_1193.iso
/
news
/
558
/
field3
/
old3demo.pas
< prev
next >
Wrap
Pascal/Delphi Source File
|
1993-07-11
|
5KB
|
159 lines
Program old_demo; { OLD3DEMO.PAS }
Uses Crt,Dos,field3;
{ This program is a rewrite of Michael H. Hughes original demo TESTKEY.PAS
to use FIELD3.PAS. It illustrates the use of the field3 functions to
generate a screen display and to allow input. It has no other purpose.
If you compare OLD3DEMO.PAS with FLD3DEMO.PAS, you will note that the
styles are different. It follows that the unit field3 is a rather basic
building block and can be used in many different ways. }
Type linestring = String[80];
Var pickcount,titlenumber,fldnum,maxfldnum,keyreturn: Byte;
title1,items1,title2,items2,title3,items3: Byte;
pointer,marker: Char;
title,path,description: linestring;
picklist: Array[1..10] Of String[30];
paperlength: Integer;
rate,amount: Real;
justify,pitch,lines: Byte;
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:='Interactive Data Entry Demonstration';
GotoXY(39-(length(title) Div 2),2);Write(title);
path:=''; description:='';
paperlength:=66;
rate:=0.0; amount:=0.0;
justify:=1; pitch:=1; lines:=1;
GotoXY(9,10); Write('Path: ');
GotoXY(2,11); Write('Description: ');
GotoXY(5,13); Write('Page (paper) Length: ',paperlength:3);
GotoXY(18,14); Write('Amount: ',amount:7:2);
GotoXY(20,15); Write('Rate: ',rate:5:3);
{ Define picklists }
picklist[1]:='Format';
picklist[2]:='Unjustified';
picklist[3]:='Justified';
title1:=1;
items1:=2;
picklist[4]:='Pitch';
picklist[5]:='10';
picklist[6]:='12';
picklist[7]:='16';
title2:=4;
items2:=3;
picklist[8]:='Lines/Inch';
picklist[9]:='Six';
picklist[10]:='Eight';
title3:=8;
items3:=2;
{ Write pick lists }
writepicklist(53,8,items1,title1);
writepicklist(53,12,items2,title2);
writepicklist(53,17,items3,title3);
{ Step through fields }
maxfldnum:=8;
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: keyreturn:=editfield(15,10,30,0,caplet,optional,path);
2: keyreturn:=editfield(15,11,30,0,alsymb,manditory,description);
3: keyreturn:=editfield(30,13,3,0,usnint,optional,paperlength);
4: keyreturn:=editfield(26,14,7,2,sgndec,optional,amount);
5: keyreturn:=editfield(28,15,5,3,usndec,manditory,rate);
6: keyreturn:=getpick(53,9,items1,justify,picklist[title1+1]);
7: keyreturn:=getpick(53,13,items2,pitch,picklist[title2+1]);
8: keyreturn:=getpick(53,18,items3,lines,picklist[title3+1]);
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:
If fldnum > 1
Then dec(fldnum)
Else fldnum:=maxfldnum;
dnarrowkey:
If fldnum < maxfldnum
Then inc(fldnum)
Else fldnum:=1;
tabkey:
; { no action }
shiftabkey:
; { no action }
esckey:
If firstpass
Then Write(char(7))
Else fldnum:=0
Else
End; { keyreturn Case statement}
Until fldnum = 0; { Data entry or editing completed }
note('END to Accept, ENTER to Edit, ESC to exit!');
Repeat
keyreturn:=getspecialkey;
If (keyreturn <> endkey) And
(keyreturn <> enterkey) And
(keyreturn <> esckey)
Then
errmsg('Must be END (Accept), ENTER (Edit), Or ESC (Exit)!');
Until
(keyreturn = enterkey) Or
(keyreturn = endkey) Or
(keyreturn = esckey);
If keyreturn = enterkey Then
Begin
firstpass:=false;
fldnum:=1
End;
Until
(keyreturn = endkey) Or { Screen accepted }
(keyreturn = esckey); { Screen cancled }
cursor(underline); { cursor on }
NormVideo;
End. { Demo }