Normal Topic PrintString ( ) Page Control (Read 1305 times)
Bharat_Naik
Senior Member
Members
*****
Offline


Ever ready to learn and
share

Posts: 1202
Location: Chicago,  Illinois
Joined: Dec 16th, 2003
PrintString ( ) Page Control
May 21st, 2008 at 5:06pm
Print Post Print Post  
I have been using MergeFilePrint ( ) with rtf file.  It works good but I ran into problem with some printing job say when I have to print out 30 notes.  It has to open MS Word 30 times and close 30 times and especially with Old Windows 98 machines it takes quite long and tie up the machine.

Taking a hint from Bob Scott, I have experimented with PrintString ( ), where I do not need to preview and edit before printing. It is quick and does not depend on any outside programs.  I like it a lot. It is great for simple one page printing.  I do not mind codeing but there are some obvious snags that I think could have been avoided and made simple as regards to PrintString ( ).

One obvious one is the Page Control. Just as the text wraps in the horizontal axis by using Page Margin and @PageExtentX ( ) value, why can't the NewPage () cannot be automatically calculated using the @PageExtentY () value,  PageType and Page Margin?  If we Paste a big paragraph in any simple word processor, overflow automatically goes to next page by internal programming.

In order to control the Page, you have to place on each PrintString ( ) to see if it is going to overflow by checking  @PageExtentY ( ) value using measureonly parameter.  Let us say you can do that by creating subroutine and including with each line of code using conditional statement.

But what about a big paragraph? You have to decide either you include that on the current page or next page using measureonly parameter.  If it overflows, it goes on to the next page and current page looks half done. Is there a way to wrap the paragraph in vertical axis so the only overflows of the text goes to the next page?

What does it involve to make Next Page automatically from the value of the @PageExtentY () value that the program knows internally all the time and PageType and Margin provided in the code?

Is there a subroutine by using I can break a paragraph to have it properly distributed in the pages concerned?  Am I making sense?

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


The One & The Only

Posts: 2482
Joined: Aug 20th, 2003
Re: PrintString ( ) Page Control
Reply #1 - May 22nd, 2008 at 4:34pm
Print Post Print Post  
Bharat_Naik wrote on May 21st, 2008 at 5:06pm:
Is there a subroutine by using I can break a paragraph to have it properly distributed in the pages concerned?  Am I making sense?


The subroutine below named PrintIt does what you are asking. The first six arguments are the same as PrintString. The last two are the Y position that you want the program to stop printing at and the Y Position you want the program to start printing at on the following page, If it wraps.

Code
Select All
Subroutine MyNewPage()
	Newpage(850, 1100)
End Subroutine

Subroutine PrintIt(vData as String, vX as Int, vY as Int, vWidth as Int, vFont as String, vFontSize as Int, vYWrap as Int, vStartY as Int)
Var vChunk as String
Var vChar as Char
Var vLen as Int


	While @Len(vData) > 0
	{
		vChunk = ""
		vChar = ""
		PrintString(vData, vX, vY, vWidth, vFont, vFontSize, 1)
		vLen = @Len(vData)
		While (@PrintLastHeight() + vY) > vYWrap
		{
			If vChar <> "" Then
			{
				vChunk = vChar + vChunk
				vLen = vLen - 1
				vData = @Left(vData, vLen)
			}
			vChar = @Right(vData, 1)
			While (vChar <> @Chr(32) And vChar <> @Chr(9) And vChar <> @Chr(10) And vChar <> @Chr(13))
			{
				vChunk = vChar + vChunk
				vLen = vLen - 1
				vData = @Left(vData, vLen)
				vChar = @Right(vData, 1)
			}

			PrintString(vData, vX, vY, vWidth, vFont, vFontSize, 1)
		}
		PrintString(vData, vX, vY, vWidth, vFont, vFontSize, 0)
		vY = vStartY
		vData = vChunk
		If vData <> "" Then
		{
			FinishPage()
			MyNewPage()
		}
	}

End Subroutine 



Below is an example of code to call it.

Code
Select All
NewDocument(1)
MyNewPage()
PrintIt(Continent, 100, 900, 650, "BArial", 12, 1050, 50)
FinishPage()
FinishDocument() 



If you need help understanding any part of the above code, just let me know and I'll be happy to explain it.

-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: PrintString ( ) Page Control
Reply #2 - May 22nd, 2008 at 7:05pm
Print Post Print Post  
Thanks for the reply and solution. I have not tested it yet or even looked at it closely but I am sure it should work. I believe,  it replaces the the PrintString ( ) command where you expect the overflow. This would be a great help if it is somehow built-in in the PrintString ( ) command for multipage document printing.  Do we expect it to be incorporated in the PrintString ( ) command in a future version? or is it asking too much?
  
Back to top
 
IP Logged
 
Ray the Reaper
Global Moderator
Members
Lantica Support
*****
Offline


The One & The Only

Posts: 2482
Joined: Aug 20th, 2003
Re: PrintString ( ) Page Control
Reply #3 - May 22nd, 2008 at 7:23pm
Print Post Print Post  
Yes you would replace the call to PrintString() with a call to PrintIt() where you expect the data to wrap onto a second/third/fourth/etc. page.

I will pass it along to development that something like this is incorporated into the Printstring family of commands.

-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: PrintString ( ) Page Control
Reply #4 - May 22nd, 2008 at 7:30pm
Print Post Print Post  
Thanks Ray. Your kind help is very much appreciated.
  
Back to top
 
IP Logged