Announcement

Collapse
No announcement yet.

writing to a com port

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • writing to a com port

    I have PB DOS 3.2. I'm trying to write to com2. Can someone
    please te,, me how to send data to com2. Below is what I have
    been trying so far.

    OPEN "COM2:9600,E,8,1" for OUTPUT AS #1

    REM PRINT ZPL CODE FOR A LABEL TO ZEBRA PRINTER ON COM2

    PRINT #1,"^XA^A100,100"
    PRINT#1,"^FT670,150^A0N,100,100^FWR^FD";OK.PART$;"^FS" REM PRINTS ON ANGLE
    PRINT#1,"^FO690,100^B3R,N,80,Y,N^FD22ITB1111111^FS"
    PRINT#1,"^FO590,100^B3R,N,80,Y,N^FD22ITB2222222^FS"
    PRINT#1,"^FO490,100^B3R,N,80,Y,N^FD22ITB3333333^FS"
    PRINT#1,"^FO390,100^B3R,N,80,Y,N^FD22ITB4444444^FS"
    PRINT#1,"^FO290,100^B3R,N,80,Y,N^FD22ITB5555555^FS"
    PRINT#1,"^A25,25"
    PRINT#1,"^FO95,450^B3R,N,80,Y,N^FD738168008988^FS"
    PRINT#1,"^xz"
    CLOSE #1


    ------------------

  • #2
    Originally posted by Lamon Ford:
    I have PB DOS 3.2. I'm trying to write to com2. Can someone
    please te,, me how to send data to com2. Below is what I have
    been trying so far.
    Looks ok, but why not try something like this

    Code:
    Sub CommPrint(TxtOut As String)
     
       Dim hFile As Word
    
       hFile = FreeFile
     
       Open "COM2:9600,N,8,1" For Random As hFile Len=1024
       Print #hFile, TxtOut;
       Close hFile
      
    End Sub
    Then you could just simply call CommPrint MyString$ anytime you wanted
    to send data to your printer.



    ------------------
    Scott Slater
    Summit Computer Networks
    www.summitcn.com
    Scott Slater
    Summit Computer Networks, Inc.
    www.summitcn.com

    Comment


    • #3
      Lamon, you hint at there being a problem with your code... can you be more precise? Does the data get scrambled, or are there run-time errors occurring?

      Are you also using $ERROR ALL ON in your code?

      Thanks!

      ------------------
      Lance
      PowerBASIC Support
      mailto:[email protected][email protected]</A>
      Lance
      mailto:[email protected]

      Comment


      • #4
        Lamon:

        I've got several Zebras that are programed using VB5.
        I've not tried to use PB, but if you are still having problems,
        reply to this and I'll see about testing with PB.
        (The semicolons look a little fishy.)

        Ed Stapleton

        ------------------

        Comment

        Working...
        X