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