For Programmers: Free Programming Magazines  


Home > Archive > Clipper > September 2006 > Memoedit-Format w/o display









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Memoedit-Format w/o display
PeterH

2006-09-14, 6:55 pm

I have a little letter writing routine where a letter is stored in a
memofield with fieldnames which will be substituted with actual data at
print time. The data is different lengths than the length fieldname causing
improper "wrap". In a batch print mode where I print the same letter to
multiple recipients, I do not invoke memoedit (which would reformat the
memo). Any ideas no how to get the memo reformatted w/o memoedit after the
substitution?

Thanks,
PeterH


Stephen Quinn

2006-09-14, 6:55 pm

Peter

cMemo := _X->MEMO_FLD
// Do your data substitution
nLines := MLCount( cMemo, nLineLength, nTabSize, lWrap )
FOR i := 1 To nLines
? MemoLine( cMemo, nLineLength, i, nTabSize, lWrap )
NEXT

HTH
Steve


Robert Haley

2006-09-14, 9:55 pm


PeterH wrote:

> I have a little letter writing routine where a letter is stored in a
> memofield with fieldnames which will be substituted with actual data at
> print time. The data is different lengths than the length fieldname causing
> improper "wrap".


Greetings,

One method I've used is to "bracket" the fieldnames within the memo to
the actual field length, e.g.: Field: CUSTNAME Char Length (30)
-----
Memo (old): Dear CUSTNAME,
Memo (new): Dear <CUSTNAME.....................>,
-----
You would need to modify your code to generate
"<CUSTNAME.....................>" as the search string used when you
STRTRAN() the memofield.

> In a batch print mode where I print the same letter to
> multiple recipients, I do not invoke memoedit (which would reformat the
> memo). Any ideas no how to get the memo reformatted w/o memoedit after the
> substitution?


Not easily, while preserving formatting: typically you try to account
for the max. field length (see above) or else run into the situation of
having to process the memo yourself.

Following is a code fragment that should allow you to parse the Memo
line by line: you can then test and adjust line length as needed:

// -snip-

#define CRLF CHR(13)+CHR(10)

// IMPORTANT: convert all Soft Returns to Hard returns
// as input for the memoline process..

STRTRAN( cMemo, CHR(141)+CHR(10), CRLF )

IF RIGHT( cMemo, 2 ) <> CRLF
cMemo += CRLF
ENDIF // make sure we process that last memo line !

nStartPos := 1
nEndPos := 1
nLineNo := 1
cMemoLine := ""

DO WHILE ( nEndPos > 0 )

// following allows for max. (255) character line, adjust as
needed..

nEndPos = AT( CRLF, SUBSTR( cMemo, nStartPos, 255 ) )

cMemoLine = SUBSTR( cMemo, nStartPos, nEndPos-1 )

// ...
// variable cMemoLine is the current memo line
// test the length of the memo line,
// add to an array for later processing, etc.
// ...

nLineNo ++ // Increment line counter
nStartPos += nEndPos + 1 // Position on next line

ENDDO

// -snip-


If preserving text formatting is not a major concern then processing
the memo using MEMOLINE() will probably do what you need - see the
MEMOLINE() example code in the Clipper Norton Guide.


Regards,
Bob

PeterH

2006-09-15, 6:55 pm

Thanks Stephen and Robert.
I do NOT have printer codes embedded at the point I added the following:
nLines := MLCount( cBatchStr, pLETTERWIDTH, 3, TRUE )
FOR i := 1 To nLines
cReFormat += MemoLine( cBatchStr, pLETTERWIDTH, i, 3, TRUE ) +pCRLF
NEXT

This provided the results I was looking for. (I should have know this.)
Thanks again,
PeterH

"PeterH" <petermhill@verizon.net> wrote in message
news:gsiOg.4273$xr.2403@trnddc03...
> I have a little letter writing routine where a letter is stored in a
> memofield with fieldnames which will be substituted with actual data at
> print time. The data is different lengths than the length fieldname

causing
> improper "wrap". In a batch print mode where I print the same letter to
> multiple recipients, I do not invoke memoedit (which would reformat the
> memo). Any ideas no how to get the memo reformatted w/o memoedit after the
> substitution?
>
> Thanks,
> PeterH
>
>



Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com