Julian,
Thanks for taking the time to look at my stuff and post a memo. The demo demonstrates the subtle difference really well. I still have a lot to learn with the components.
I am now using the replace tokens and mailmerge code. So far so good and it satisfies on of my main design goals, i.e. not to put proprietary stuff in the RTF's so they can edit them in whatever they want.
So to see if you can see an elegant solution to the following. If I want a 1-> n relationship to be displayed in a document (e.g. one client with a list of their investments), I insert a table into the document and then have something like the following.
<repeatrow><inv> <inv><inv>
My code used to be:
if StrStartsWithLeftNoCase(cRepeatRowPrefix,theToken) then begin delete(theToken,1,length(cRepeatRowPrefix)); WPRichMain.seltext:=''; RepeatRow(theToken); end
Which basically deletes the token, works out which table is to be used and repeat the row for each record, then you have n rows.
vNoRows:=FCallBackTableRows(vTableName);
WPRichMain.SelectThisRow;
vrowData:=WPRichMain.SelText;
WPRichMain.CopyToClipboard;
dec(vNoRows);
while vNoRows >= 1 do
begin
WPRichMain.InsertRow;
WPRichMain.SelLength:=0;
WPRichMain.TableRowNumber:=WPRichMain.TableRowNumber+1;
WPRichMain.TableColNumber:=0;
WPRichMain.ShowCursor;
WPRichMain.PasteFromClipboard;
WPRichMain.ShowCursor;
WPRichMain.CPPosition:=WPRichMain.CPPosition-1;
dec(vNoRows);
end;
WPRichMain.SelLength:=0;
end;
Alles anzeigen
I haven't looked at this code for ages, but if it gets called in MergeGetText() it doesn't work, you only get the one row. Looking at the code, it would be nice if it didn't use the clipboard either. I guess I could use the AsString of the selection for this.
So is it a no-no to mess with cursors and content in the MergeGetText() and if so, do you propose I pre-parse the text before replaceTokens it, or replaceTokens it and then search for fields starting with <repeatrow*?
Thanks again, you have really speeded up the trouble shooting on this.
[/quote]