home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Education
/
collectionofeducationcarat1997.iso
/
COMPUSCI
/
TOT11.ZIP
/
TOTDEM11.ZIP
/
DEMIO22.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1991-02-11
|
11KB
|
422 lines
program DemoIOTwentyTwo;
{demIO22 - This example illustrates how you could use the
Toolkit to develop a two-screen input form}
Uses DOS, CRT,
totFAST, totREAL, totIO1, totIO2, totSTR, totDATE, totMSG;
Const
MsgX=25;
MsgY=19;
Type
RecordInfo = record
FirstLast: string[40];
Company: string[40];
Addr1: string[40];
Addr2: string[40];
City: string[25];
State: string[20];
Zip: string[9];
Country: string[30];
Tel: string[20];
OrderDate: longint;
OrderQuantity: word;
UnitPrice: extended;
OtherGarbage: array[1..5] of string[40];
end;
var
ActivePage:shortint;
ActiveRecord: RecordInfo;
Result: tAction;
{Now the input fields}
UpKey,DownKey,PgDnKey,PgUpKey,F1key: HotkeyIOOBJ;
Page1But, Page2But, OKBut, CancelBut, HelpBut: Strip3DIOOBJ;
FirstLastField,
CompanyField,
Addr1Field,
Addr2Field,
CityField,
StateField,
CountryField,
Field2A,Field2B,Field2C,Field2D,Field2E: StringIOOBJ;
ZipField,
TelField: PictureIOOBJ;
OrderDateField: DateIOOBJ;
OrderQuantityField: IntIOOBJ;
UnitPriceField: FixedRealIOOBJ;
Controlkeys: ControlKeysIOOBJ;
Page1,Page2: FormOBJ;
{$F+}
procedure ContexturalHelp(ID:word);
{A not too helpful help window!}
var HelpTxt: MessageOBJ;
begin
with HelpTxt do
begin
Init(1,' Help ');
AddLine('');
Addline(' You need help!! It''s going ');
Addline(' to be a long day. Just press ');
if (ID in [101..104]) or (ID = HelpID) then
begin
Addline('enter to select the button, ');
Addline('or TAB to change fields. ');
end
else
begin
Addline(' the keys and enter the');
case ID of
1: AddLine(' Customer''s name. ');
2: AddLine(' Company name. ');
3,4: AddLine(' Company''s street address. ');
5: AddLine(' Company''s City. ');
6: AddLine(' Company''s State. ');
7: AddLine(' Company''s Zip. ');
8: AddLine(' Company''s country details. ');
9: AddLine(' telephone number. ');
10: AddLine(' order date. ');
11: AddLine(' order quantity. ');
12: AddLine(' unit price. ');
21: AddLine(' A data! ');
22: AddLine(' B data! ');
23: AddLine(' C data! ');
24: AddLine(' D data! ');
25: AddLine(' E data! ');
else AddLine('something!');
end; {Case}
end;
AddLine('');
Show;
Done;
end;
end; {ContexturalHelp}
{$F-}
procedure RecordToForm;
{Updates the form objects with the contents of the record}
begin
with ActiveRecord do
begin
FirstLastField.SetValue(FirstLast);
CompanyField.SetValue(Company);
Addr1Field.SetValue(Addr1);
Addr2Field.SetValue(Addr2);
CityField.SetValue(City);
StateField.SetValue(State);
CountryField.SetValue(Country);
ZipField.SetValue(Zip);
TelField.SetValue(Tel);
OrderDateField.SetValue(OrderDate);
OrderQuantityField.SetValue(OrderQuantity);
UnitPriceField.SetValue(UnitPrice);
Field2A.SetValue(OtherGarbage[1]);
Field2B.SetValue(OtherGarbage[2]);
Field2C.SetValue(OtherGarbage[3]);
Field2D.SetValue(OtherGarbage[4]);
Field2E.SetValue(OtherGarbage[5]);
end;
end; {RecordToForm}
procedure FormToRecord;
{Updates the record with the values entered into the form}
begin
with ActiveRecord do
begin
Firstlast := FirstLastField.GetValue;
Company := CompanyField.GetValue;
Addr1 := Addr1Field.GetValue;
Addr2 := Addr2Field.GetValue;
City := CityField.GetValue;
State := StateField.GetValue;
Country := CountryField.GetValue;
Zip := ZipField.GetValue;
Tel := TelField.GetValue;
OrderDate := OrderDateField.GetValue;
OrderQuantity := OrderQuantityField.GetValue;
UnitPrice := UnitPriceField.GetValue;
OtherGarbage[1] := Field2A.GetValue;
OtherGarbage[2] := Field2B.GetValue;
OtherGarbage[3] := Field2C.GetValue;
OtherGarbage[4] := Field2D.GetValue;
OtherGarbage[5] := Field2E.GetValue;
end;
end; {FormToRecord}
procedure InitFields;
{Initializes all of the field objects}
begin
F1Key.Init(315,help);
PgDnKey.Init(337,Stop2);
PgUpKey.Init(329,Stop3);
UpKey.Init(328,PrevField);
DownKey.Init(336,NextField);
with Page1But do
begin
Init(10,23,' Page ~1~ ',Stop1);
SetID(101);
SetHotkey(376);
SetMessage(MsgX,MsgY,'Edit page one data');
end;
with Page2But do
begin
Init(10,23,' Page ~2~ ',Stop1);
SetID(102);
SetHotkey(377);
SetMessage(MsgX,MsgY,'Edit page two data');
end;
with OKBut do
begin
Init(25,23,' ~O~K ',Finished);
SetID(103);
SetHotkey(280);
SetMessage(MsgX,MsgY,'Save input to database');
end;
with CancelBut do
begin
Init(40,23,' ~C~ancel ',Escaped);
SetID(104);
SetHotkey(302);
SetMessage(MsgX,MsgY,'Abort and go home');
end;
with HelpBut do
begin
Init(55,23,' ~H~elp ',Help);
SetID(HelpID);
SetHotkey(291);
SetMessage(MsgX,MsgY,'Seek further guidance from the machine!');
end;
with FirstLastField do
begin
Init(25,4,40);
SetID(1);
SetForceCase(true);
SetCase(Upper);
SetLabel('Customer Name');
SetMessage(MsgX,MsgY,'Name in FIRST M. LAST format');
end;
with CompanyField do
begin
Init(25,5,40);
SetID(2);
SetLabel('Company');
SetMessage(MsgX,MsgY,'Enter the FULL company name');
end;
with Addr1Field do
begin
Init(25,6,40);
SetID(3);
SetLabel('Address');
SetMessage(MsgX,MsgY,'Street address only no PO BOXES!');
end;
with Addr2Field do
begin
Init(25,7,40);
SetID(4);
SetMessage(MsgX,MsgY,'Add second line if necessary.');
end;
with CityField do
begin
Init(25,8,25);
SetID(5);
SetLabel('City');
SetMessage(MsgX,MsgY,'Enter the City name');
end;
with StateField do
begin
Init(25,9,20);
SetID(6);
SetForceCase(true);
SetCase(Upper);
SetLabel('State');
SetMessage(MsgX,MsgY,'Enter the State, Province or County');
end;
with ZipField do
begin
Init(55,9,'#####-####');
SetID(7);
SetLabel('Zip');
SetMessage(MsgX,MsgY,'Enter the 9 digit ZIP or postal code');
end;
with CountryField do
begin
Init(25,10,30);
SetID(8);
SetForceCase(true);
SetCase(Upper);
SetLabel('Country');
SetMessage(MsgX,MsgY,'Leave empty for USA customers');
end;
with TelField do
begin
Init(25,12,'(###) ###-####');
SetID(9);
SetLabel('Telephone');
SetMessage(MsgX,MsgY,'Leave empty for international customers');
end;
with OrderDateField do
begin
Init(25,14,MMDDYY);
SetID(10);
SetLabel('Order date');
SetRules(EraseDefault+AllowNull);
SetMessage(MsgX,MsgY,'Enter date in format MM/DD/YY');
end;
with OrderQuantityField do
begin
Init(45,14,2);
SetID(11);
SetMinMax(1,15);
SetLabel('Quantity');
SetRules(EraseDefault+AllowNull);
SetMessage(MsgX,MsgY,'Enter number of units ordered');
end;
with UnitPriceField do
begin
Init(59,14,3,2);
SetID(12);
SetMinMax(10.0,499.99);
SetLabel('Price');
SetRules(EraseDefault+AllowNull);
SetMessage(MsgX,MsgY,'Enter price per item');
end;
with Field2A do
begin
Init(25,4,40);
SetID(21);
SetLabel('Field A');
SetMessage(MsgX,MsgY,'Enter the Field A data');
end;
with Field2B do
begin
Init(25,7,40);
SetID(22);
SetLabel('Field B');
SetMessage(MsgX,MsgY,'Enter the Field B data');
end;
with Field2C do
begin
Init(25,10,40);
SetID(23);
SetLabel('Field C');
SetMessage