title: Agrox Cp-2140 Printer PPLB Command
body: <p>i am using Agrox CP-2140 Printer in VFP 
  i want to use printer direct command , using dll files , my above printing label correctly but before print label it's living 1st label  blank .</p>
  
  <p>if i print continuously 3 label its live blank label before every label</p>
  
  <p>pl.check my above code what i am missing</p>
  
  <pre><code>CREATE CURSOR pmkbarcode ( cBarCode c(10),nRs n(6,2))
  INSERT INTO pmkBarCode (cBarCode,nRs)  values("123456789",450.20)
  INSERT INTO pmkBarCode (cBarCode,nRs) values("789123844",25.30)
  INSERT INTO pmkBarCode (cBarCode,nRs) values("859234567",10.55)
  
  #DEFINE vpCrLf CHR(13)+CHR(10)
  
  DECLARE  string B_Get_DLL_Version in WINPPLB.DLL integer nShowMessage
  DECLARE integer B_GetUSBDeviceInfo in WINPPLB.DLL integer nPort, string @pDeviceName, ;
          integer @pDeviceNameLen, string @pDevicePath, integer @pDevicePathLen
  DECLARE integer B_CreatePrn in WINPPLB.DLL integer selection, string filename
  DECLARE integer B_CreateUSBPort in WINPPLB.DLL integer nPort
  
  DECLARE integer B_GetUSBBufferLen in WINPPLB.DLL
  DECLARE integer B_EnumUSB in WINPPLB.DLL string @buf
  DECLARE integer B_Set_Originpoint in WINPPLB.DLL integer hor, integer ver
  DECLARE integer B_Select_Option in WINPPLB.DLL integer option
  DECLARE integer B_Set_Darkness in WINPPLB.DLL integer darkness
  DECLARE integer B_Set_Labgap in WINPPLB.DLL integer lablength, integer gaplength
  DECLARE integer B_Set_Labwidth in WINPPLB.DLL integer labwidth
  DECLARE integer B_Prn_Barcode in WINPPLB.DLL integer x, integer y, integer ori, string type_Renamed, ;
          integer narrow, integer width_Renamed, integer height_Renamed, short human, ;
          string data_Renamed
  DECLARE integer B_Prn_Text in WINPPLB.DLL integer x, integer y, integer ori, integer font_Renamed, ;
          integer hor_factor, integer ver_factor, short mode, string data_Renamed
  DECLARE integer B_Print_Out in WINPPLB.DLL integer labset
  DECLARE B_ClosePrn in WINPPLB.DLL
  Declare B_Prn_Configuration IN "WINPPLB.DLL"
  DECLARE integer B_Set_Backfeed in WINPPLB.DLL short option
  DECLARE integer B_Get_Pcx in "WINPPLB.DLL" integer, integer, string
  DECLARE integer B_CreatePrn in "WINPPLB.DLL" integer, string
  
  &amp;&amp; get total usb port to find out printer installed or not
  &amp;&amp; and finding printer for print
  
  &amp;&amp; open port.
  PRIVATE nLen, ret, sw
  PRIVATE pbuf, ver, strmsg
  pbuf = Space(128)
  
  &amp;&amp; dll version.
  ver = B_Get_DLL_Version(0)
  
  &amp;&amp; search port.
  nLen = B_GetUSBBufferLen() + 1
  
  strmsg = "DLL " + ver + vpCrLf   &amp;&amp; only sample coding, not smart.
  If nLen &gt; 1
      PRIVATE buf1, buf2
      PRIVATE len1, len2
      len1 = 128
      len2 = 128
      buf1 = Space(len1)
      buf2 = Space(len2)
      B_EnumUSB(@pbuf)
      B_GetUSBDeviceInfo(1, @buf1, @len1, @buf2, @len2)
      sw = 1
      If 1 == sw
         ret = B_CreatePrn(12, buf2)   &amp;&amp; open usb.
      Else
         ret = B_CreateUSBPort(1)   &amp;&amp; must call B_GetUSBBufferLen() function fisrt.
      EndIf    
      If 0 &lt; ret
          strmsg = strmsg + "Open USB fail!"
      Else
          strmsg = strmsg + "Open USB:" + vpCrLf + "Device name: "
          strmsg = strmsg + Left(buf1, len1)
          strmsg = strmsg + vpCrLf + "Device path: "
          strmsg = strmsg + Left(buf2, len2)
          &amp;&amp; sw = 2
          If 2 == sw
            &amp;&amp; Immediate Error Report.
            pbuf = "^ee\r\n"
            B_WriteData(1, pbuf, 5)   &amp;&amp; ^ee
            ret = B_ReadData(@pbuf, 4, 1000)
          EndIf
      EndIf
  ELSE
      MessageBox("Printer Not Ready",0,"by Prasanna")
      CreateDirectory(szSavePath, null)
      ret = B_CreatePrn(0, szSaveFile)   &amp;&amp; open file.
      strmsg = strmsg + "Open " + szSaveFile
      If 0 &lt; ret
          strmsg = strmsg + " file fail!"
      Else
          strmsg = strmsg + " file succeed!"
      EndIf
  EndIf
  MessageBox(strmsg,0,"by Prasanna")
  If 0 &lt; ret
      Return
  ENDIF
  
  ?B_Set_Originpoint(0, 0) &amp;&amp; Horizontal margin, Vertical margin measured in dots.
  ?B_Select_Option(2) &amp;&amp; direct thermal, disable Cutter and Peel.
  ?B_Set_Darkness(8) &amp;&amp; Setup the "darkness" function (heating level).
                    &amp;&amp; Acceptable values from 0 to 15.The default darkness value is 8.
  B_Set_Backfeed(ASC('F')) &amp;&amp; Tear off so user can see last printed label       
  
      B_Set_Labgap(0117,025) &amp;&amp; - perfect size don't change
      B_Set_Labwidth(1250) &amp;&amp;- perfect size don't change
  
  SELECT pmkBarCode 
  GOTO TOP 
  DO WHILE !EOF()
  &amp;&amp;E80,1
  
      B_Prn_Barcode(280, 120, 0,"1",2, 2, 75, 66,cBarCode)
      B_Prn_Text   (280, 230, 0, 2, 1, 1, ASC("N"), "1st Beauty Friend")
      B_Prn_Text   (520, 247,  3, 1, 2, 1, ASC("N"), "MRP."+alltrim(str(nRs,10,2)))
      B_Print_Out(1)   &amp;&amp; copy 2.
  
      SELECT pmkBarCode 
      SKIP 
  ENDDO 
  
  
  B_ClosePrn()
  </code></pre>