Hi,
I have tried a few experiments with this.
Here is some simplified code for what I am trying.
I have a template RTF file which has placeholder text like [[mrgAddress]].
I have code which reads something like this.
Code: Select all
on mouseUp
local theTemplateFile, theMergedFile, theRTFtext
-- set up the files for template and merged file
answer file "Where is 'EpOfCare.rtf' template file?"
if it is empty then exit mouseUp
put it into theTemplateFile
ask file "Save your message as:"
if it is empty then exit mouseUp
put it into theMergedFile
-- put the card fields into the variables for merging
local mrgAddress
put field "fldAddress" into mrgAddress
-- merge and save the new file
put URL("binfile:" & theTemplateFile) into theRTFtext
set the fileType to "MSWDRTF"
put merge(theRTFtext) into URL("binfile:" & theMergedFile)
end mouseup
What this code does is to identify the template file and a name for the output file. It then takes the text from a multi-line address field and puts it into a variable (mrgAddress) which has the same name as the placeholder in the template file. The merge function then replaces the placeholder text with the text in the variable of the same name.
The problem is that there are no carriage returns in the text that is merged. So the text is merged as one line not multiple lines.
I have tried putting text with carriage returns into the mrgAddress variable like this;
Code: Select all
put "test" & numToChar(13) & "test" into mrgAddress
and the merged text is "testtest"- so no carriage return. I am wondering if the merge function strips out or ignores the carriage return function so it has no effect. I tried this with space;
Code: Select all
put "test" & numToChar(32) & "test" into mrgAddress
and got a space. But when I tried line feed/new line
Code: Select all
put "test" & numToChar(10) & "test" into mrgAddress
I got "testtest".
Any ideas?
thanks