Page Index Toggle Pages: 1 [2] 3 4  Send Topic Send Topic Print Print
Very Hot Topic (More than 25 Replies) MergeFilePrint() Questions (Read 10103 times)
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
 
Page Index Toggle Pages: 1 [2] 3 4 
Send Topic Send Topic Print Print