Dec 232017
TpBkMemo adds a simplified set of blocking commands to the TpMemo editor. TpMemo is a memo editor included as part of Turbo Professional 5.0.
File TPBMEM.ZIP from The Programmer’s Corner in
Category Pascal Source Code
TpBkMemo adds a simplified set of blocking commands to the TpMemo editor. TpMemo is a memo editor included as part of Turbo Professional 5.0.
File Name File Size Zip Size Zip Type
BMEMO.PAS 9457 2749 deflated
TPBKMEMO.DOC 5789 2506 deflated
TPBKMEMO.INC 12679 3111 deflated
TPBKMEMO.PAS 61828 13193 deflated

Download File TPBMEM.ZIP Here

Contents of the TPBKMEMO.DOC file

TpBkMemo adds a simplified set of blocking commands to the TpMemo editor.
(TpMemo is a small "memo" editor included as part of Turbo Professional 5.0).

This modification builds upon code copyrighted by TurboPower Software. To
ease the process of distributing these modifications, TurboPower Software has
granted permission to distribute the modified files BMEMO.PAS and TPBKMEMO.PAS.
Since only the source code is provided, it's useless to anyone that doesn't
already own Turbo Professional 5.0 (TpMemo.obj is required to compile these
files). If you have one of the early versions of Turbo Professional 5.0
(before TpMemo was included), you'll need to download TpMemo.arc as well.

It is, or course, larger and slower than TpMemo. It's speed (or lack thereof)
could be bothersome on XT class machines with large active blocks in large
files ( >1000 lines).

Last updated on 11-25-89 to release 5.08 of Turbo Professional.

BMemo.pas - source code for demonstration "memo" editor
TpBkMemo.pas - modified TpMemo.pas 5.02 - block editing routines
TpBkMemo.doc - this documentation file

These files add a subset of common block operations to TpMemo. All block
operations work on a line basis rather than a character basis. There are
two reasons for this simplistic approach: first, to keep the size and
complexity of the modifications to a minimum; second, because it was felt that
such block operations would be adequate for a "memo" editor.

^KB,F7 - mark begin block (current line)
^KK,F8 - mark end block (current line)
^KC - copy block
^KV - move block
^KR - read block from file
^KW - write block to file
^KY - delete block
^KH - hide block

With the exception of lines versus characters, these features work pretty much
as you are used to in the Turbo Integrated Development Environment's editor.

Mark Block End and Mark Block Begin always include the entire current line.
Copy Block and Move Block always copy/move in front of the current line no
matter where the cursor is on the current line.

Using TpBkMemo
This is a brief description of how TpBkMemo works; you'll probably want to
review a listing of BMemo for an example of how to use TpBkMemo.

This is a complete replacement for TpMemo. Compile TpBkMemo to a TPU file and
include it in the USES clause of your program (instead of TpMemo). In addition
to the normal things you do to activate TpMemo in your program, you'll need to
do the following:

1. Call InitBlockCommands before invoking the editor. This will activate
the ^Kx commands and cause EditMemo to end whenever such a command is

2. Place your call to EditMemo in a repeat..until loop, with a case
statement to check the Exit Command. If it was a block command, call the
appropriate block procedure.

3. For ReadMarkedBlock and WriteMarkedBlock, your program should prompt
for a file name, and perhaps take some specific action for file not found
or file already exists conditions. (the demonstration program always uses
a file named 'block.tmp', not very useful but suitable for the demo)

4. Highlight Attribute. There are several new fields in the EMCB control
block. The only one you should access is KAttr. This is the display
attribute of the highlighted text. Note that if you do not explicitly
set this, it defaults to the normal text attribute with the intensity bit

TpBkMemo will return an 'out of buffer' space error if there is not enough
heap space to hold the marked block (when you try to move/copy).

TpBkMemo does not include prompts for reading and writing block files. You
are responsible for providing a file name for read/writing block files (the
demo uses 'block.tmp').

After a brief look at the ^B reformat code, it would appear to be too
time-consuming to keep blocking intact during this operation. Therefor,
blocking is turned off whenever reformatting is requested. (However, simple
WordWrap will work with blocking).

The include file ( contains the majority of the new procedures.
It is a bit under 500 source lines and adds about 5K to the TPU file (about
3.5K more code).

TpBkMemo is slower than TpMemo. This could prove to be a problem on XT class
machines in a certain situation. That situation is defining a large block
(several hundred lines) and leaving it highlighted as you perform text
editing in front of the block. As long as you are typing/editing on a
single line response is acceptable. However, as soon as you leave a line,
TpBkMemo must check to see if you've pushed the block out (or pulled it in).
It also calls a general purpose routine to update the block line coordinates
(this is what takes so much time). What the operator of TpBkMemo sees is a
slight pause whenever a line is inserted or deleted.

In all other situations, on any class machine, response time is reasonable.


All new procedures/functions are in the file. Many modifications
were also made to TpMemo (now TpBkMemo). All of these changes are preceded by
a comment line of the form:

{blocking - }

Typically these changes simply reference one of the new procedures. On a few
occasions however, one or two statements were added, modified or moved around
right in TpBkMemo.

As mentioned before, the EMCB control block contains a few new elements for
keeping track of pointers. Keeping these elements in the control block
maintains the reentrant property of TpMemo.

 December 23, 2017  Add comments

Leave a Reply