[comp.lang.pascal] How to get information out of Editor Toolbox buffer

ir332@sdcc6.ucsd.EDU (Jeff Miller) (02/28/88)

Here is an interesting and difficult problem involving the Turbo Pascal Editor
toolbox.  Fortunately, it does not depend on any details
of the code involved, and one of you experienced DOS programmers may be able
to put me on the track of a good solution even if you have
to point me in the direction of a good solution even if you have
never used Turbo Pascal or the Editor Toolbox.

For several years, I have been wanting to develop a set of user interfaces
(for several different programs) in which:
  a) The user is in an Editor-like environment.
  b) From this environment, the user escapes to the actual program,
  which reads information from the editor's buffer to find out what
  the user wants done.
  c) The actual program writes its results into the editor buffer
  (usually at the end), and then puts the user back into the editor
  buffer to modify his instructions to the program, issue new
  instructions, or just be able to inspect and edit the results.

(Whether or not this type of interface seems sensible is irrelevant
to the discussion.)

It seemed that having Borland's Editor Toolbox would be the ideal
solution to my problem, since I wouldn't have to actually write an
Editor for the user to interact with.  However, I find that Borland
has left out a piece that is essential for me: they include no
provision for a program to read what is in the buffer.  My question,
then, is what is a good way to do this.  Perhaps someone has already
dealt with this problem, or can give good advice.

The buffer maintained by the editor toolbox is essentially a linked
list of strings, and I can get at  this linked list.  I have thought
of three ways to get at the buffer, in increasing order of
sophistication:

1.  Write the buffer out to disk and then use standard pascal file IO
routines (i.e., reading typed variables) to read it back in.  (The
editor toolbox provides code to write out the file).
Material could be added onto the end of the file by appending.

Obviously, this is a horribly UGLY solution, and I would expect my
computer to instantly vaporize if I actually implemented it.  But it
would be very easy to implement, and it would allow the full power
of Pascal's Read(ln) and Write(ln) routines to be available automatically.

2.  Write a million routines, one to read each conceivable type (i.e.,
integer, long integer, character, string, 5 kinds of reals, ...) from
the buffer (starting at the current position).  Write another
million routines to write each conceivable type onto the end of the
buffer.  This is what I will probably do if I can't come up with anything
better, but I'll always wish that I'd had the guts to do #1 or the
brains to do #3 instead).

3.  Write a "device driver" that treats the editor buffer as a
character stream.  This sounds good to me, but I have no idea what
is involved, or even if it is possible.  Basically, my notion is
that I should be able to just write a few routines to be invoked by
the operating system when they are needed to do the
equivalents of Reset, Rewrite, Append, Get_Character,
and Put_Character for this "device".  Then, I should be able to
say things like Assign(UserFile,'MYDRIVER:') and 
Readln(UserFile,Int,DumChar,RealVal,EndString), thereby letting the
Pascal system handle all the character to type conversions (same for
output).

Does anyone have a better idea than any of these?

Does anyone have any information about whether it is possible to
write a device driver of the type needed for #3, and if so where one
gets the requisite
descriptions of how to write device drivers (if this has to be done
in assembler, I'll throw in the towel right now)?

Is anyone interested in helping with this problem or seeing the
solution that is developed?

Is anyone at Borland listening?

        Jeff Miller               BITNET: jomiller@ucsd
	U. C. San Diego           Internet: jomiller@ucsd.edu
	Dept Psychology, C-009    ARPA: ir332@sdcc6.ucsd.edu
        La Jolla, CA  92093       Ma Bell or clone: 619-534-2996