Very Hot Topic (More than 25 Replies) MergeFilePrint() Questions (Read 10107 times)
BOBSCOTT
Senior Member
Members
*****
Offline


That Darn Computer #$X#
{curse words}

Posts: 1195
Joined: Nov 22nd, 2002
MergeFilePrint() Questions
Jul 19th, 2007 at 9:13pm
Print Post Print Post  
I am confused (Yes once again)

Does an element name (amount of letters contained) affect how it merges with MergeFilePrint() ?

I have numerous name.Rtf files created and working well for my merge needs. My problem is when I am creating the original master RTF merge document it is often hit and miss if the data will display. Often it seems to occur when an element name is larger.

I can copy a perfectly working RTF file, rename it a new RTF file name and run it, it merges fine. I then open the RTF file change an element name. In my example I change PropertyFirst (the name of the property owner) to PropertyPODContactFirst (the name of the Pay off Demand company contact) and it will not work.

Often if I change my element name to something short it works.

I have messed with the folding digit and opening in notepad and manually editing the line but that creates all sorts of other issues for me.

Has anyone else seen this behavior using MergeFilePrint() ?

Has anyone had problems getting certain elements to merge when they try to create a MergeFilePrint() document ?

Thanks
« Last Edit: Mar 19th, 2008 at 9:04pm by Hammer »  

Team – Together Everyone Achieves More
Back to top
 
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: MergeFilePrint() frustration.
Reply #1 - Jul 19th, 2007 at 9:33pm
Print Post Print Post  
I know this is probably a silly question, but I have to get it out of the way.
Are you certain you are spelling the element name correctly?
  

- Hammer
The plural of anecdote is not data.
Back to top
IP Logged
 
BOBSCOTT
Senior Member
Members
*****
Offline


That Darn Computer #$X#
{curse words}

Posts: 1195
Joined: Nov 22nd, 2002
Re: MergeFilePrint() frustration.
Reply #2 - Jul 19th, 2007 at 9:53pm
Print Post Print Post  
Hammer wrote on Jul 19th, 2007 at 9:33pm:
I know this is probably a silly question, but I have to get it out of the way.
Are you certain you are spelling the element name correctly?


Silly questions fit me well.  Smiley Unfortunately that is not the problem in this case.

I often times f5 in the name box of the property editor and copy this data and paste into my [[  ]]  (on a side note right clicking in the property editor field offers a choice of Grab Current Value- once grabbed how do I paste this? Ctrl V does not work)

Thanks

  

Team – Together Everyone Achieves More
Back to top
 
IP Logged
 
Carl Underwood
Senior Member
Members
*****
Offline



Posts: 1350
Location: New Hampshire
Joined: Mar 11th, 2003
Re: MergeFilePrint() frustration.
Reply #3 - Jul 20th, 2007 at 1:54am
Print Post Print Post  
BOBSCOTT wrote on Jul 19th, 2007 at 9:53pm:
(on a side note right clicking in the property editor field offers a choice of Grab Current Value- once grabbed how do I paste this? Ctrl V does not work)

That is simply doing the exact same thing as pressing the F5 key. It's doesn't place the value in the Windows clipboard. Try it while the Name field in Property Editor is empty (and an LE is selected), and you will see that it fills in with the name of the LE.

To copy the value, you need to use Ctrl-C, or select Edit Long Value, then use the right-click Copy selection from that editor window.

It would be nice, though, if that little popup menu had the normal Cut, Copy, Paste... type choices available at the Property Editor level, rather than only in the popup editor window.
  


Carl Underwood
CDU Computer Consulting LLC
Epsom, New Hampshire
Back to top
IP Logged
 
BOBSCOTT
Senior Member
Members
*****
Offline


That Darn Computer #$X#
{curse words}

Posts: 1195
Joined: Nov 22nd, 2002
Re: MergeFilePrint() frustration.
Reply #4 - Jul 20th, 2007 at 2:36pm
Print Post Print Post  
Quote:
That is simply doing the exact same thing as pressing the F5 key


Thanks Carl,

I use the f5 feature all the time. I find it to be one of the handiest little features. My interpretation of grab current value was different then its actual intention. I was thinking once I f5 to retrieve the value write clicking on grab current value meant it wood cut it to a clipboard saving me my ctl c ctrl v steps.  No biggie!

Now does no other responses mean I am the only one who is having a problem with some elements and MergeFilePrint ?

Everyone else just sticks the [[ brackets around the element name and all is well?

Thanks
  

Team – Together Everyone Achieves More
Back to top
 
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: MergeFilePrint() frustration.
Reply #5 - Jul 20th, 2007 at 2:56pm
Print Post Print Post  
BOBSCOTT wrote on Jul 20th, 2007 at 2:36pm:
Now does no other responses mean I am the only one who is having a problem with some elements and MergeFilePrint ?

Everyone else just sticks the [[ brackets around the element name and all is well?


Is there one that always fails that we can try/look at?
  

- Hammer
The plural of anecdote is not data.
Back to top
IP Logged
 
BOBSCOTT
Senior Member
Members
*****
Offline


That Darn Computer #$X#
{curse words}

Posts: 1195
Joined: Nov 22nd, 2002
Re: MergeFilePrint() frustration.
Reply #6 - Jul 20th, 2007 at 3:07pm
Print Post Print Post  
Hammer wrote on Jul 20th, 2007 at 2:56pm:
Is there one that always fails that we can try/look at?


Sure. I will send tech support my app, 2 rtf files 1 that works everytime and 1 with only 1  element that does not. I will attach directions on the steps I use.

Thanks
  

Team – Together Everyone Achieves More
Back to top
 
IP Logged
 
Ray the Reaper
Global Moderator
Members
Lantica Support
*****
Offline


The One & The Only

Posts: 2480
Joined: Aug 20th, 2003
Re: MergeFilePrint() frustration.
Reply #7 - Jul 20th, 2007 at 3:48pm
Print Post Print Post  
Thanks Robert, I'll have a look at it as soon as possible.

-Ray
  

Raymond Yoxall Consulting
ray.yoxall@gmail.com
ryoxall@lantica.com
Sesame Applications, Design and Support
Back to top
IP Logged
 
Ray the Reaper
Global Moderator
Members
Lantica Support
*****
Offline


The One & The Only

Posts: 2480
Joined: Aug 20th, 2003
Re: MergeFilePrint() frustration.
Reply #8 - Jul 24th, 2007 at 2:02pm
Print Post Print Post  
Just a Followup:

Roberts problem turned out to be that the ['s and ]'s were set as one font Face and size and the name of the element was set as another font face and size. When viewed as plain text it looked something like this /fontstatement[[/fontstatementPropertyPODContactFirst/fontstatement]]

It was fixed by selecting the entire Merge Field and setting the font size and face on it.

-Ray
  

Raymond Yoxall Consulting
ray.yoxall@gmail.com
ryoxall@lantica.com
Sesame Applications, Design and Support
Back to top
IP Logged
 
Amor
Full Member
Members
***
Offline


No personal text

Posts: 366
Location: Germany
Joined: Feb 7th, 2004
Re: MergeFilePrint() frustration.
Reply #9 - Mar 14th, 2008 at 12:47pm
Print Post Print Post  
Hello!

I use [[AddressBlock]] tag in the merge doc in place of individual merge fields
to handles a blank-linesin-the-address-block problem.  And
Replace [[theDate]] merge tag with current formal date  [[Datum]] merge tag
also inserts the current date in the doc.

Since the original RFT-File after the start of the MergeFilePrint is changed. I try to do a copy from the original before the start from it over Shell. Unfortunately, the Shell runs - command not correct. I make one for mistake here surely.


Thanks for the help.

Dr. Belhareth


hier is Batch file:
c:
cd\
C:\sesame2\docs\rft
copy %1  %2
exit



MergePrintFile Code:

ar vTypeFiles as String      // Files of specified type (file extension)
var vSelectedFile as String // Selected file
var n as Int                       // Loop counter
var vDoc as String
var vAddressBlock as String
var vOutputAddressBlock as String
var vResult as String
var vDatei as String
var vDateiKopie as String


PopupSelectPosition(4, @XPos(ThisElement),@YPos(ThisElement))
vPath = "C:\Sesame2\DOCS\RFT"

vType = @Popupmenu(".txt;.doc;.pdf;.htm;.rtf","SELECT FILE")

vAllFiles = @LocalListDirectory(vPath)

For n = 1 to @CountStringArray(vAllFiles)
If @Right(@AccessStringArray(vAllFiles, n), 4) = vType
Then
vTypeFiles = @AppendStringArray(vTypeFiles,@AccessStringArray(vAllFiles, n) )
Next

vTypeFiles = @SortStringArray(vTypeFiles, 0)
vSelectedFile = @PopupChoiceList(vTypeFiles, vPath + "\*" + vType)
vDatei = vPath + "\" + vSelectedFile
@Msgbox("Selected file:","",vDatei)
PopupSelectPosition(0, 0, 0)

vDateiKopie =  vPath + "\2" + vSelectedFile

(??)  n = @AsynchShell("C:\sesame2\copy.bat " + vDatei + " " + vDateiKopie)

// This program uses an [[AddressBlock]] tag in the merge doc
// Read in the rtf merge doc
vDoc = @Insert(vDateiKopie)

// Compile the address block
vAddressBlock = Vorname + " " + NachName + @NL() + Firma +@NL() + Add1 + @NL() + Add2 + @NL() + Plz + ", " +  Ort

// Replace [[theDate]] merge tag with current formal date
vDoc = @Replace(vDoc, "[[Datum]]",@Dom(@ServerDate()) + "." + @Month$(@ServerDate()) + "."+ @Year(@ServerDate()) )

// Collapse any blank lines in address block
vAddressBlock = @Replace(vAddressBlock, @NL() + @NL(),@NL())

// Loop thru the address block and precede each remaining
// line with the rtf "\par" tag for a new paragraph

SetStringArraySeparator(@NL())
For n = 1 to @CountStringArray(vAddressBlock)
vOutputAddressBlock += "\par " + @AccessStringArray(vAddressBlock, n) + @NL()
Next

// Replace the merge doc tag with the reconstituted address block
vDoc = @Replace(vDoc, "[[AddressBlock]]", vOutputAddressBlock)

// vresult = "Myresult"
If FileExists("C:\Sesame2\Myresult.rtf")  then  FileDelete("C:\Sesame2\Myresult.rtf")

// Write output file
FileOverwrite(vDateiKopie, vDoc)

     MergeFilePrint(vDateiKopieNeu, "rtf", "", "", "", "Myresult", 0)
           n = @AsynchShell("Myresult.rtf")
« Last Edit: Mar 16th, 2008 at 11:43am by Amor »  

Dr. med. Amor Belhareth&&Medizin Labor &&Germany
Back to top
 
IP Logged
 
Carl Underwood
Senior Member
Members
*****
Offline



Posts: 1350
Location: New Hampshire
Joined: Mar 11th, 2003
Re: MergeFilePrint() frustration.
Reply #10 - Mar 15th, 2008 at 1:40am
Print Post Print Post  
Quote:
Since the original RFT-File after the start of the MergeFilePrint is changed.

Actually, that is not accurate. The original RTF file is not changed by Sesame. It simply reads the original file into memory, and writes the changes out to a different file. For example, in the following code sample, "Document.rtf" is read into memory, then the modified output is written to "Result.rtf" (the .rtf file extension is omitted because Sesame will use the extension specified in the extension parameter).

Code
Select All
MergeFilePrint("Data\Document.rtf", "rtf", "", "", "", "Data\Result", 1) 





Hmmm... Now that I've looked through your code, I realize that I may have misunderstood what you meant in the statement above.

I see that you are modifying the original RTF file before MergeFilePrint() has a chance to read it. There is another way to handle the AddressBlock.

The documentation indicates that the 5th argument (called "matches") allows us to "match" the merge field names appearing in the merge file with the element names on the form. What is doesn't tell us, is that you can also "match" a merge field name with a variable.

So, rather than modify the RTF document, you should be able to use something like the following:
Code
Select All
MergeFilePrint(vDateiKopieNeu, "rtf", "", "", "AddressBlock=vOutputAddressBlock", "Myresult", 0) 



BTW, I see you already found out that MergeFilePrint() will not overwrite an existing file, so you definately do need to keep using this:
Code
Select All
If FileExists("C:\Sesame2\Myresult.rtf")  then  FileDelete("C:\Sesame2\Myresult.rtf") 

  


Carl Underwood
CDU Computer Consulting LLC
Epsom, New Hampshire
Back to top
IP Logged
 
Amor
Full Member
Members
***
Offline


No personal text

Posts: 366
Location: Germany
Joined: Feb 7th, 2004
Re: MergeFilePrint() frustration.
Reply #11 - Mar 17th, 2008 at 9:49pm
Print Post Print Post  
Hello Carl!
I can ´t  "match" a merge field name with a variable.
MergeFilePrint hier  does not work:

MergeFilePrint(vDatei, "rtf", "", "", "AddressBlock=vOutputAddressBlock", "Myresult", 0)

Thanks.

Dr. Belhareth
« Last Edit: Mar 18th, 2008 at 10:41am by Amor »  

Dr. med. Amor Belhareth&&Medizin Labor &&Germany
Back to top
 
IP Logged
 
Carl Underwood
Senior Member
Members
*****
Offline



Posts: 1350
Location: New Hampshire
Joined: Mar 11th, 2003
Re: MergeFilePrint() frustration.
Reply #12 - Mar 19th, 2008 at 1:40am
Print Post Print Post  
Sorry about that.  Embarrassed    The variable must be outside of the quotes.  Roll Eyes


The correct syntax is like this:
Code
Select All
MergeFilePrint(vDatei, "rtf", "", "", "AddressBlock=" + vOutputAddressBlock, "Myresult", 0)  



Be sure to let me know if this works - it should.
  


Carl Underwood
CDU Computer Consulting LLC
Epsom, New Hampshire
Back to top
IP Logged
 
Amor
Full Member
Members
***
Offline


No personal text

Posts: 366
Location: Germany
Joined: Feb 7th, 2004
Re: MergeFilePrint() frustration.
Reply #13 - Mar 19th, 2008 at 1:15pm
Print Post Print Post  
Hello Carl!
Thanks for the support.
Your proposal runs good, but unfortunately I get shut only the first line of the AddressBlocks !

My code :

/ / Compile the address blocks
vAddressBlock = first name" + " + last name + @NL() + company + @NL() + Add1 + @NL() + Add2 + @NL() + country" + " + Plz" + " + place
/ / Collapse any brightly lines in address blocks
vAddressBlock = @Replace (vAddressBlock, @NL() + @NL(), @NL() )

/ / Loop thru the blocks address and precede each remaining
// line with the rtf "\par" tag to signify new paragraph
SetStringArraySeparator(@NL())
For n = 1 to @CountStringArray(vAddressBlock)
vOutputAddressBlock += "\par " + @AccessStringArray(vAddressBlock, n) + @NL()
Next

If FileExists("C:\Sesame2\Myresult.rtf") then  FileDelete("C:\Sesame2\Myresult.rtf")

vMatches = "AddressBlock=" + vOutputAddressBlock
  MergeFilePrint(vDatei, "rtf", "", "", vMatches,"Myresult", 0)
           n = @AsynchShell("Myresult.rtf")


Thanks.
Dr. Belhareth
  

Dr. med. Amor Belhareth&&Medizin Labor &&Germany
Back to top
 
IP Logged
 
Carl Underwood
Senior Member
Members
*****
Offline



Posts: 1350
Location: New Hampshire
Joined: Mar 11th, 2003
Re: MergeFilePrint() frustration.
Reply #14 - Mar 19th, 2008 at 2:27pm
Print Post Print Post  
Yes, I see what you mean.

I've never tried to use multiple lines in the same variable before, but I just worked it out now.

This is the general template that works properly. It only requires one variable and no loops.
Code
Select All
var vAddressBlock as string

// Build address block
vAddressBlock = LE1 + @NL() + LE2 + @NL() + LE3

// Remove blank lines
vAddressBlock = @Replace(vAddressBlock, @NL() + @NL(), @NL() )

// Insert RTF paragraph tags
vAddressBlock = @Replace(vAddressBlock, @NL(), "\par " + @NL())

// Delete existing output file because MergeFilePrint will not overwrite files
If FileExists("Data\result.rtf")
	FileDelete("Data\result.rtf")

// Merge data with document
MergeFilePrint("Data\Document.rtf", "rtf", "", "", "Address1=" + vAddressBlock, "Data\result", 1)
 



  


Carl Underwood
CDU Computer Consulting LLC
Epsom, New Hampshire
Back to top
IP Logged
 
Carl Underwood
Senior Member
Members
*****
Offline



Posts: 1350
Location: New Hampshire
Joined: Mar 11th, 2003
Re: MergeFilePrint() frustration.
Reply #15 - Mar 19th, 2008 at 2:33pm
Print Post Print Post  
Amor,

BTW, I also noticed that the section of your code which builds the vAddressBlock variable, seems a little mixed up with extra quotes and plus signs, and possibly missing a couple @NL()'s.
  


Carl Underwood
CDU Computer Consulting LLC
Epsom, New Hampshire
Back to top
IP Logged
 
Amor
Full Member
Members
***
Offline


No personal text

Posts: 366
Location: Germany
Joined: Feb 7th, 2004
Re: MergeFilePrint() frustration.
Reply #16 - Mar 19th, 2008 at 8:48pm
Print Post Print Post  
Thanks Carl!

Your example works fine.
Carl,how can i print only a current record  or all Retrieved Records?

Dr. Belhareth

  

Dr. med. Amor Belhareth&&Medizin Labor &&Germany
Back to top
 
IP Logged
 
Carl Underwood
Senior Member
Members
*****
Offline



Posts: 1350
Location: New Hampshire
Joined: Mar 11th, 2003
Re: MergeFilePrint() Questions
Reply #17 - Mar 19th, 2008 at 11:46pm
Print Post Print Post  
Start by putting the merge code into a subroutine, then program a command button using the following sample as a guide.

You will need to replace the "cuPrintInvoice()" portions with the name you give to your subroutine. You'll also want to change the other references to "Invoices" to something that applies to your situation.

Code
Select All
PopupSelectPosition(3, @XPos(ThisElement) + (@Width(ThisElement) / 2) , @YPos(ThisElement) + @Height(ThisElement))
vChoice = @PopupMenu("1. This Record Only;2. All Records in the Result Set", "PRINT INVOICES for")

If @Left(vChoice, 1) = "1"
{
	FormCommit(@Layout)
	cuPrintInvoice()
}
Else If @Left(vChoice, 1) = "2"
{
	If @AskUser("Do you want to PRINT INVOICES for all " + @Str(@ResultSetTotal()) + " records in the result set?", "", "")
	{
		FormCommit(@Layout)
		vRecordInView = @ResultSetCurrentPosition()
		For i = 1 to @ResultSetTotal()
			ResultSetCurrentPosition(i)
			cuPrintInvoice()
		Next
		ResultSetCurrentPosition(vRecordInView)
	}
} 

  


Carl Underwood
CDU Computer Consulting LLC
Epsom, New Hampshire
Back to top
IP Logged
 
Amor
Full Member
Members
***
Offline


No personal text

Posts: 366
Location: Germany
Joined: Feb 7th, 2004
Re: MergeFilePrint() Questions
Reply #18 - Mar 20th, 2008 at 1:58pm
Print Post Print Post  
Hello Carl!
That is particularly kind of you and would like to thank you for your patience  to help us.
I already have  integrated your example code in my code and changed my MergeFilePrint Project in a Subroutine.
I have still another problem with printing to word and to Printer:
The Print-process is long, there i must confirm individually each record to print.
Can I send all the selected records to the Printer or Word at once?

Thank you again in advance.

Dr. Belhareth
  

Dr. med. Amor Belhareth&&Medizin Labor &&Germany
Back to top
 
IP Logged
 
Carl Underwood
Senior Member
Members
*****
Offline



Posts: 1350
Location: New Hampshire
Joined: Mar 11th, 2003
Re: MergeFilePrint() Questions
Reply #19 - Mar 20th, 2008 at 2:36pm
Print Post Print Post  
If you don't specify an output file, the output will go straight to the default printer.

For example you would replace this:
Code
Select All
MergeFilePrint(vDatei, "rtf", "", "", "AddressBlock=" + vOutputAddressBlock, "MyResult", 0) 



With this:
Code
Select All
MergeFilePrint(vDatei, "rtf", "", "", "AddressBlock=" + vOutputAddressBlock, "", 0) 



Notice that "MyResult" was replaced with "".
  


Carl Underwood
CDU Computer Consulting LLC
Epsom, New Hampshire
Back to top
IP Logged
 
Carl Underwood
Senior Member
Members
*****
Offline



Posts: 1350
Location: New Hampshire
Joined: Mar 11th, 2003
Re: MergeFilePrint() Questions
Reply #20 - Mar 20th, 2008 at 2:49pm
Print Post Print Post  
BTW, if you send the output directly to the printer, no file is created on disk. So, this also means that you can remove the following lines from your code:

Code
Select All
If FileExists("C:\Sesame2\Myresult.rtf") then  FileDelete("C:\Sesame2\Myresult.rtf")

n = @AsynchShell("Myresult.rtf") 

 
  


Carl Underwood
CDU Computer Consulting LLC
Epsom, New Hampshire
Back to top
IP Logged
 
Bharat_Naik
Senior Member
Members
*****
Offline


Ever ready to learn and
share

Posts: 1202
Location: Chicago,  Illinois
Joined: Dec 16th, 2003
Re: MergeFilePrint() Questions
Reply #21 - Mar 21st, 2008 at 4:59pm
Print Post Print Post  
Quote:
(on a side note right clicking in the property editor field offers a choice of Grab Current Value- once grabbed how do I paste this? Ctrl V does not work)


The best way to get the element list (especially if there are many elements in the form) to use @StringArrayElementList( ). Display them in the Slate and then you got all of them at once and do whatever you want. This method I found useful while using @XLookUpSourceList ( ).
  
Back to top
 
IP Logged
 
Bharat_Naik
Senior Member
Members
*****
Offline


Ever ready to learn and
share

Posts: 1202
Location: Chicago,  Illinois
Joined: Dec 16th, 2003
Re: MergeFilePrint() Questions
Reply #22 - Mar 21st, 2008 at 10:04pm
Print Post Print Post  
I have used MergeFilePrint() before but after genius of Carl found out undocumented feature of it ability to use variables make it a lot more attractive.  I have detected a couple of anomalies with this command, may be that might have to do with the other software setup such as MS Word.

1.  I could not get .rtf file to work when I save the file in MS Word as .rtf file. If I open the .rtf file in WordPad and then save it in WordPad, the file works fine.

2.  The display .rtf file does not pick up the page setup of the merge document .rtf  that I think it should. I have not tested that with printeout of document .. whether that takes the page setup of the merge document or that of displayed document using @AsynchShell ( ) command.
  
Back to top
 
IP Logged
 
Carl Underwood
Senior Member
Members
*****
Offline



Posts: 1350
Location: New Hampshire
Joined: Mar 11th, 2003
Re: MergeFilePrint() Questions
Reply #23 - Mar 22nd, 2008 at 3:16am
Print Post Print Post  
Bharat_Naik wrote on Mar 21st, 2008 at 10:04pm:
1.  I could not get .rtf file to work when I save the file in MS Word as .rtf file. If I open the .rtf file in WordPad and then save it in WordPad, the file works fine.

Word does save the RTF file in a slightly different pattern than WordPad does. Naturally, this can have an effect on how you deal with an RTF file when manipulating it in SBasic.

For instance, WordPad places the "\par" paragraph tag at the end of a line followed by CRLF (Carraige Return w/Line Feed) like this:
Code
Select All
[[Name]]\par
[[Address1]]\par
[[Address2]]\par
[[City]], [[State]] [[Zip Code]]\par 



Whereas Word places the CRLF before the paragraph tag, then followed by a space like this:
Code
Select All
[[Name]]
\par [[Address1]]
\par [[Address2]]
\par [[City]], [[State]] [[Zip Code]]
\par  


(Note that you MUST maintain the space between the "\par" tag and the text that appears after it. Otherwise, the entire line will be ignored in the final output.)

So yes, there's a logical reason why saving it with WordPad may have "fixed" it, because it would have reversed the order of the CRLFs and the "\par" tags.
  


Carl Underwood
CDU Computer Consulting LLC
Epsom, New Hampshire
Back to top
IP Logged
 
Bharat_Naik
Senior Member
Members
*****
Offline


Ever ready to learn and
share

Posts: 1202
Location: Chicago,  Illinois
Joined: Dec 16th, 2003
Re: MergeFilePrint() Questions
Reply #24 - Mar 23rd, 2008 at 7:54am
Print Post Print Post  
Thanks Carl for explanation.  You see so much of garbage in RTF file when you open it in notepad, really hard to  decipher.
« Last Edit: Mar 27th, 2008 at 8:50am by Bharat_Naik »  
Back to top
 
IP Logged
 
Bharat_Naik
Senior Member
Members
*****
Offline


Ever ready to learn and
share

Posts: 1202
Location: Chicago,  Illinois
Joined: Dec 16th, 2003
Re: MergeFilePrint() Questions
Reply #25 - Mar 24th, 2008 at 3:00pm
Print Post Print Post  
Quote:
// Insert RTF paragraph tags
vAddressBlock = @Replace(vAddressBlock, @NL(), "\par " + @NL())


I am finding it difficult to pass on "\par" to merge. The whole tag seems to disappear and nothing merges. I am using Word2002 and I believe, if it is working for some of you, not for me, probably it is related to Word setup and version. Any ideas to make it work. It has been great help to find out that variables can be merged.  If we could pass on the CR in the merged field that would be great for some applications.
  
Back to top
 
IP Logged
 
Bharat_Naik
Senior Member
Members
*****
Offline


Ever ready to learn and
share

Posts: 1202
Location: Chicago,  Illinois
Joined: Dec 16th, 2003
Re: MergeFilePrint() Questions
Reply #26 - Mar 24th, 2008 at 6:11pm
Print Post Print Post  
I made the .rtf file all over and then used the code with "\par" and it worked fine. So, I believe earlier problem was related to pdf file.  I also tried out .htm file and with that replacing @NL () with  "<br>" works fine too.  However, I prefer .rtf file as you have better control with the printing and page layout.  Thanks for the code.

Note: file name is corrected from .pdf to .rtf after Mark pointed out as under.  Thanks Mark.
  
Back to top
 
IP Logged
 
The Cow
YaBB Administrator
*****
Offline



Posts: 2530
Joined: Nov 22nd, 2002
Re: MergeFilePrint() Questions
Reply #27 - Mar 24th, 2008 at 6:32pm
Print Post Print Post  
Several times you have mentioned working on .pdf files as opposed to .rtf files. Do you mean .rtf files?
  

Mark Lasersohn&&Programmer&&Lantica Software, LLC
Back to top
IP Logged
 
Bharat_Naik
Senior Member
Members
*****
Offline


Ever ready to learn and
share

Posts: 1202
Location: Chicago,  Illinois
Joined: Dec 16th, 2003
Re: MergeFilePrint() Questions
Reply #28 - Mar 24th, 2008 at 6:36pm
Print Post Print Post  
Sorry, what I meant is .rtf file instead of .pdf.  Thanks for pointing out. Let me correct it, so someone does not get misguided.
  
Back to top
 
IP Logged
 
Carl Underwood
Senior Member
Members
*****
Offline



Posts: 1350
Location: New Hampshire
Joined: Mar 11th, 2003
Re: MergeFilePrint() Questions
Reply #29 - Mar 25th, 2008 at 2:39am
Print Post Print Post  
Bharat_Naik wrote on Mar 24th, 2008 at 3:00pm:
I am finding it difficult to pass on "\par" to merge. The whole tag seems to disappear and nothing merges.

That can happen if you don't have a space after \par, and other text follows it before the next CRLF.

Quote:
If we could pass on the CR in the merged field that would be great for some applications.

Actually, you don't need it. The \par tag is what really tells WordPad (or Word) to start a new line. The main reason I had @NL() in my code, was so that the file would be more readable when looking at it in a text editor like Notepad.

For example, take the following two sections of RTF:
Code
Select All
[[Name]]\par [[Address1]]\par [[Address2]]\par [[City]], [[State]] [[Zip Code]]\par 

(It's crucial that there be a space after each \par.)

Code
Select All
[[Name]]\par
[[Address1]]\par
[[Address2]]\par
[[City]], [[State]] [[Zip Code]]\par 



Both of those examples will show up in Word or WordPad like this, so you don't really need the CRs:
Code
Select All
[[Name]]
[[Address1]]
[[Address2]]
[[City]], [[State]] [[Zip Code]] 

  


Carl Underwood
CDU Computer Consulting LLC
Epsom, New Hampshire
Back to top
IP Logged
 
Bharat_Naik
Senior Member
Members
*****
Offline


Ever ready to learn and
share

Posts: 1202
Location: Chicago,  Illinois
Joined: Dec 16th, 2003
Re: MergeFilePrint() Questions
Reply #30 - Mar 25th, 2008 at 8:19am
Print Post Print Post  
I am lost with the Fold feature of the MergeFilePrint( ). As stated in the programming manual, it is indeed tricky. I have edited the file using Notepad, moved everything from the mergefield line in the file except the Mergefield and still it is refusing to fold.  I tried all different ways to place /Par and /Pard but still having hard time to have it fold when there is no matching value in the only mergefield in the line. Nothing seems to be clicking for folding to work. I am sure there is some trick to it but cannot seem to make it work. Please help.
  
Back to top
 
IP Logged
 
Bharat_Naik
Senior Member
Members
*****
Offline


Ever ready to learn and
share

Posts: 1202
Location: Chicago,  Illinois
Joined: Dec 16th, 2003
Re: MergeFilePrint() Questions
Reply #31 - Mar 25th, 2008 at 1:34pm
Print Post Print Post  
This is prescription printout. I am just placing the part of the .rtf file and how it looks in notepad and how it looks after editing.

.rtf file

Code
Select All
[[M4]]
[[I4]]
[[M5]]
[[I5]]
[[M6]]
[[I6]]
 




Notepad preedit:

Code
Select All
{\insrsid14817277 [[M4]]
\par }\pard \s15\ql \fi720\li0\ri0\widctlpar\wrapdefault\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0\pararsid14817277 {\insrsid14817277 [[I4]]
\par }\pard \s15\ql \li0\ri0\widctlpar\wrapdefault\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0\pararsid14817277 {\insrsid14817277 [[M5]]
\par }\pard \s15\ql \li720\ri0\widctlpar\wrapdefault\aspalpha\aspnum\faauto\adjustright\rin0\lin720\itap0\pararsid14817277 {\insrsid14817277 [[I5]]
\par }\pard \s15\ql \li0\ri0\widctlpar\wrapdefault\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0\pararsid14817277 {\insrsid14817277 [[M6]]
\par }\pard \s15\ql \li720\ri0\widctlpar\wrapdefault\aspalpha\aspnum\faauto\adjustright\rin0\lin720\itap0\pararsid14817277 {\insrsid14817277 [[I6]]
\par }\pard \s15\ql \li0\ri0\widctlpar\wrapdefault\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0\pararsid14817277
 




After editing in the notebook as suggested in the programing guide in order for it to fold:

Code
Select All
{\insrsid14817277
[[M4]]
\par }\pard \s15\ql \fi720\li0\ri0\widctlpar\wrapdefault\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0\pararsid14817277 {\insrsid14817277
[[I4]]
\par }\pard \s15\ql \li0\ri0\widctlpar\wrapdefault\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0\pararsid14817277 {\insrsid14817277
[[M5]]
\par }\pard \s15\ql \li720\ri0\widctlpar\wrapdefault\aspalpha\aspnum\faauto\adjustright\rin0\lin720\itap0\pararsid14817277 {\insrsid14817277
[[I5]]
\par }\pard \s15\ql \li0\ri0\widctlpar\wrapdefault\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0\pararsid14817277 {\insrsid14817277
[[M6]]
\par }\pard \s15\ql \li720\ri0\widctlpar\wrapdefault\aspalpha\aspnum\faauto\adjustright\rin0\lin720\itap0\pararsid14817277 {\insrsid14817277
[[I6]]
\par }\pard \s15\ql \li0\ri0\widctlpar\wrapdefault\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0\pararsid14817277
 



The MergeFilePrint ( )

Code
Select All
MergeFilePrint(vPath , "rtf", "", "", vExtFields, "Data\prescription_test", 1)
 



This should fold when there is no data to merge for field "M5" and "I5" but it is not folding. What am I doing wrong?


  
Back to top
 
IP Logged
 
Carl Underwood
Senior Member
Members
*****
Offline



Posts: 1350
Location: New Hampshire
Joined: Mar 11th, 2003
Re: MergeFilePrint() Questions
Reply #32 - Mar 25th, 2008 at 2:12pm
Print Post Print Post  
I don't know, because I never could get it to "fold" either. That's the reason for using a variable that contains a block of data which is stripped of blank lines, then inserted via MergeFilePrint().
  


Carl Underwood
CDU Computer Consulting LLC
Epsom, New Hampshire
Back to top
IP Logged
 
Bharat_Naik
Senior Member
Members
*****
Offline


Ever ready to learn and
share

Posts: 1202
Location: Chicago,  Illinois
Joined: Dec 16th, 2003
Re: MergeFilePrint() Questions
Reply #33 - Mar 25th, 2008 at 2:51pm
Print Post Print Post  
Code
Select All
// Remove blank lines
vAddressBlock = @Replace(vAddressBlock, @NL() + @NL(), @NL() )
 



Initially I could not get the importance of above code but now I understand it. I have 32 such collapsing mergefields in one rtf mergefile to print.  I guess I will have to go with the above code.

The other solution I was thinking was to remove \par with notepad edits and merge \par with the mergefiled whenever data is present for that mergefield.

if vM1 <> "" then
       {
              vM1 = vM1 + " /Par"
       }
     
This will work, I believe,  but yours is a lot better way since if you want to change the rtf file you do not have to go through the whole routine of notepad edits of rtf file and then save.

I hope Lanticans are watching this thread and doing something about the "Fold" parameter that is either not working or we do not know how to make it work. Thanks Carl,  for your input.
  
Back to top
 
IP Logged
 
The Cow
YaBB Administrator
*****
Offline



Posts: 2530
Joined: Nov 22nd, 2002
Re: MergeFilePrint() Questions
Reply #34 - Mar 25th, 2008 at 3:41pm
Print Post Print Post  
Bharat_Naik wrote on Mar 25th, 2008 at 2:51pm:
I hope Lanticans are watching this thread and doing something about the "Fold" parameter that is either not working or we do not know how to make it work. Thanks Carl,  for your input.


We are watching. However, there is not much we can do without forcing the command to only work with .rtf or another singular ASCII format. The problem you are having is due to the paragraph code being inserted by your word processor between each block of text, whether or not that block contains any actual text. We can, of course, eliminate the content text using the "fold option", but we cannot interpret and remove any formatting that may occur around that empty block. 
  

Mark Lasersohn&&Programmer&&Lantica Software, LLC
Back to top
IP Logged
 
Bharat_Naik
Senior Member
Members
*****
Offline


Ever ready to learn and
share

Posts: 1202
Location: Chicago,  Illinois
Joined: Dec 16th, 2003
Re: MergeFilePrint() Questions
Reply #35 - Mar 25th, 2008 at 3:56pm
Print Post Print Post  
Quote:
there is not much we can do without forcing the command to only work with .rtf or another singular ASCII format.


As mentioned in the programming guide.
Quote:
RTF documents are usually the best choice to use with MergeFilePrint .......


Can we have one exclusive command just for RTF file over and above this?  Just a suggestion.
  
Back to top
 
IP Logged
 
The Cow
YaBB Administrator
*****
Offline



Posts: 2530
Joined: Nov 22nd, 2002
Re: MergeFilePrint() Questions
Reply #36 - Mar 25th, 2008 at 4:07pm
Print Post Print Post  
Bharat_Naik wrote on Mar 25th, 2008 at 3:56pm:
Quote:
there is not much we can do without forcing the command to only work with .rtf or another singular ASCII format.


As mentioned in the programming guide.
Quote:
RTF documents are usually the best choice to use with MergeFilePrint .......


Can we have one exclusive command just for RTF file over and above this?  Just a suggestion.


Its not that rtf is a bad choice. If you tell any formatting language to break a line, whether via "par" in rtf or "<B>" in HTML, you will end up breaking the line, even if there is no content there. There may be a way to tell rtf or postrscript to "fold" the formatting as well (much like "<P>" can do in HTML), but I doubt MSWord will insert that in for you automatically.
« Last Edit: Mar 25th, 2008 at 5:10pm by The Cow »  

Mark Lasersohn&&Programmer&&Lantica Software, LLC
Back to top
IP Logged
 
Bharat_Naik
Senior Member
Members
*****
Offline


Ever ready to learn and
share

Posts: 1202
Location: Chicago,  Illinois
Joined: Dec 16th, 2003
Re: MergeFilePrint() Questions
Reply #37 - Mar 25th, 2008 at 5:31pm
Print Post Print Post  
Thanks for your Input Mark. I want to share my experience with MergeFilePrint() command.  Over period of time to answer the need for mergeprinting various methods have evolved in the form of Wordmerge, Wordmerge Lite, Simple text file merging, various versions and upgrades of wordmerge and we have followed them one by one and still felt how good it would be if we had inbuilt word processor just like Q&A.

Each method has their limitations, Wordmerge you have to stop or use external program's Macro and visual basics and/or modify Registry to cleanly printout the merged data without any interruption.  With Wordmerge Lite I was missing the complete control over the formating and how it prints out on paper that is the limitation we have come to know about HTML, looks great on display however.  With plain text file merging you miss that text enhancement and formating both.

When I looked at MergeFilePrint() command, it practically solved my all mergeprint needs.  It printout document without interruption, it has all the enhancements. I do not think even development team envisioned it to carry out merging of data from external applications with its "Matches" parameter.


I can manipulate and format data whatever way I want using s-basic in Sesame itself.  If I want to review the document and edit before I print out without disturbing standard merge document, no problems.  It is extremely compact command with seven parameters without making source file or various documents menu or whatever.  What user want is the result with the least interference or input when it could be avoided.

For me, if any of the prescription field has value, just print a prescription, when lab is ordered as per the Lab element just print that form in the lab, the same for consultation, x-ray requisition, going back to school or work statements etc. all these selectively done as needed without pressing any button when record is new.  All these can be done with minimum of codeing with MergeFilePrint() command with RTF option. 

There are couple of limitations however..
1. Cannot beat printstring() when dealing with pre-printed forms.
2. I wish to have option of AlternateDefaultPrinter
3. Fold is currently not working with .rtf file but this could be worked around using "Matches" parameter.

Why am I blabbering all these? Well, this command could be the answer to mergeprinting needs without having inbuilt word-processor.  More than anything else, the mergeprint needs are taken care of with minimal programing and great results.  I wish Sesame Development team to invest more time and effort in order to enhance and develop this command further.
  
Back to top
 
IP Logged
 
The Cow
YaBB Administrator
*****
Offline



Posts: 2530
Joined: Nov 22nd, 2002
Re: MergeFilePrint() Questions
Reply #38 - Mar 25th, 2008 at 6:55pm
Print Post Print Post  
Bharat and Carl, try this. I just built a rtf file with the usual content. Then I edited it so that the merge fields all appear concatenated on the same line:
Code
Select All
This is a test of folding:
\par
[[First]]\par[[Last]]\par[[Company]]\par
\par
This is the end of the folding test
 


I then set Last element on my test record to be blank and ran this with the fold flag set. In the output, the Company element appeared after the First element, without an intervening blank line.
  

Mark Lasersohn&&Programmer&&Lantica Software, LLC
Back to top
IP Logged
 
Carl Underwood
Senior Member
Members
*****
Offline



Posts: 1350
Location: New Hampshire
Joined: Mar 11th, 2003
Re: MergeFilePrint() Questions
Reply #39 - Mar 25th, 2008 at 7:12pm
Print Post Print Post  
Mark,

If Last DOES have a value, this will cause First and Company to appear on the same line without Last.

You need to have a space after "\par" to allow Last to be displayed. But, that space will cause a blank line when Last is blank.

I'm working on a solution. More on this later... Wink
  


Carl Underwood
CDU Computer Consulting LLC
Epsom, New Hampshire
Back to top
IP Logged
 
The Cow
YaBB Administrator
*****
Offline



Posts: 2530
Joined: Nov 22nd, 2002
Re: MergeFilePrint() Questions
Reply #40 - Mar 25th, 2008 at 7:24pm
Print Post Print Post  
Shoot! I shoulda known. Foiled again.

In any case, I'm working on a solution internal to the MergeFilePrint command that allows the rest of the line, until linefeed or another merge field, to be folded.
  

Mark Lasersohn&&Programmer&&Lantica Software, LLC
Back to top
IP Logged
 
Bharat_Naik
Senior Member
Members
*****
Offline


Ever ready to learn and
share

Posts: 1202
Location: Chicago,  Illinois
Joined: Dec 16th, 2003
Re: MergeFilePrint() Questions
Reply #41 - Mar 25th, 2008 at 7:29pm
Print Post Print Post  
Thanks Mark. In the meantime we will work with the workaround !
  
Back to top
 
IP Logged
 
Bharat_Naik
Senior Member
Members
*****
Offline


Ever ready to learn and
share

Posts: 1202
Location: Chicago,  Illinois
Joined: Dec 16th, 2003
Re: MergeFilePrint() Questions
Reply #42 - Mar 25th, 2008 at 7:46pm
Print Post Print Post  
This workaround is made using Carl's idea and it works perfectly well for me. The Element name and application will be different for you but the code goes as follows.

Code
Select All
var n as int
var vPath as String = "C:\Sesame2\Docs\Understand.rtf"
var vAddress as String
var vApt_Number as String
var vCity as String
var vState as String
var vZip as String
var vPhone as String
var vMG as String
var vFileName as String   //only used during testing or when you want to review before printing
var vExtFields as String
var vScript as String

vAddress = @XLookup (@FN, RecNumber, "Index!RecNumber", "Address")
vApt_Number = @XLookup (@FN, RecNumber, "Index!RecNumber", "Apt_Number")
vCity = @XLookup (@FN, RecNumber, "Index!RecNumber", "City")
vState = @XLookup (@FN, RecNumber, "Index!RecNumber", "State")
vZip = @XLookup (@FN, RecNumber, "Index!RecNumber", "Zip")
vPhone = @XLookup (@FN, RecNumber, "Index!RecNumber", "Phone")

// Build Script block
vScript = 	M1 + @NL( ) + I1 + @NL ( ) +
		M2 + @NL( ) + I2 + @NL ( ) +
		M3 + @NL( ) + I3 + @NL ( ) +
		M4 + @NL( ) + I4 + @NL ( ) +
		M5 + @NL( ) + I5 + @NL ( ) +
		M6 + @NL( ) + I6 + @NL ( ) +
		M7 + @NL( ) + I7 + @NL ( ) +
		M8 + @NL( ) + I8 + @NL ( ) +
		MA + @NL( ) + IA + @NL ( ) +
		MB + @NL( ) + IB + @NL ( ) +
		MC + @NL( ) + IC + @NL ( ) +
		MD + @NL( ) + ID + @NL ( ) +
		ME + @NL( ) + IE + @NL ( ) +
		MG + @NL( ) + IG

// Remove blank lines
While @IN (vScript, @NL( ) + @NL( )) > 0
	{
		vScript = @Replace(vScript, @NL() + @NL(), @NL() )
	}

// Insert RTF paragraph tags

vScript = @Replace(vScript, @NL(), "\par " )

//WriteLN (vScript)


/*

vMG = MG
// Insert RTF paragraph tags
//vMG = @Replace(vMG, @NL(), "<BR> ")    //For .htm file
vMG = @Replace(vMG, @NL(), "\par" + @NL ( ))   // for .rtf file)


//WriteLN (vMG)

*/




vFileName = "c:\sesame2\Data\Und_test.rtf"


	if fileExists(vFileName)
	{
		fileDelete(vFileName)
	}

vExtFields = "Address=" + vAddress + ";Apt_Number=" + vApt_Number + ";City=" + vCity + ";State=" + vState +
 ";Zip=" + vZip + ";Phone=" + vPhone + ";MGG=" + vMG + ";Script=" + vScript


MergeFilePrint(vPath , "rtf", "", "", vExtFields, "Data\Und_test", 0)   //file will print without displaying
n = @AsynchShell (vFileName)


 



The good part about this workaround is that one does not have to edit RTF file in Notepad even if you make any change.
  
Back to top
 
IP Logged
 
Bharat_Naik
Senior Member
Members
*****
Offline


Ever ready to learn and
share

Posts: 1202
Location: Chicago,  Illinois
Joined: Dec 16th, 2003
Re: MergeFilePrint() Questions
Reply #43 - Mar 26th, 2008 at 2:46pm
Print Post Print Post  
The other limitation of MergeFilePrint() that I forgot to mention is it's inability to handle element's data with carriage return or paragraphs. Simply replacing @NL () with "\par " will not work. but if you place couple of loops as in the code under will take care of that limitation. This is once again just Sesame side coding and it does not involve editing of RTF document file with Notepad.

Code
Select All
var n as int
var vPath as String = "C:\Sesame2\Docs\Understand.rtf"
var vAddress as String
var vApt_Number as String
var vCity as String
var vState as String
var vZip as String
var vPhone as String
var vFileName as String   //only used during testing or when you want to review before printing
var vExtFields as String
var vList as String
var vUnderstanding as String
var vUND as String

SetStringArraySeparator (";")  //since later on we are using Set and restore different separator so it is needed

//Following used to Merge Data from different database or applications

vList = @XLookupSourceList (@FN, RecNumber, "Index!RecNumber", "Address;Apt_Number;City;State;Zip;Phone")

vAddress = @AccessStringArray (vList, 1)
vApt_Number = @AccessStringArray (vList, 2)
vCity = @AccessStringArray (vList, 3)
vState = @AccessStringArray (vList, 4)
vZip = @AccessStringArray (vList, 5)
vPhone = @AccessStringArray (vList, 6)

If vApt_Number <> "" then
	{
		vAddress = vAddress + " APt#: " + vApt_Number
	}

//This will take care for carriage return if any
vUnderStanding = UND

//Remove Blank lines

While @IN (vUnderstanding, @NL ( ) + @NL ( )) > 0
	{

		vUnderstanding = @Replace (vUnderstanding, @NL ( ) + @NL ( ), @NL ( ))
	}



SetStringArraySeparator (@NL())

For n = n to @CountStringArray(vUnderstanding)
	vUND = vUND + @AccessStringArray (vUnderstanding, n) + "\par "
	Next
RestoreStringArraySeparator ( )

vUnderstanding = vUND


// vUnderstanding = @Replace (vUnderstanding, @NL ( ), "\Par ") //Space after \par is very important //did not work for format paragraph

vFileName = "c:\sesame2\Data\Und_test.rtf"


	if fileExists(vFileName)
	{
		fileDelete(vFileName)
	}

vExtFields = "Address=" + vAddress + ";City=" + vCity + ";State=" + vState +
 ";Zip=" + vZip + ";Phone=" + vPhone + ";Understand=" + vUnderstanding


// MergeFilePrint(vPath , "rtf", "", "", vExtFields, "Data\Und_test", 0)   //file will display before printing
// n = @AsynchShell (vFileName)

MergeFilePrint(vPath , "rtf", "", "", vExtFields, "", 0) //File will print without displaying

 



Mark, as you mentioned earlier that you are working on the internal command. Since this is purely Sesame side modification, somehow you can accommodate in the code.
  
Back to top
 
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: MergeFilePrint() Questions
Reply #44 - Mar 26th, 2008 at 3:00pm
Print Post Print Post  
Again, Bharat, this "inability" depends on the interpreter for the file format you are merging with. Some formats see a newline as a newline, others do not and require a special tag instead. If you are merging to a plain text format that respects newlines, then the newlines will appear just fine.

We are looking at this and will do what we can, but we don't actually control how these formats and interpreters behave.
  

- Hammer
The plural of anecdote is not data.
Back to top
IP Logged
 
Bharat_Naik
Senior Member
Members
*****
Offline


Ever ready to learn and
share

Posts: 1202
Location: Chicago,  Illinois
Joined: Dec 16th, 2003
Re: MergeFilePrint() Questions
Reply #45 - Mar 26th, 2008 at 3:43pm
Print Post Print Post  
You are right Erika. I am strictly talking about RTF file format with MergeFilePrint() command. RTF seems to address the most of the merge print needs and I have come to like it so much. I have realized that MergeFilePrint() command takes care of other file formats such as HTM, PS and txt in addition to RTF and I believe some of the limitations with RTF file are particularly linked to that broad applicability.  With RTF fomat, since most of the issues can be handled from Sesame side with s-basic, I can live with it.  However, RTF file is method of choice as mentioned in the Programming Guide, separate command could be made available addressing to the need of just RTF file. Or am I asking too much?

Quote:
We are looking at this and will do what we can,

Thanks.
  
Back to top
 
IP Logged
 
BOBSCOTT
Senior Member
Members
*****
Offline


That Darn Computer #$X#
{curse words}

Posts: 1195
Joined: Nov 22nd, 2002
Re: MergeFilePrint() Questions
Reply #46 - Mar 26th, 2008 at 6:37pm
Print Post Print Post  
Thanks for the concise write up guys this thread is extremely helpful.

In my experience I have found that for me the sbasic printstring() commands to be my best option if multiple users / machines will be using the application. Every time I have deployed an application using mergefile something is different on one machine or someone upgrades the word processor program and the merge has issues. It takes me a little longer to get my output just the way I need it with Sbasic and printstring() commands but it works fine every time on every machine. I have 1 user using ubuntu Linux and it works as well as the Vista or XP user machines outputing with printstring().

I for one am hooked on Printstring()  Smiley
  

Team – Together Everyone Achieves More
Back to top
 
IP Logged
 
Bharat_Naik
Senior Member
Members
*****
Offline


Ever ready to learn and
share

Posts: 1202
Location: Chicago,  Illinois
Joined: Dec 16th, 2003
Re: MergeFilePrint() Questions
Reply #47 - Mar 26th, 2008 at 9:03pm
Print Post Print Post  
Hi Bob,  You are the one who started this thread!

Yes, this is indeed an eye opener as to what simple one line command can do for you. I have gone through the drudgery of going through customizing and formating values in MS Word using Mergefield switches and going through Word Macro and even a little of VB and all that for practically nothing and never could get it to work to my 100% satisfaction.

As far as @PrintString ( ) goes, I like it and have used it for precise printing as it is required in  pre-printed forms.  But for an average user, one has to work with it and devote quite a long time to be comfortable using it and get some great results. But you are right, once you get it to work, there is no looking back. It will work great every  time and since no external program involved, we are not at the mercy of other program or company.

Credit goes to Sesame development team to provide us with all different tools to work with and meeting everybody's needs as per ones comfort level, temperament and working knowledge.

For me, I have come to rely on MergeFilePrint() in RTF format for my mergeprint requirement and very happy with it so far.  This thread has explored the command to the fullest.... or may be not. Still a lot can be done with it!!!
« Last Edit: Mar 26th, 2008 at 11:06pm by Bharat_Naik »  
Back to top
 
IP Logged
 
Bharat_Naik
Senior Member
Members
*****
Offline


Ever ready to learn and
share

Posts: 1202
Location: Chicago,  Illinois
Joined: Dec 16th, 2003
Re: MergeFilePrint() Questions
Reply #48 - Mar 27th, 2008 at 7:11pm
Print Post Print Post  
For AlternateDefaultPrinter ( ) with MergeFilePrint() command, I was exploring if it is possible to change the Default printer on the fly with commandline code in Windows Operating system. Here what I have found...

http://www.robvanderwoude.com/2kprintcontrol.html

Set printer as default
    RUNDLL32 PRINTUI.DLL,PrintUIEntry /y /n "printer"

Restore all printer settings from a file
    RUNDLL32 PRINTUI.DLL,PrintUI /Sr /n "printer" /a "file.dat"

I have not tested it yet but looking at this, it seems that this could be used with @Shell command to change AlternateDefaultprinter() on the fly using SBasic  with MergeFilePrint() command using RTF file option or am I just dreaming? 


  
Back to top
 
IP Logged
 
Bharat_Naik
Senior Member
Members
*****
Offline


Ever ready to learn and
share

Posts: 1202
Location: Chicago,  Illinois
Joined: Dec 16th, 2003
Re: MergeFilePrint() Questions
Reply #49 - Mar 27th, 2008 at 9:44pm
Print Post Print Post  
Set printer as default
    RUNDLL32 PRINTUI.DLL,PrintUIEntry /y /n "printer"

The above command seems to work fine. I ran that using "RUN" box and it did change the default printer.

However I do not understand how to set up the following file in order to reset the default printer again.

Restore all printer settings from a file
    RUNDLL32 PRINTUI.DLL,PrintUI /Sr /n "printer" /a "file.dat"


Or just may be I can use the first command again to set the normal default printer. One before the the MergeFilePrint() command and one after to reset to original printer. I would appreciate the guidance in this matter.  Thanks.

Bharat
  
Back to top
 
IP Logged
 
Ray the Reaper
Global Moderator
Members
Lantica Support
*****
Offline


The One & The Only

Posts: 2480
Joined: Aug 20th, 2003
Re: MergeFilePrint() Questions
Reply #50 - Mar 28th, 2008 at 1:31pm
Print Post Print Post  
Hello Bharat,

You can use the /Ss switch to create the file that stores the printer settings.

RUNDLL32 PRINTUI.DLL,PrintUIEntry /Ss /n "printer" /a "file.dat"

-Ray
  

Raymond Yoxall Consulting
ray.yoxall@gmail.com
ryoxall@lantica.com
Sesame Applications, Design and Support
Back to top
IP Logged
 
Bharat_Naik
Senior Member
Members
*****
Offline


Ever ready to learn and
share

Posts: 1202
Location: Chicago,  Illinois
Joined: Dec 16th, 2003
Re: MergeFilePrint() Questions
Reply #51 - Mar 28th, 2008 at 5:28pm
Print Post Print Post  
Thanks Ray. I think now incorporating this, we should be able to use any printer on the network with MergeFilePrint ( ) with RTF file and Windows OS without displaying the document to be printed (on the fly).
« Last Edit: Mar 28th, 2008 at 8:44pm by Bharat_Naik »  
Back to top
 
IP Logged
 
Amor
Full Member
Members
***
Offline


No personal text

Posts: 366
Location: Germany
Joined: Feb 7th, 2004
Re: MergeFilePrint() Questions
Reply #52 - Mar 30th, 2008 at 3:52pm
Print Post Print Post  
Hello!

I must say that MergeFilePrint()  beside the Xresult Commands and  the simple Search future are the best true innovation in sesame 2.0.
I use the MergeFilePrint() command to merge data from external applications with its "Matches" parameter.

I can manipulate and format data whatever way i want using s-basic in Sesame itself.

With RTF fomat, can i conditionally change the color of a field from Sesame side with s-basic?

Thank you for the help.

Dr. Belharetrh
  

Dr. med. Amor Belhareth&&Medizin Labor &&Germany
Back to top
 
IP Logged
 
Bharat_Naik
Senior Member
Members
*****
Offline


Ever ready to learn and
share

Posts: 1202
Location: Chicago,  Illinois
Joined: Dec 16th, 2003
Re: MergeFilePrint() Questions
Reply #53 - Mar 30th, 2008 at 5:18pm
Print Post Print Post  
Yes, It can be done. It requires a little work but If your application warrants it, it can be done.

Here how I did it.

First find out the code for Color from RTF file. You can make any dummy file and open it in the Notepad. you will see the code..

For blue it is  -   \cf2\insrsid16728339\charrsid16728339

(The above might have included codes for fonts and other enhancements)

Just place that in front of text that you want to merge.

vName = "\cf2\insrsid16728339\charrsid16728339" + " " + vName


When you assign ";Name=" vName

Name mergefield in the rtf display will be blue.

MergeFilePrint ( ) with RTF file is indeed impressive. Since all your work is done in Sesame with SBasic, you have a lot more control on format of the output.

Bharat

  
Back to top
 
IP Logged
 
Bharat_Naik
Senior Member
Members
*****
Offline


Ever ready to learn and
share

Posts: 1202
Location: Chicago,  Illinois
Joined: Dec 16th, 2003
Re: MergeFilePrint() Questions
Reply #54 - Mar 30th, 2008 at 11:31pm
Print Post Print Post  
On testing above further, the code is very inconsistent.  It is hard to terminate it at the end of the mergefield. I really do not know much about RTF format. Just trying to learn using notepad. I am sure someone will get better results and I did.
  
Back to top
 
IP Logged
 
Bharat_Naik
Senior Member
Members
*****
Offline


Ever ready to learn and
share

Posts: 1202
Location: Chicago,  Illinois
Joined: Dec 16th, 2003
Re: MergeFilePrint() Questions
Reply #55 - Mar 31st, 2008 at 12:32am
Print Post Print Post  
I did a little further studies and following is my take.

RTF file studies:

http://www.biblioscape.com/rtf15_spec.htm

Following code will work and it will terminate the the mergefield color properly unlike the earlier code.

vName = "{\f1\cf6\insrsid13335651\charrsid13335651 " +  vName + "}{\f1\insrsid13335651   }"

Here in the above code cf6 represent the red color. insrsid13335651\charrsid13335651 etc. represent the font and size etc. I believe, you will have to get yours using notepad if it is to match with rest of your document.

cf6 - Red
cf2 - Blue
cf4 - Green
cf7 - Yellow
cf5 - Pink
cf12 - Violet

In the Match parameter the part of the code will be ";Name=" + vName

Where Name is the Merge field in the document.

If vSex = "M" then
        {
                 vName = "{\f1\cf2\insrsid13335651\charrsid13335651 " +  vName +    "}{\f1\insrsid13335651   }"

        }
     Else if vSex = "F" then
        {
                 vName = "{\f1\cf5\insrsid13335651\charrsid13335651 " +  vName +    "}{\f1\insrsid13335651   }"

        }

The above when merged in the document - will produce Blue colors for Boy's Name and Pink for Girl's name!!!




« Last Edit: Mar 31st, 2008 at 2:51am by Bharat_Naik »  
Back to top
 
IP Logged
 
Carl Underwood
Senior Member
Members
*****
Offline



Posts: 1350
Location: New Hampshire
Joined: Mar 11th, 2003
Re: MergeFilePrint() Questions
Reply #56 - Apr 27th, 2008 at 10:55pm
Print Post Print Post  
Quote:
I'm working on a solution. More on this later... Wink

Sorry about the long delay on this issue. I came up with a pretty good solution to the MergeFilePrint() "line-fold" problem with RTF documents. It was good enough to be an article for Inside Sesame, but it was too late to get it in the April issue. Though, I've been informed that it should appear in the May issue, which will be coming out in a few days.
  


Carl Underwood
CDU Computer Consulting LLC
Epsom, New Hampshire
Back to top
IP Logged
 
Bharat_Naik
Senior Member
Members
*****
Offline


Ever ready to learn and
share

Posts: 1202
Location: Chicago,  Illinois
Joined: Dec 16th, 2003
Re: MergeFilePrint() Questions
Reply #57 - Apr 27th, 2008 at 11:11pm
Print Post Print Post  
Thanks Carl. I am looking forward to seeing the solution. In the meanwhile, I am using MergeFilePrint() quite a lot and with good results. I have been using following function to fold and it has been working pretty good.

Function udf_MakeItFlat (vString as String) as String
//vString is Elements and varibles separated by default separator ";"
var vBlock as String
var n as Int

//Build the Block

//WriteLN (vString)

For n = 1 to @CountStringArray (vString)
     //WriteLn ("Number of Strings is " + @Str (@CountStringArray (vString)))      
     If vBlock  =  "" then
           {
                 vBlock = @AccessStringArray (vString, n)
           }
           Else
           {
                 vBlock = vBlock + @NL ( ) + @AccessStringArray (vString, n)
           }

  Next
//WriteLN ("vBlock before Removing Blank lines is " + vBlock)

// Remove blank lines
While @IN (vBlock, @NL( ) + @NL( )) > 0
     {
           vBlock = @Replace(vBlock, @NL() + @NL(), @NL() )
     }
//WriteLN ("vBlock after Removing Blank lines is " + vBlock)

// Insert RTF paragraph tags

vBlock = @Replace(vBlock, @NL(), "\par " )

//WriteLN ("vBlock after placing \par " + vBlock)

Return (vBlock)
End Function
  
Back to top
 
IP Logged