_STRUCTURED PROGRAMMING COLUMN_ by Jeff Duntemann [LISTING ONE] PROCEDURE TMortgageApp.HandleEvent(VAR Event : TEvent); {-----------------------------------------------------------------} { The following are procedures local to TMortgageApp.HandleEvent: } {-----------------------------------------------------------------} PROCEDURE Calculator; VAR P: PCalculator; BEGIN P := New(PCalculator, Init); P^.HelpCtx := hcNoContext; { Used to be hcCalculator } IF ValidView(P) <> NIL THEN Desktop^.Insert(P); END; PROCEDURE Calendar; VAR P: PCalendarWindow; BEGIN P := New(PCalendarWindow, Init); P^.HelpCtx := hcNoContext; { Used to be hcCalendar } Desktop^.Insert(ValidView(P)); END; BEGIN TApplication.HandleEvent(Event); IF Event.What = evCommand THEN BEGIN CASE Event.Command OF cmNewMortgage : NewMortgage; cmLoadMortgage : LoadMortgage; cmSaveMortgage : SaveMortgage; cmCloseAll : CloseAll; cmPrint : PrintMortgage; cmCalculator : Calculator; { Calculator is NOT a method! } cmCalendar : Calendar; { Calendar is NOT a method! } ELSE Exit; END; { CASE } ClearEvent(Event); END; END; [LISTING TWO] {-----------------------------------------------------------} { This file describes mods needed to make the TV calculator } { respond to the broadcast command cmCloseBC used in Jeff } { Duntemann's HCALC mortgage calculator program. } { THIS IS NOT A COMPLETE, COMPILABLE FILE! This is just a } { collection of mods to make to Borland's TV Demo file } { CALC.PAS. } { By Jeff Duntemann 8/2/92 } {-----------------------------------------------------------} { Add this constant definition up front somewhere in CALC.PAS: } CONST cmCloseBC = 196; { Modify the object definition for TCalculator like this: } TCalculator = OBJECT(TDialog) CONSTRUCTOR Init; PROCEDURE HandleEvent(VAR Event : TEvent); VIRTUAL; END; { Add this method definition to the CALC.PAS file: } PROCEDURE TCalculator.HandleEvent(VAR Event : TEvent); BEGIN TDialog.HandleEvent(Event); IF Event.What = evBroadcast THEN IF Event.Command = cmCloseBC THEN Done; END;