Hot Topic (More than 10 Replies) [Solved] User is printing faster than Sesame (Read 2629 times)
Infinity
Senior Member
Members
*****
Offline


Diagonally parked in a
parallel dimension

Posts: 1290
Location: Massachusetts
Joined: May 27th, 2005
[Solved] User is printing faster than Sesame
Oct 9th, 2007 at 11:11am
Print Post Print Post  
Solution: Have print button offer to print all the records. See code later in thread.

I don't know how to title this question, so if a forum Moderator can think of a better title, please change it.

Here's what's happening:

On my Invoice form I have a button which sends data to a pre-printed form, via a whole bunch of Printstring commands.  It works fine when I use it (except for frequently mangled printouts, which is a different issue....Ray and Ben, did my email of Oct. 1 reach you?)  My Accounts Receivable user is a different story.

She will stack invoice numbers in a retrieve spec, such as "23456;23457;23458" and so on.  Once the stack has been retrieved she will hit the Print button, then use the "advance to next record" arrow in the bar on the menu bar, hit the button, hit the arrow, button, arrow, and so on.  And then she comes to me to complain that some of the invoices have printed twice, and some not at all.

I was able to duplicate this result this morning, and I think it has to do with advancing the record before the full print routine code has shot the result to the printer.  That is, she's advancing to the next record too quickly.  I mentioned this as a possibility last Friday and she whined "but I shouldn't have to wait".

Sigh.

Is there a way to force the program to wait?  I mean, can I program it so that advancing to the next record is impossible until the full output has been sent to the printer?  Or maybe some kind of progress bar?  It wouldn't have to be very long, just a matter of five seconds or so.
« Last Edit: Oct 9th, 2007 at 4:15pm by Hammer »  

**
Captain Infinity
Back to top
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: User is printing faster than Sesame
Reply #1 - Oct 9th, 2007 at 12:29pm
Print Post Print Post  
Why don't you have your program offer to print her whole batch so she doesn't have to do this at all?
  

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


Diagonally parked in a
parallel dimension

Posts: 1290
Location: Massachusetts
Joined: May 27th, 2005
Re: User is printing faster than Sesame
Reply #2 - Oct 9th, 2007 at 1:17pm
Print Post Print Post  
Quote:
Why don't you have your program offer to print her whole batch so she doesn't have to do this at all?

I don't know how to do that, sorry.
  

**
Captain Infinity
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: User is printing faster than Sesame
Reply #3 - Oct 9th, 2007 at 2:10pm
Print Post Print Post  
Hello Scott,

Yes we did recieve your e-mail, and I just got a line on a dot matrix printer that I'm going to go borrow tonight and have Ben set up tomorrow morning.

Sesame naturally waits for Sbasic to finish before it does anything else. I just tested it here with over 400,000 Printstring lines(I'm still waiting for the document to actually print, It was sent to the printer over 15 minutes ago. It's only 42 Megs) and I could not get Sesame to advance to the next record no matter what I clicked or what keys I hit, until the code had finished running. I'll try later with your app but my gut says that your Accounts Receivable user is mis-clicking. Do any of the printed invoices have mixed data on them, i.e. Top half from one record and bottom half from another?

-Ray
  

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


Diagonally parked in a
parallel dimension

Posts: 1290
Location: Massachusetts
Joined: May 27th, 2005
Re: User is printing faster than Sesame
Reply #4 - Oct 9th, 2007 at 2:42pm
Print Post Print Post  
Quote:
I could not get Sesame to advance to the next record no matter what I clicked or what keys I hit, until the code had finished running. I'll try later with your app but my gut says that your Accounts Receivable user is mis-clicking.

Well, it happened for her again just a few minutes ago.  She stacked 2 Invoices.  Then she hit print, advance, print.  Two copies of the second Invoice printed.  The first did not print.
Quote:
Do any of the printed invoices have mixed data on them, i.e. Top half from one record and bottom half from another?

In the run that happened a few minutes ago, both are exact dupes and match what is saved in the database, no mixing with the one that didn't print.

I've told her to slow down, to wait for the printer to start printing before advancing.
  

**
Captain Infinity
Back to top
IP Logged
 
Infinity
Senior Member
Members
*****
Offline


Diagonally parked in a
parallel dimension

Posts: 1290
Location: Massachusetts
Joined: May 27th, 2005
Re: User is printing faster than Sesame
Reply #5 - Oct 9th, 2007 at 2:46pm
Print Post Print Post  
Quote:
Yes we did recieve your e-mail, and I just got a line on a dot matrix printer that I'm going to go borrow tonight and have Ben set up tomorrow morning.

Maybe I should ship my printer to you.    Undecided
  

**
Captain Infinity
Back to top
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: User is printing faster than Sesame
Reply #6 - Oct 9th, 2007 at 2:59pm
Print Post Print Post  
Infinity wrote on Oct 9th, 2007 at 1:17pm:
Quote:
Why don't you have your program offer to print her whole batch so she doesn't have to do this at all?

I don't know how to do that, sorry.

Would you like to know?  Smiley
  

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


Diagonally parked in a
parallel dimension

Posts: 1290
Location: Massachusetts
Joined: May 27th, 2005
Re: User is printing faster than Sesame
Reply #7 - Oct 9th, 2007 at 3:07pm
Print Post Print Post  
Quote:
Would you like to know?

You bet!
  

**
Captain Infinity
Back to top
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: User is printing faster than Sesame
Reply #8 - Oct 9th, 2007 at 3:32pm
Print Post Print Post  
Infinity wrote on Oct 9th, 2007 at 3:07pm:
Quote:
Would you like to know?

You bet!


Code
Select All
var vChoice as String
var vPos as Int
var vLoop as Int
var vCount as Int

SUBROUTINE PrintStuff()

	NewPage(850, 1100)
	PrintString("A Value to Print", 100, 200, 0, "BArial", 33, 0)
	FinishPage()

END SUBROUTINE


	vChoice = @PopupChoiceList("This Record;All Retreived Records", "SELECT RECORDS TO PRINT")
	If vChoice = "This Record"
	{
		PrintStuff()
	}
	Else If vChoice = "All Retreived Records"
	{
		vPos = @ResultSetCurrentPosition()	// Remember the starting point
		vCount = @ResultSetTotal()		// Get how many records we have
		For vLoop = 1 To vCount			// Print each record
			ResultSetCurrentPosition(vLoop)
			PrintStuff()
		Next
		ResultSetCurrentPosition(vPos)		// Return to starting point
	}


 

  

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


Diagonally parked in a
parallel dimension

Posts: 1290
Location: Massachusetts
Joined: May 27th, 2005
Re: User is printing faster than Sesame
Reply #9 - Oct 9th, 2007 at 4:12pm
Print Post Print Post  
Thanks Erika!  I modified it a bit with an @AskUser(), just in case some accidentally retrieved all 32,648 Invoices:
Code
Select All
var vChoice as String
var vResultSetPosition as Int   // changed from vPos because my print routine uses that elsewhere
var vLoop as Int
var vCount as Int
Var vTotalString as String

//  Allows user to print the record showing or all retrieved records

vChoice = @PopupChoiceList("This Record;All Retrieved Records", "SELECT RECORDS TO PRINT")
If vChoice = "This Record"
	{
	PrintStuff()
	}
Else If vChoice = "All Retrieved Records"
{

// Ask the user if the current result set is what he wants

vTotalString = @STR(@ResultSetTotal()) + " Miara Invoices."

IF @AskUser("This will print", vTotalString, "Are you sure you want to do this?")
THEN
	{
	vResultSetPosition = @ResultSetCurrentPosition()	// Remember the starting point
	vCount = @ResultSetTotal()		// Get how many records we have
	For vLoop = 1 To vCount			// Print each record
		ResultSetCurrentPosition(vLoop)
		PrintStuff()
	Next
	ResultSetCurrentPosition(vResultSetPosition)		// Return to starting point
	}
} 



Thanks again for your help, I think this will solve the mystery of the duplicate printouts!
  

**
Captain Infinity
Back to top
IP Logged
 
Alec
Lanticans
*****
Offline



Posts: 200
Location: Ascot, England, UK
Joined: Nov 22nd, 2002
Re: User is printing faster than Sesame
Reply #10 - Oct 9th, 2007 at 5:57pm
Print Post Print Post  
Infinity wrote on Oct 9th, 2007 at 4:12pm:
 I modified it a bit with an @AskUser(), just in case some accidentally retrieved all 32,648 Invoices:

I'd go one further. I would prevent them printing more than a reasonable number of invoices, say 50 or 100. If you don't, then inevitably someone will ignore the warning and tie up Sesame for everyone for [a period of time], and cause all sorts of problems. I'd have 3 tiers (my figures just as examples) ..

1-10 records - no warning, just print them
11-50 records - Are you sure?
51+ - no can do.

If they really need to print more than the maximum, they can do so in batches.
  

Alec
Back to top
IP Logged
 
Infinity
Senior Member
Members
*****
Offline


Diagonally parked in a
parallel dimension

Posts: 1290
Location: Massachusetts
Joined: May 27th, 2005
Re: [Solved] User is printing faster than Sesame
Reply #11 - Oct 9th, 2007 at 6:24pm
Print Post Print Post  
Another great idea from Alec, who has the uncanny ability to see into the future and must, somehow, have had experience with the users at J.A. Miara Transportation, Inc.

Thanks!
  

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



Posts: 1351
Location: New Hampshire
Joined: Mar 11th, 2003
Re: User is printing faster than Sesame
Reply #12 - Oct 10th, 2007 at 12:48am
Print Post Print Post  
Alec wrote on Oct 9th, 2007 at 5:57pm:
1-10 records - no warning, just print them
11-50 records - Are you sure?
51+ - no can do.

Alec,

What a terrific twist.

I really like your idea not to bother the user for small batches, and to all-out restrict an almost obvious mistake of printing a very large batch.
  


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


Diagonally parked in a
parallel dimension

Posts: 1290
Location: Massachusetts
Joined: May 27th, 2005
Re: [Solved] User is printing faster than Sesame
Reply #13 - Oct 10th, 2007 at 10:51am
Print Post Print Post  
Here's the code I came up with.  It looks clunky but it works.  I set my breaks at:
10 or less, no questions
11 to 20, ask
> 20, no can do.
Code
Select All
var vChoice as String
var vResultSetPosition as Int
var vLoop as Int
var vCount as Int

SUBROUTINE PrintStuff()
NewPage(850, 1100)
[My Invoice print routine]
FinishPage()
END SUBROUTINE


SUBROUTINE PrintResultSet()
var vResultSetPosition as Int
var vLoop as Int
var vCount as Int
vResultSetPosition = @ResultSetCurrentPosition()	// Remember the starting point
vCount = @ResultSetTotal()		// Get how many records we have
For vLoop = 1 To vCount			// Print each record
	ResultSetCurrentPosition(vLoop)
	PrintStuff()
Next
ResultSetCurrentPosition(vResultSetPosition)		// Return to starting point
END SUBROUTINE



//  Allows user to print the record showing or all retrieved records if less than 21 retrieved.

vChoice = @PopupChoiceList("This Record;All Retrieved Records", "SELECT RECORDS TO PRINT")
IF vChoice = "This Record"
	{
	PrintStuff()
	}
ELSE IF vChoice = "All Retrieved Records"
IF NOT @ResultSetTotal() > 20
THEN
	IF @ResultSetTotal() < 11
	THEN PrintResultSet()
	ELSE
	{
	vTotalString = @STR(@ResultSetTotal()) + " Miara Invoices."
	IF @AskUser("This will print", vTotalString, "Are you sure you want to do this?")  // Ask the user if the current result set is what he wants
	THEN PrintResultSet()
	} 



I got an error message about the PrintResultSet() subroutine's variables until I moved them into the actual subroutine: "Loop invariants (FOR-NEXT-counter) must be simple local variables".  I'm curious about that, don't know exactly what it means but moving them worked.

Thanks again for everyone's help; this is a wonderful solution to my original problem and goes far beyond what I originally had in mind.  And it's sure to make my A/R user very happy.  Smiley
  

**
Captain Infinity
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: [Solved] User is printing faster than Sesame
Reply #14 - Oct 10th, 2007 at 1:14pm
Print Post Print Post  
Hello Scott,

Since you moved the declarations for vLoop and vCount into the Subroutine, you will probably want to remove the originals so that you don't confuse yourself.

Also you may want to include a message that tells your users that they can not print more than 20 invoices at a time incase they try to print 21. This way you save yourself the "IT'S NOT WORKING" message from your users.

-Ray
  

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


Diagonally parked in a
parallel dimension

Posts: 1290
Location: Massachusetts
Joined: May 27th, 2005
Re: [Solved] User is printing faster than Sesame
Reply #15 - Oct 10th, 2007 at 5:20pm
Print Post Print Post  
Quote:
Since you moved the declarations for vLoop and vCount into the Subroutine, you will probably want to remove the originals so that you don't confuse yourself. 

Yup, did that, direct transplant.
Quote:
Also you may want to include a message that tells your users that they can not print more than 20 invoices at a time incase they try to print 21. This way you save yourself the "IT'S NOT WORKING" message from your users. 

Probably.  But with this situation, unlike a real problem, I know in advance why it's not working.  So, forearmed and smug with self-confidence, I can easily maintain my status as a miracle worker.  HELLO, COMPUTER!!  WHIP ME UP SOME TRANSPARENT ALUMINUM!!  THERE BE WHALES HERE!!!

(Yes, I have Star Trek on my mind today.  About an hour ago I bought a ticket to the November 19 theatrical showing of the remastered "The Menagerie".  I've never seen Trek on the big screen, it should be a hoot.)

P.S. There's only 1 user who would ever be printing a "batch" of Invoices, and I've already told her about the limits, so there will be no surprises.
  

**
Captain Infinity
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: [Solved] User is printing faster than Sesame
Reply #16 - Oct 10th, 2007 at 6:33pm
Print Post Print Post  
Infinity wrote on Oct 10th, 2007 at 5:20pm:
Quote:
Since you moved the declarations for vLoop and vCount into the Subroutine, you will probably want to remove the originals so that you don't confuse yourself. 

Yup, did that, direct transplant.


They still exist in the code that you had posted up above, which is why I was not sure.

-Ray
  

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


Diagonally parked in a
parallel dimension

Posts: 1290
Location: Massachusetts
Joined: May 27th, 2005
Re: [Solved] User is printing faster than Sesame
Reply #17 - Oct 10th, 2007 at 7:04pm
Print Post Print Post  
Yeah, sorry, I Frankensteined that together for my post.
  

**
Captain Infinity
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: User is printing faster than Sesame
Reply #18 - Oct 12th, 2007 at 6:05pm
Print Post Print Post  
Infinity wrote on Oct 9th, 2007 at 2:46pm:
Maybe I should ship my printer to you.    Undecided


Well Scott after a very tiring search we just found your printing problem and It has nothing to do with the printer.

In Global Code you have a subroutine named ChecKItemLength. In that subroutine is the problem. You are calling PrintString without calling NewPage() and CancelPage(). PrintString as documented on Page 309 of the Sesame 2.0 Programming Guide will call NewPage(), if a Print Page does not already exist and set the width as 750 and the height as 1000.

Now you may be wondering what that has to do with your printing of invoices. It's simple. If a Print Page already exists a new one is not created when NewPage() is called. So your invoices are being printed using a grid of 750 by 1000 after that subroutine is run and a grid of 850, 1100 before that subroutine is run. Which results in I believe a 12% shift on the X and a 9% shift on the Y, which results in the skewed results that you were getting. And it would only happen after leaving certain elements which results in your "Random" problem.

So what you are going to want to do is in the ChecKItemLength subroutine add a NewPage(850, 1100) call before the PrintString call and a CancelPage() call at the end of the subroutine. Also check for other places where you may be doing the same thing, as I've seen a few.

-Ray
  

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


Diagonally parked in a
parallel dimension

Posts: 1290
Location: Massachusetts
Joined: May 27th, 2005
Re: [Solved] User is printing faster than Sesame
Reply #19 - Oct 13th, 2007 at 3:45pm
Print Post Print Post  
Ray, if you were here, or I were there, I would kiss you.  Seriously.  I would grab you in a bear hug and plant one right on you, and Ben too.  I can't begin to thank you enough for all the work you did to solve this problem.  I have never, ever in my life, encountered such willing and able customer support for any software or hardware device I have ever used.  You folks are amazing.

I apologize for the sloppy coding and lack of research to do it correctly to begin with.  I'm not sure where I got the base code for the routine to check item length but I really should have read more about the process before instituting it.  I'm sorry to have been such a pain but I am overwhelmingly grateful that you put up with me and my problem through all this.  THANK YOU!!
  

**
Captain Infinity
Back to top
IP Logged
 
Bob_Hansen
Senior Member
Members
*****
Offline


WOW, They have the Internet
on computers now!

Posts: 1861
Location: Salem, NH
Joined: Nov 24th, 2002
Re: [Solved] User is printing faster than Sesame
Reply #20 - Oct 13th, 2007 at 5:14pm
Print Post Print Post  
Now THERE's a testmonial for the next release! Grin
  



Bob Hansen
Sesame Database Manager Professional
Sensible Solutions Inc.
Salem, NH
603-898-8223
Skype ID = sensiblesolutions
Back to top
IP Logged
 
Ben
Lantica Support
*****
Offline



Posts: 218
Joined: Apr 7th, 2005
Re: [Solved] User is printing faster than Sesame
Reply #21 - Oct 15th, 2007 at 1:24pm
Print Post Print Post  
Infinity wrote on Oct 13th, 2007 at 3:45pm:
THANK YOU!!

You're welcome.
  
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: [Solved] User is printing faster than Sesame
Reply #22 - Oct 15th, 2007 at 8:20pm
Print Post Print Post  
Infinity wrote on Oct 13th, 2007 at 3:45pm:
Ray, if you were here, or I were there, I would kiss you.....


I'll pass on the kiss Scott, but I will take the Thank You and say that you are Welcome.

-Ray
  

Raymond Yoxall Consulting
ray.yoxall@gmail.com
ryoxall@lantica.com
Sesame Applications, Design and Support
Back to top
IP Logged