1
{------------------------------------------------------------------------------
4
------------------------------------------------------------------------------
6
Programmer: Ken J. Wright, ken@cncware.com
9
Purpose - Demonstrate the use of oCrt in a simulated database record editor.
11
-------------------------------<< REVISIONS >>---------------------------------
12
Ver | Date | Prog| Description
13
-------+------------+-----+----------------------------------------------------
14
1.00 | 06/29/2000 | kjw | Initial Release.
15
-------------------------------------------------------------------------------
39
address : Array [1..MAXROWS] of tAddress;
40
fields : Array [1..MAXCOLS] of tFields;
50
Procedure Display(row : integer);
52
With address[row] Do Begin
53
For i := 1 to MAXCOLS Do Begin
54
With fields[i] Do Begin
63
win.FWrite(x,y,att1,x+wid-1,s);
70
{ bind the arrow keys so they trigger an exit }
73
win.ec.Special := ^I^R^L^P^N;
74
m1 := win.ec.AddChMap(#0+Char(nKeyRight)+^R#0);
75
m2 := win.ec.AddChMap(#0+Char(nKeyLeft)+^L#0);
76
win.FWrite(1,win.Rows,48,0,'[F2]-Arrows');
79
Procedure UnBindArrows;
81
win.ec.Special := ^R^L^P^N;
84
win.FWrite(1,win.Rows,62,0,'[F2]-Arrows');
88
FillChar(address,SizeOf(address),#0);
89
With address[1] Do Begin
90
FirstName := 'Rainer';
91
LastName := 'Hantsch';
92
Street := '12345 Some Street';
98
For i := 1 to MAXCOLS Do Begin
99
With fields[i] Do Begin
101
1 : Begin x := 14; y := 2; wid := 40; pic := ''; End;
102
2 : Begin x := 14; y := 3; wid := 40; pic := ''; End;
103
3 : Begin x := 14; y := 4; wid := 40; pic := ''; End;
104
4 : Begin x := 14; y := 5; wid := 2; pic := ''; End;
105
5 : Begin x := 19; y := 5; wid := 5; pic := '*#'; End;
106
6 : Begin x := 27; y := 5; wid := 30; pic := ''; End;
111
att1 := 19; { field display color }
112
att2 := 31; { field edit color }
113
att3 := 23; { labels color }
115
nMakeWindow(win,1,1,60,10,att3,30,63,true,center,' Rainer''s Address Book ');
117
Align(center,center);
118
FWrite(1,Rows,48,Cols,'[F2]-Arrows [F10]-Exit [Tab]-NextField [^P]-Prev [^N]-Next');
120
Writeln(' First Name [ ]');
121
Writeln(' Last Name [ ]');
122
Writeln(' Street [ ]');
123
Write (' Zip/City [ ]-[ ] [ ]');
125
ec.AddChMap(^P#0#0+Char(nKeyPgUp));
126
ec.AddChMap(^N#0#0+Char(nKeyPgDn));
134
FWrite((cols-10) div 2,rows-1,26,0,'Record #'+s);
135
With address[row] Do Begin
136
With fields[col] Do Begin
146
s := Edit(x,y,att2,x+wid-1,x+Length(s),s,ch);
156
FWrite(x,y,att1,x+wid-1,s);
167
nKeyDown : Case col of
173
nKeyF2 : UnBindArrows; { use arrows for editing }
174
nKeyF10 : IsDone := true;
178
If row > MAXROWS Then row := MAXROWS;
179
If row < 1 Then row := 1;
180
If col > MAXCOLS Then col := 1;
181
If col < 1 Then col := MAXCOLS;
182
If Ord(ch) in [nKeyPgUp,nKeyPgDn] Then Display(row);
183
If Ord(ch) <> nKeyF2 Then BindArrows; { arrows for navigation }