Hi Frank,
>> Here is a preliminary stab I had at the soft CR problem along the lines
>> I suggested - except that I did not ltrim() the remaining string that
>> I mentioned in my step #4 since doing that would be against the Clipper
>> docs.
>
> Thank you for this. I've worked -- a little -- in other object-oriented
> environments, but this was my first encounter with Clipper's.
Well, I didn't even get into that department yet. All I did was borrow
the existing MemoEdit() function, rename it MyMemoEdit() and add the two
functions to remove and add back the soft CRs. I did that from inside
MyMemoEdit() because then I already knew what the line length in the
output was supposed to be, so I could make the result Clipper compatible
again.
The object oriented stuff you saw was from the original MemoEdit. And
MyMemoEdit() instantiates the same HBMemoEditor class as the original
function does.
> I know
> that late-edition Clipper had /some/ object-like features, since I
> encountered a few in this code I'm working on, but I had o idea it was
> quite so extensive. Or is some of it extensions added by the Harbour
> Project?
Clipper, before 5.3, had the tBrowse class, the Get class and the Error
class. 5.3 added radiobuttons, scrollbars and a few other things as
classes. The application programmer could only use the classes that were
provided, period. In Harbour there are many other classes, mostly
outside the strictly Clipper compatible area. But what is more important
is that in Harbour you can subclass any existing class and add whatever
you want in the subclass ... and of course write your own classes from
scratch.
If you want to add the missing functionality in MemoEdit() (besides
removing and adding back soft CRs on your way into and out of MemoEdit()
), then what you should do is to subclass HBMemoEditor (which is itself
a subclass of HBEditor) or maybe skip HBMemoEditor and write a subclass
of HBEditor based on code borrowed from HBMemoEditor. To use the new
subclass you would have to change the line in MyMemoEdit() that says
oEd := HBMemoEditor():New( [etc]
into a call to your new subclass. That was the second reason that I
borrowed from MemoEdit() into a new function.
There are also ways to add new methods and data to existing classes, but
I am not sure this is a good idea with a parent class that someone might
modify in the Harbour source tree one day out of your control.
>> All other issues in the editor class remain, and, as I said, I am not
>> even sure that this attempt is Clipper compatible. But maybe it is a
>> start, and maybe you could test it against some real memos ...
>
> I did, and it seemed to do the job.
OK, but it seemed a little to easily fixed :-). As I said, my MemoEdit()
experience is very limited, so I don't know how those soft CRs are used
in Clipper, whether they are kept while editing or stripped and put back
like I did. The stripped memo certainly seemed to behave properly while
being edited. If it was this simple, why did the xHarbour folks make a
comment about stripping instead of actually doing it? Oh, well ...
> However -- and thanks in no small
> part to what I learned working my way through your code -- I finally
> realized that I was overlooking something: for /this/ application, at
> least, nobody /needs/ those soft CRs. I do have to deal with those which
> already exist in the legacy-but-still-in-use MEMO fields, but MEMOEDIT
> seems to re-wrap the MEMO field text each time it is invoked, and all
> the customer needs is the ability to insert and delete "real" EOLs, ones
> which will someday reach a printer or the screen in a report. My current
> solution involves:
Precisely what I was thinking.
> * Stripping (old) soft CRs from a MEMO field before MEMOEDIT sees them,
> * Letting MEMOEDIT (re-)wrap the MEMO field text within its window, and
> * Stripping out any new soft CRs added by MEMOEDIT when it exits.
>
> This line of code (fortunately, the only call to MEMOEDIT):
>
> crv:= memoedit(fld, wm[2], wm[3], wm[4], wm[5], lwrite, "mefn")
>
> is now three:
>
> crvi = MemoFixSoftCRs(fld)
> crv:= memoedit(crvi, wm[2], wm[3], wm[4], wm[5], lwrite, "mefn")
> crv := MemoFixSoftCRs(crv)
Or wrap your fixing function inside a modified copy of MemoEdit() like
in my example.
>> Have fun :-)
>
> Aha! Thanks! I knew there was something I forgot to put on my ToDo List!
:-)
> And thank you again for all your help.
You're welcome
> P.S. Has anyone else noticed that it's almost half-past 2014 already?
Yes, we are not getting any younger :-)
Regards,
Klas