Dec 202017
Turbo Pascal 5.5 unit that provides a simple screen editor that can be used in your program. Will not do word-wrap.
File CWDKIT55.ZIP from The Programmer’s Corner in
Category Pascal Source Code
Turbo Pascal 5.5 unit that provides a simple screen editor that can be used in your program. Will not do word-wrap.
File Name File Size Zip Size Zip Type
CENTWR55.TPU 16112 5805 deflated
CWDKIT55.DOC 32365 11120 deflated
DCHANGES.DOC 2328 1056 deflated
DLICENSE.DOC 8852 3387 deflated
ORDER.FRM 1976 618 deflated
VENDOR.DOC 232 160 deflated

Download File CWDKIT55.ZIP Here

Contents of the CWDKIT55.DOC file

Centiwrite 1.10 Developer's Kit and User's Manual
Both Items Copyright 1988 Andrew M. Saucci, Jr.

Note that you may also inspect the copyright notice of the file CENTWR55.TPU
by entering "copy centwr55.tpu /b con" at the DOS prompt. Ignore all the
beeping and stumbling and wait for this command to finish executing.
Also, if your copy of the compressed version of the Kit is named "CWDKIT.ARC"
you should rename it "CWDKIT55.ARC".


Centiwrite 1.10 Developer's Kit User's Manual
========== ==== =========== === ====== ======

Copyright 1988 Andrew M. Saucci, Jr.

What's to Follow

1. Introduction
2. About the Author
3. The Interface of the Unit
4. What You'll Need to Compile
5. The Basic Principles
6. A Sample Calling Program
7. Analysis of the Sample Program
8. The Initial Values
9. Initializing the Array
10. How to Overlay the Unit
11. Compatibility Consideration
12. For Extra Punch in Your Program
13. Down to Brass Tacks
14. Boilerplate
15. To All Those Who Helped
16. Coming Attractions
17. It's Alive!



Congratulations on having acquired this useful developer's tool. Now
you can have an "instant editor" in your own programs whenever you need to
include the capability to create short memos, notes, or letters. This file
will attempt to show you how to incorporate the Centiwrite 1.10 editor into
your Turbo Pascal programs. If you are unfamiliar with this editor, you should
definitely obtain a copy of the stand-alone version of Centiwrite and read its
User's Manual. This explains in detail the operation of the editor. Of course,
as a "developer" (one of the initiated), you'll gain access to some features
not used in the stand-alone version.


About the Author

Andrew M. Saucci, Jr. was graduated with distinction from the
New York Institute of Technology with a master's degree in computer science.
He received a bachelor's degree in computer science from Hofstra University.
A member of the Association of Shareware Professionals (ASP) and the
Association for Computing Machinery (ACM), Mr. Saucci has programmed in
Turbo Pascal for over one year. He is also the author of the program
The Holy Rosary.

Mr. Saucci can be reached at any of the following electronic mail

CompuServe 72117,241

Comments about any of his products are most welcome; however,
please allow one week for a response to your initial inquiry. After that,
an "active" mailbox is checked daily. Also, for guaranteed service, use
the regular mail facility of your service rather than a bulletin board area,
or send a regular mail note saying to check the bulletin board. One week is
a "worst case" situation. Often, mailboxes are checked more frequently.


The Interface of the Unit

unit centwr55;
uses dos, crt;
type scarray= array [1..62] of string[85];
commstruc= record
screline: scarray;
lastring, initWhereX, initWhereY: byte;
CurAttr, StdAttr, MessAttr, WarnAttr: byte;
passkey: integer;
TimeOutInterval, NextTimeOut, oldhours: word;
BlankChar: char;
insmode, RetCtrlKeys, ShowStatusLine, TimeOut: boolean;
function nextword (sentence: string): integer;
function lastword (sentence: string): integer;
function isletter (charcode: char): boolean;
function isdigit (charcode: char): boolean;
function datestring: string;
function timestring: string;
function CheckSumVidBuf (x1, y1, count: byte): word;
function BufChar (xlimit, ylimit: byte): byte;
procedure AnalyzeKey (var inkey: integer; var scancode: byte);
procedure DelWord (var sentence: string; position: integer);
procedure Centiwrite (var infoexch: commstruc);

{ Implementation would follow here. }

Each of the variables used in the "commstruc" (for "communications structure"
record is described below.

screline: The strings which represent each line of the text to a maximum of
62. This accomodates 25-, 43-, and 50-line screens.

lastring: The number of currently "valid" strings in screline. Because a line
consisting solely of a carriage return (ASCII 13-10) is represented
by a null string, "lastring" indicates how many lines of screline
are currently being used. Note that in an empty file, lastring is 1.

initWhereX: The initial x-coordinate of the cursor on entry to the editor.

initWhereY: The initial y-coordinate of the cursor on entry to the editor.

CurAttr: The color attribute of the cursor. You can use any valid attribute.
If the foreground and background are the same, the Centiwrite editor
assumes that the blinking hardware cursor is being used, and the
software cursor is disabled. The cursor will appear as a blinking
CHARACTER if a background color greater than 7 is used.

StdAttr: The normal color attribute of the editor.

MessAttr: The color attribute for messages which appear on the status line.

WarnAttr: The color attribute for the word "Overstrike" when visible.

TimeOutInterval: The number of minutes between timeouts. If this is set
to zero, timeouts are disabled.

NextTimeOut: Time in minutes of the next timeout. If the next timeout is
at 4:43, this variable could have the values 43, 103, 163, ...
through 65535 (the maximum for a word), or (43+ 60*n), where
n is the number of hours to the next timeout. On the hour,
NextTimeOut is decremented by 60 (if it exceeds 59).

oldhours: Hours at the last time check. This is passed as part of the
structure because the calling program must initialize it before
the first call to Centiwrite. You should re-initialize it if
you leave Centiwrite for more than an hour. Basically, this is
used as a "rollover" flag.

passkey: The character passed back to the main program when Centiwrite does
not define a function for it. (This is now an INTEGER.)

BlankChar: The character that is displayed at the cursor position when
the character at that position is either ASCII zero, ASCII 32
(blank), or ASCII 255. All of these normally appear as a blank,
and you may need to choose an alternate character, particularly
for those using monochrome monitors. You may select any character
except ASCII 7, 8, 10, or 13.

insmode: If true, then the editor is in Insert mode. Otherwise, Overstrike
mode is used.

RetCtrlKeys: Set this to true if you want control keys (ASCII 1 to 31,
except 8, 9, and 13) returned to the calling program.
Otherwise, set it to false so that Ctrl-L, for example,
will insert an ASCII 12 (form-feed). Even if control keys
are returned, using the Alt+ numeric keypad method of
entering characters will always insert the appropriate
character, except for ASCII 7, 8, 10, and 13, which are
ignored. Backspace, Tab, and Enter are never returned this way.

ShowStatusLine: Set this flag to true if you require the status line,
which shows the current state of Insert/Overstrike and
the current position on the screen. If this is set to
false, no status line is displayed and the top line
is available for editing. When ShowStatusLine is false,
the Insert key is returned to the calling procedure for
action, so that any display or indication of the Insert/
Overstrike mode that the caller maintains (in lieu of
the status line) may be updated by the caller. Also, the
F5, F8, and Ctrl-F8 keys are ignored (because they use
the status line for their display).

TimeOut: When set to true, TimeOut indicates that the calling procedure
has received control on account of a timeout, and that the
appropriate timeout procedures or functions should be
executed. Otherwise, the caller received control because of
an unrecognized or Ctrl-key.

The functions and procedures which are included are summarized next.

nextword: Returns the position of the next word in a string. In the string
"for he's a jolly good fellow", nextword returns 4. If no "next
word" is found, the return value is the length of the string plus 1.

lastword: Returns the position of the last word in a string. In the string
"which nobody can deny", lastword returns 18. If the string is a
single word, the return value is 1.

datestring: Returns the current system date in the form "Monday, May 26, 1988".

timestring: Returns the current system time in the form "10:45:44 PM".

CheckSumVidBuf: Returns a checksum of the characters in the video buffer
starting at a given location (in REAL coordinates-- not
those recognized by the CRT unit) and continuing for
count characters. This procedure is not used by the
editor, but is included because it is important to
all programmers who want to discourage tampering with
their programs. (Real coordinates start at 0,0 and are
not relative to the current window.)

BufChar: Returns the character at the cursor location and advances the
cursor one column to the right, or to the beginning of the
next line. "xlimit" is the x-coordinate (again, in real coordinates)
at which the cursor should wrap to the next line. "ylimit" is the
y-coordinate of the bottom of the screen. If the cursor is in the
lower right corner of the screen, the character is returned but
the cursor is not advanced. This function is also not used by
the editor, but it is the function that the stand-alone version
of Centiwrite uses to load a screen into the editor. Now you
can use it, too!

AnalyzeKey: Substitute keyboard reading procedure (for ReadKey). A single
call returns all pertinent keyboard information-- no need to
make multiple calls to check for extended key codes.
Extended key codes are returned in inkey as values in excess
of 255-- for example, F6 is returned as 322. Note that "inkey"
is an INTEGER variable. To get the value returned in "inkey",
add 256 to the extended key code (F6 is 322, or 64+ 256).
This procedure is now written in assembly language for
extra speed.

DelWord: Deletes the word starting at a given location in a string.

Centiwrite: The editor itself.


What You'll Need to Compile

In order to compile a program using Centiwrite, you need to copy
CENTWR55.TPU into the directory where Turbo Pascal normally looks for your
.TPU files. In version 5.5, this is one of the EXE & TPU directories specified
under the Options/Directories menu selection. You will also need to add the
line "uses centwr55;" to the the source file of the procedure that calls the
editor. Check your Turbo Pascal manual for additional information on including
units in your programs. Oh, yes, you'll also need Turbo Pascal version 5.5.
For those concerned about needing to recompile for future versions of the
compiler, the current plan is to update the unit whenever a new version of
Turbo Pascal is released. Upgrades will be available for a modest charge.

With the advent of Turbo Pascal 5.5, units may incorporate object-
oriented programming techniques. This means that a unit such as this one could
be distributed as a .TPU file, yet a user could make changes to it without
the need for the source code. If possible, the Developer's Kit will be
revised to take advantage of this opportunity.


The Basic Principles

The Centiwrite editor is based upon an "array of strings"
implementation. While not suitable for a large text editor or word processor,
this approach is quite adequate for a simple program such as this. It allows
a "quick and dirty" style, and is easily understandable. Each element in the
array of strings represents a line of text on the screen. An "implied"
carriage return ends each line. A count of the current number of lines is
maintained at all times. A duplicate array is maintained in memory in order
to facilitate the "Undo" feature (invoked by F3).

Some may wonder why the video memory is not used to store the
text, considering that the text is stored there anyway. Use of character
strings allows the use of Turbo Pascal's string-handling procedures. Using
video memory would mean writing substantially more code in order to duplicate
the functions already available in the runtime library. This code would not
only make the program larger, but would also need to be debugged. The Turbo
Pascal string-handling routines (while not perfect) are already thoroughly


A Sample Calling Procedure

The following program is an example of how to call the editor.

program CallEditor (input, output);
uses dos, crt, centwr55;
var reg: registers;
origcx: word;
cwinfo: commstruc;
i: byte;
hours, minutes, seconds, hundredths: word;

procedure SaveFile;
writeln ('Code for saving a file would be here.');
delay (2500);

procedure HelpProcedure;
writeln ('Help! Help!');
delay (2500);

reg.ah:= $03; $00;
intr ($10, reg); { Save old cursor }
reg.ah:= $01; $2000;
intr ($10, reg); { Disable hardware cursor }
with cwinfo do { Allows unqualified variable references. }
insmode:= true; { Initialize structure variables. }
initWhereX:= 1;
initWhereY:= 1;
CurAttr:= $70; { Black on LightGray }
StdAttr:= $17; { LightGray on Blue }
MessAttr:= $20; { Black on Green }
WarnAttr:= $4F; { White on Red }
for i:= 1 to 25 do
screline[i]:= ''; { empty file }
lastring:= 1;
passkey:= 0;
RetCtrlKeys:= false;
ShowStatusLine:= true;
BlankChar:= #32; { pick the blank character because of the CurAttr we used }
TimeOutInterval:= 5; { causes a timeout every five minutes }
GetTime (hours, minutes, seconds, hundredths);
NextTimeOut:= minutes+ TimeOutInterval; { set first timeout }
oldhours:= hours; { initialize rollover flag }
window (1, 1, 80, 25);
TextAttr:= $07;
writeln ('Joe''s Program: Centiwrite Editor-- Alt-X to Exit');
window (1, 2, 80, 25);
Centiwrite (cwinfo); { <------------- PLUG-IN EDITOR }
window (1, 1, 80, 25);
TextAttr:= $07;
if TimeOut { Short-circuit the other tests-- passkey contains }
then begin { values which have already been processed. }
passkey:= 0;
if ((passkey= 346) or (passkey= 316)) or (TimeOut)
{ If Alt-X, F2, or TimeOut, save the file. }
then SaveFile;
if passkey= 315 { F1 displays a list of keys and their functions. }
then HelpProcedure;
until ((passkey= 288) or (passkey= 346)); { Alt-D or Alt-X (exit condition) }
end; { with statement }
reg.ah:= $01; origcx;
intr ($10, reg); { restore cursor }
end. { program }


Analysis of the Sample Program

Take a close look at the sample program. Although it has been
simplified in order to highlight the main points, its basic structure is
the same as that of the stand-alone version of Centiwrite 1.10. You should
be able to compile and run it. It gives initial values to the members of the
structure, and then runs the editor in a repeat..until loop.

Why a loop? This is the means you can use to add your own "frills"
to the editor. Any time the Centiwrite editor sees a key that it does not
recognize, such as F9, Alt-Z, or PageDown, the editor terminates and control
returns to the calling procedure. Placing the editor in a loop gives you a
chance to execute whatever procedures or functions you like before RETURNING
control, or exiting if you like. For example, Alt-X is the "recommended" exit
key. The editor takes no special action on seeing Alt-X; it merely exits just
the same as it would for any other unrecognized key. The "until" condition
"passkey=288" is what causes the sample program to terminate. To use F10 as
an exit key, just change the condition to "passkey=324". Likewise, what
displays help is "passkey=315"; to use Shift-F1, change to "passkey=340".

Note that the editor recognizes all keys that return an ASCII value
plus the following extended keys:

arrow keys Shift-Tab Ctrl-Left arrow Alt- B E H T V Y
Insert Home/End Ctrl-Right arrow F3 F5 F7 F8
Delete Ctrl-Home/End Ctrl-F8

The calling procedure is passed any other keys and may deal with them
however it sees fit. The variable "passkey" will hold the value of the last
key pressed. By using the flag RetCtrlKeys, you can specify additional keys
to be returned.

Notice the "window" statement just before the call to Centiwrite.
This is absolutely necessary in order for the editor to establish its window
boundaries and insure the integrity of its screen. The editor can operate
in a window no narrower than 40 columns. It has not been tested in windows
of fewer than 24 rows; however, it should work for any number of rows.
(For a single row "window" you should use "liminput", the complete source
code to which is found in the Deciwrite Developer's Kit.) If you specify a
window size of fewer than 40 columns, greater than the screen width, or
greater than the screen height, the result is unknown.

The Centiwrite editor redraws its window each time it is called, and
it leaves the screen in place when it exits. Therefore, you can put a window
over it without any trouble.


The Initial Values

The most important value in "commstruc" is "lastring". If you use
an invalid value for lastring, the editor will become confused and behave
erratically. Lastring should be 1 for an empty file. Otherwise, it reflects
the number of currently valid strings in the array "screline".


If screline is this (line numbers added):

[1] Now is the time for all good people.
[2] We must mobilize now.
[4] May we have your support?

then lastring is 4. If two carriage returns are added after line 4, as in

[4] May we have your support?

then lastring is 6. Lastring should only be changed when the number of lines
in the text is changed.

Here's an important note about carriage returns. The Centiwrite
editor does NOT add the ASCII 13-10 combination explicitly to the text. Every
string ends in an IMPLIED 13-10. If you write a file to disk, you must add the
13-10 yourself. This is easily done using a "writeln(screline[i])"-type
statement. You need not delete a 13-10 on input, however, as the editor
automatically removes these (as well as ASCII 7 and 8) from the text. You
should, however, take care to format the input strings so that they do not
contain embedded carriage returns that really belong at the end of a line.

InitWhereX and initWhereY are used to position the cursor when
the editor is called. For the first invocation, each of these should usually be
set to 1, although any valid values are acceptable. Never position the cursor
below the row "lastring", or erratic operation will result. When the editor
passes control back to the calling procedure, the current cursor position is
saved in initWhereX and initWhereY. It can then be reused if necessary when
the editor is called again. Pressing F9 demonstrates this simply. The cursor
position is saved; the editor returns control to the main program; the main
program ignores the key (because no function has been defined for it there,
either); and the editor regains control, positioning the cursor at the saved

Insmode, as explained earlier, is simply a flag. It's your choice--
set it however you like depending upon whether you want to start the editor in
Insert mode or Overstrike mode.

Passkey must be initialized. If a timeout occurs before the first
key is pressed, the internal check of passkey will fail if passkey
contains garbage.

You must also initialize BlankChar, RetCtrlKeys, and ShowStatusLine.
They are explained previously.

You do not have to initialize TimeOut, because it is set to
false each time the editor is called.


Initializing the Array

You must initialize "screline" before using it. This can be done
any way you like-- with assignment statements, reads, Move, etc. You should
assign an initial value to "maxline" elements in screline, where "maxline" is
equal to the maximum number of lines on the screen plus 1. Be sure to keep
"lastring" synchronized with the actual number of elements of screline in use.


How to Overlay the Unit

This unit is compiled using {$O+}. This means that you may
overlay it using the methods outlined in Chapter 13 of the Turbo Pascal
Reference Guide, just as you would do for any other unit compiled with {$O+}.
If you do not want to overlay the unit, simply ignore this feature. While it
has not been tested as an overlay, it should work just as well either way.


Compatibility Consideration

The Centiwrite editor uses direct screen writes (through Turbo
Pascal's CRT unit). This may cause problems, particularly with windowing
environments such as Desqview or Concurrent DOS. If you need to write to
the screen using the video BIOS functions, place the line "uses crt" in
your main program and set the built-in CRT variable DirectVideo to "false".
Otherwise, DirectVideo will be assumed to be "true".


For Extra Punch in Your Program

If you want to use a "plug-in editor" in your program, but feel
Centiwrite just isn't powerful enough, don't walk away feeling dejected.
Here's good news! Also available is an editor similar to Centiwrite but ten
times as powerful. It's Deciwrite! The Deciwrite Developer's Kit includes all
the features of Centiwrite PLUS:

1. Automatic word wrap and paragraph reformatting.
2. Full support for binary files.
3. Time and date can be inserted into the text with one keystroke.
4. Full source code-- including liminput, a replacement for readln; dectohex
and hextodec, hexadecimal conversion routines; and FileCheck, which checks
for the existence of a file and determines if it is read-only; and more!

What's more, if you're not sure, you can "lock in" the price of
the Deciwrite Developer's Kit by buying the Centiwrite Developer's Kit NOW.
You'll have one year to upgrade at the current price (plus $1 for shipping),
PLUS you get a credit for what you paid for the Centiwrite Developer's Kit.
What's to lose? Send electronic mail to the addresses listed earlier to learn
how to take advantage of this great offer. Don't forget, too, that the
Deciwrite Developer's Kit comes with a 30-day money-back guarantee no matter
when you buy it.


Down to Brass Tacks

As of July 1, 1989, this is the Centiwrite/Deciwrite price list.

Individual License Site License
*# Centiwrite 1.10 $20.00 $250.00
# Deciwrite 1.10 $30.00 $500.00
Deciwrite 1.10 Demo Disk $ 4.00 *******
*# Centiwrite 1.10 Developer's Kit $32.50 $550.00
Upgrade to later TP version $ 5.00 $ 60.00
# Deciwrite 1.10 Developer's Kit $75.00 $950.00
Disk replacement fee $ 3.00 none

* These items may be ordered through the Public (Software) Library;
others must be ordered directly from the author.

# Please add $4.00 shipping & handling to these items.

New York State residents and businesses MUST add their local sales tax
or provide proof of exemption. Send electronic mail if you are uncertain
of your local tax rate. Specify your address and county. The shipping
and handling charge is NOT included in the calculation of sales tax.

Residents of other states will in most cases be required to remit the
appropriate tax directly to their state tax department.

The Deciwrite Demo Disk includes one $3.00 discount off the purchase
of Deciwrite 1.10.

An individual license permits the user to operate the program on
a single computer at a time, while a site license permits unlimited use
within the confines of a contiguous area of the owner's property.

These prices are guaranteed not to increase through October 1, 1989.

Custom implementations of these programs are also available on
request for modest additional fees. Send electronic mail to one
of the addresses listed earlier.

If you would like to use your Visa or MasterCard to register this
program, you may order through the Public (Software) Library.
The number to call for orders is 1-800-2424-PSL (1-800-242-4775).
Information and questions about orders is available from the PSL
at 713-665-7017. You may also write to the PSL at P.O. Box 35707,
Houston, TX 77235-5705, or send electronic mail via CompuServe to
71355,470. When writing, you should sign your letter, include your
card number and its expiration date, and specify that you want to
register Centiwrite, (CWDKIT55.ARC), by Andrew M. Saucci, Jr. Please
note that the PSL is not equipped to answer questions about Centiwrite
itself. Such questions are best directed to one of the electronic
mail addresses listed earlier. Also note that no surcharge
is imposed on credit card orders.

Make checks payable to

Andrew M. Saucci, Jr.
641 Koelbel Ct
Baldwin, NY 11510-3915.

Please specify the disk size you require.

You may wish to check one of the electronic mail addresses to verify
that the above address is current. Please use this "physical" address
ONLY for orders, unless you lack a modem. All other correspondence,
including technical support questions, should be directed to one of
the electronic mail addresses whenever possible.


Before Going to the Highest Court in the Land

This program is produced by a member of the Association of Shareware
Professionals (ASP). ASP wants to make sure that the shareware principle
works for you. If you are unable to resolve a shareware-related problem with
an ASP member by contacting the member directly, ASP may be able to help. The
ASP Ombudsman can help you resolve a dispute or problem with an ASP member,
but does not provide technical support for members' products. Please write to
the ASP Ombudsman at P.O. Box 5786, Bellevue, WA 98006 or send a CompuServe
message via EasyPlex to ASP Ombudsman 70007,3536.


Special Bonus

All registered users of the Centiwrite Developer's Kit are also
licensed to use the stand-alone version of Centiwrite (CWRITE.EXE) at no
additional charge. CWRITE.EXE is included on the distribution disk that will
be sent to you when your order is received. Also, registered users receive
the source code for DIRALL.EXE, one of the programs provided to registered
users of the stand-alone version of Centiwrite. DIRALL.EXE provides a
regular directory listing, but highlights hidden files in boldface.

A registered user is also entitled to unlimited telephone, U. S.
mail, or electronic mail support. If such a user finds a bug within three
months of purchase, it will either be fixed or the purchase price will be



Liability in the event of defects in Centiwrite 1.10 and/or the
Centiwrite 1.10 Developer's Kit is expressly limited to replacement of the disk
on which Centiwrite and/or the Developer's Kit was originally provided. No
other liability of any sort is either implied or assumed. In particular, the
user is responsible for all consequential damages, such as loss of income,
loss of data, pain and suffering, etc.


To All Those Who Helped

Thanks to all those who gave their assistance toward the completion
of this program, especially Michael Day, Neil Rubenking, Scott Bussinger, and
all the other helpful people who frequent Borland's Programming Forum A
(BPROGA) on CompuServe. It's truly amazing!


Coming Attractions

A plan to produce a full-size text editor based on Centiwrite and
Deciwrite is in the works. Please use Centiwrite to write a short note
describing a few of the features you would like to see in a text editor,
particularly anything that is not found in other programs, and send it to one
of the electronic mail addresses. The result could be a really good program.
You might also indicate what incentives are most likely to cause you to
purchase registered copies of programs distributed on a "try-before-you-buy"
basis. Your suggestions will be most appreciated.


It's Alive!

This program is not carved in stone. Many of you no doubt have
extensive experience in this field, and your comments and suggestions are
valuable and welcome. Send them to the electronic mail addresses listed.

============================= END OF FILE ===================================

 December 20, 2017  Add comments

 Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>