Normal Topic Question about NewDocument() (Read 568 times)
lksseven
Full Member
***
Offline



Posts: 416
Location: Southwest
Joined: Jan 26th, 2009
Question about NewDocument()
May 5th, 2009 at 5:01pm
Print Post Print Post  
In trying to refine my label code so I can print a variable number of copies before the printer cuts the label roll (the previous code used a loop, but each label was it's own print job, so the printer cut off the label off the roll after each label), I have tried the following code using NewDocument().  But it will only print 1 copy.  I've tried substituting a hard integer instead of vQty variable, and still just one label prints.  It seems that the Finishpage() is terminating the job and sending it to the printer, rendering the NewDocument(2) and FinishDocument() code unexecuted.  Any suggestions?

#Include "sbasic_include.sbas"
var vRS2 as Int
var vItemNum as String
var vItemDesc as String
var vPONum as String

var vAnswer as String
var vFinal as Int
var vQty as Int
var vAnswer2 as String


If @Mode() < 3
{
vAnswer = @PromptForUserInput("Key in the Item Number you want to print labels for", "")
vItemNum = vAnswer
     

vRS2 = @XResultSetSearch(@FN, "Inventory", SEARCH_MODE_AND, SEARCH_SYNTAX_QA, "!ItemNum=" + vItemNum)
   
If @XresultSetTotal(vRS2) = 1                        // if there is exactly one matching record in Inventory, pull data from Inventory into printstring job
   {
                                                        
    vItemDesc = @XResultSetValue(vRS2, "ItemDesc")
    vPONum = @XResultSetValue(vRS2, "CurrentPONum")
     
     vAnswer2 = @PromptForUserInput("How many labels would you like to print?", "")
     vQty = vAnswer2
    
     AlternateDefaultPrinter("wcLabel1")
     NewDocument(vQty)
       NewPage(840, 240)
            PrintPageOrientation(2)
            PrintString(vItemNum, 6, 6, 0, " ARIAL", 11, 0)
          PrintString(vItemDesc, 6, @PageExtentY(), 200, " ARIAL", 8, 0)
          PrintString("---------------", 160, 48, 0, " ARIAL", 9, 0)
            PrintString("Company 918-xxx-xxxx", 15, 54, 0, " ARIAL", 9, 0)
          PrintString("PO#" + " " + vPONum, 160, 54, 0, " ARIAL", 9, 0)
            PrintString("www.company.com", 15, 63, 0, " Arial", 8, 0)
     FinishPage()
       FinishDocument()

       RestoreDefaultPrinter()
     }

    If @XresultSetTotal(vRS2) < 1
        {
         @Msgbox("This Item # does not exist.  Reenter the number","","")
          }
 
  XResultSetClose(vRS2)
     
}
  

Larry
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: Question about NewDocument()
Reply #1 - May 8th, 2009 at 1:12pm
Print Post Print Post  
Try something like

Code
Select All
vLoop = 1

NewDocument(1)
	 While vLoop <= vQty
	 {
		  NewPage(840, 240)
			 PrintPageOrientation(2)
			 PrintString(vItemNum, 6, 6, 0, " ARIAL", 11, 0)
			 PrintString(vItemDesc, 6, @PageExtentY(), 200, " ARIAL", 8, 0)
			 PrintString("---------------", 160, 48, 0, " ARIAL", 9, 0)
			 PrintString("Company 918-xxx-xxxx", 15, 54, 0, " ARIAL", 9, 0)
			 PrintString("PO#" + " " + vPONum, 160, 54, 0, " ARIAL", 9, 0)
			 PrintString("www.company.com", 15, 63, 0, " Arial", 8, 0)
		  FinishPage()
		  vLoop = vLoop + 1
	 }
FinishDocument()
 



You'll need to declare vLoop as an int

-Ray
  

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



Posts: 416
Location: Southwest
Joined: Jan 26th, 2009
Re: Question about NewDocument()
Reply #2 - May 8th, 2009 at 5:15pm
Print Post Print Post  
Thank you, Ray.   I'll test it when I get to the office

Update:

Ray, no joy.  The label printer still cuts off each label. 

The printer will stream print a specified number of labels if I use Brother's label editor software, so the label printer is capable of withholding its 'cut' until the end of the print job with its own software.

It's not the end of the world for me (any single print run of labels will normally be somewhere between 1 and 7) if I can't figure a work around on individual label cuts.   Although if my needs required a print run of 50 identical labels, then individual cuts would be problematic, so I'd like to find a solution for future reference (for myself or possibly other Sesame users).

Here is the relevant section of code I used:

     vQty = vAnswer2
    
        AlternateDefaultPrinter("wcLabel1")
         vLoop = 1
         NewDocument(1)
             While vLoop <= vQty
              {
                NewPage(840, 240)
                  PrintPageOrientation(2)
                  PrintString(vItemNum, 6, 6, 0, " ARIAL", 11, 0)
                PrintString(vItemDesc, 6, @PageExtentY(), 200, " ARIAL", 8, 0)
                PrintString("---------------", 160, 48, 0, " ARIAL", 9, 0)
                  PrintString("Company xxx-xxx-xxxx", 15, 54, 0, " ARIAL", 9, 0)
                PrintString("PO#" + " " + vPONum, 160, 54, 0, " ARIAL", 9, 0)
                  PrintString("www.company.com", 15, 63, 0, " Arial", 8, 0)
              FinishPage()
                vLoop = vLoop + 1
              }
           FinishDocument()
        RestoreDefaultPrinter()
« Last Edit: May 8th, 2009 at 6:48pm by lksseven »  

Larry
Back to top
IP Logged