_INSIDE OBJECT PROFESSIONAL_ by Gary Entsminger [LISTING ONE] program Edit; uses OpCrt, OpRoot, OpCmd, OpFrame, OpWindow, OpMemo, OpEditor; var TE : TextEditor; FSize : LongInt; ExitCommand : Word; AllDone : Boolean; begin if not TE.InitCustom(2, 4, 79, 24, { Window coordinates } DefaultColorSet, { ColorSet } DefWindowOptions or wBordered, { Win options } 65521) { Buffer size } then begin WriteLn('Failed to init TextEditor. Status = ', InitStatus); Halt; end; { use built-in status and error handlers provided by OPMEMO } TE.SetStatusProc(MemoStatus); TE.SetErrorProc(MemoError); { Create and Read a text file } TE.ReadFile('AnyFile', FSize); AllDone := False; repeat TE.Process; ExitCommand := TE.GetLastCommand; case ExitCommand of ccSaveExit, { Save and exit -- file already saved } ccAbandonFile, { Abandon file } ccError : { Fatal error } AllDone := True; {...user exit commands..} end; until AllDone; TE.Erase; TE.Done; ClrScr; end. [LISTING TWO] program HelloWorld; Uses HWMain, OpSwap; begin HelloWorldMain; end; unit HWMain; interface uses OpInLine, OpSwap1; procedure HelloWorldMain; implementation const HotKey = $080F { code for ALT-TAB } Swap1 = 'Hello1.SWP'; Swap2 = 'Hello2.SWP'; {$F+} procedure PopUpEntryPoint; begin Writeln('Hello World'); end; {$F-} procedure HelloWorldMain; begin SetSwapMsgOn( not WillSwapUseEMS(ParagraphsToKeep) ); { define the popup } if DefinePop(HotKey, PopUpEntryPoint, Ptr($SSeg,SPtr)) then begin Writeln('PopUp loaded, press to activate.'); { Make PopUp routines active. } PopUpsOn; { Try to go resident. } StayResSwap(ParagraphsToKeep, 0, Swap1, Swap2, True); end; { If we get here, report failure. } Writeln('Unable to go resident. '); end; end. [LISTING THREE] program CommandWindowExample; {EXCMDWIN.PAS} uses OpCrt, OpRoot, OpCmd, OpFrame, OpWindow; const {Define a trivial KeySet of a few cursor commands} KeyMax = 18; KeySet : array[0..KeyMax] of Byte = ( {length keys command type key sequence} 3, $00, $48, ccUp, {Up} 3, $00, $50, ccDown, {Down} 3, $00, $4B, ccLeft, {Left} 3, $00, $4D, ccRight, {Right} 2, $1B, ccQuit); {Esc} type SampleWindow = object(CommandWindow) procedure Process; virtual; end; var Commands : CommandProcessor; CmdWin : SampleWindow; Finished : Boolean; procedure SampleWindow.Process; begin repeat {Get a command} GetNextCommand; case GetLastCommand of ccUp : WriteLn('ccUp'); ccDown : WriteLn('ccDown'); ccLeft : WriteLn('ccLeft'); ccRight : WriteLn('ccRight'); ccQuit : WriteLn('ccQuit'); ccChar : WriteLn('ccChar: ', Char(Lo(GetLastKey))); else WriteLn('ccNone'); end; until (GetLastCommand = ccQuit) or (GetLastCommand = ccError); end; begin {Make a small CommandProcessor} Commands.Init(@KeySet, KeyMax); {Make a bordered CommandWindow} if not CmdWin.InitCustom(30, 5, 50, 15, {Window coordinates} DefaultColorSet, {Color set} wBordered+wClear+wSaveContents, {Window options} Commands, {Command processor} ucNone) {Unit code} then begin WriteLn('Failed to init CommandWindow. Status = ', InitStatus); Halt; end; {Add headers and draw window} CmdWin.wFrame.AddHeader(' Command window ', heTC); CmdWin.wFrame.AddHeader(' to Quit ', heBC); CmdWin.Draw; {Get and process commands} Finished := False; repeat CmdWin.Process; case CmdWin.GetLastCommand of ccQuit : Finished := True; {Quit} ccError : begin {Error} WriteLn('Error: ', CmdWin.GetLastError); Finished := True; end; ccUser0..ccUser55 : WriteLn('user command'); {Handle exit command} end; until Finished; {Clean up} CmdWin.Done; Commands.Done; end.