home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
DP Tool Club 9
/
CD_ASCQ_09_1193.iso
/
news
/
558
/
field3
/
fld3test.pas
< prev
next >
Wrap
Pascal/Delphi Source File
|
1993-07-11
|
10KB
|
338 lines
Program field_3_test; { FLD3TEST.PAS }
Uses Crt,Dos,field3;
{ This program was developed by Frank Wood to test the field2 unit.
It allows most of the features of FIELD3.PAS to be tested and will
permit a new user to get a feel for the unit. It is also a rather
elaborate demonstration of the field3 function getpick. }
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..64] 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 }
GotoXY(43,1);Write('Test Program for FIELD3.TPU');
{ 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]:='Numbers (String)';
picklist[9]:='Integer';
picklist[10]:='Signed Integer';
picklist[11]:='Unsign Dec Form';
picklist[12]:='Dec Form w Sign';
picklist[13]:='Free Form Real';
picklist[14]:='Real FF w Sign';
title2:=4;
items2:=10;
ft:=8;
picklist[15]:='Field Input:';
picklist[16]:='Optional';
picklist[17]:='Manditory';
title3:=15;
items3:=2;
rq:=1;
picklist[18]:='Column:';
picklist[19]:=' 1';
picklist[20]:='21';
picklist[21]:='41';
picklist[22]:='61';
title4:=18;
items4:=4;
cl:=1;
picklist[23]:='Decimal Places:';
picklist[24]:=' 0';
picklist[25]:=' 1';
picklist[26]:=' 2';
picklist[27]:=' 3';
picklist[28]:=' 4';
picklist[29]:=' 5';
title5:=23;
items5:=6;
dp:=1;
picklist[30]:='Zero Input:';
picklist[31]:='Accepted';
picklist[32]:='Rejected';
title6:=30;
items6:=2;
zv:=1;
picklist[33]:='Rows:';
picklist[34]:='21';
picklist[35]:='22';
picklist[36]:='23';
picklist[37]:='24';
title7:=33;
items7:=4;
rw:=2;
picklist[38]:='Field Length:';
picklist[39]:=' 1';
picklist[40]:=' 2';
picklist[41]:=' 3';
picklist[42]:=' 4';
picklist[43]:=' 5';
picklist[44]:=' 6';
picklist[45]:=' 7';
picklist[46]:=' 8';
picklist[47]:=' 9';
picklist[48]:='10';
title8:=38;
items8:=10;
fl:=6;
picklist[49]:='Hi Text Color';
picklist[50]:='White';
picklist[51]:='Yellow';
picklist[52]:='Magenta';
picklist[53]:='Red';
picklist[54]:='Cyan';
picklist[55]:='Green';
picklist[56]:='Blue';
title9:=49;
items9:=7;
hitc:=2;
picklist[57]:='Lo Text Color';
picklist[58]:='White';
picklist[59]:='Brown';
picklist[60]:='Magenta';
picklist[61]:='Red';
picklist[62]:='Cyan';
picklist[63]:='Green';
picklist[64]:='Blue';
title10:=57;
items10:=7;
lotc:=1;
{ Initialize buffers }
strbuf:='';
intbuf:=0;
decbuf:=0;
Repeat
{ Write pick lists }
writepicklist(1,1,items1,title1);
writepicklist(1,5,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,2,items1,rv,picklist[title1+1]);
If rv =1 Then reversevideo:=True
Else reversevideo:=False
End;
2: Begin
keyreturn:=getpick(1,6,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;
If ft = 9 Then fldtype:=usnufd;
If ft = 10 Then fldtype:=sgnufd
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+20
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
noteactive:=False;
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
note('Use '#24', '#25', TAB, and Shft-TAB keys to select field; ESC to Exit');
firstpass:=false;
fldnum:=1
End;
Until
(keyreturn = homekey) Or { Screen restart }
(keyreturn = esckey); { Screen cancled }
If keyreturn = homekey Then
Begin
noteactive:=False;
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 Program }