WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Serial
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Can I do a FileCopy to a Port that is Open?

Keywords:     pTimeout  pComClose

Question:

I have run into a little puzzle I need some help on ...

One of my customers needs a little app that:

  • Dials up a remote server - no logon required
  • dumps a batch of ASCII text files to the remote - the remote can only do ASCII
  • logs off

I have the SERIAL EXTENDER, and have used one of the sample routines to do the dialup and connect. because I can't use pSendFile, I tried to use

   FileCopy("*.txt", %MyModemIsOn%, @FALSE)     
and get "3052: Uninitialized Variable or undefined function".

Any suggestions?

My first four lines of code define modem port, speed, etc.

        AddExtender("wwser34I.dll")
        MyModemIsOn="COM1"
        HostPhone="784-0000"
        port=pComOpen(MyModemIsOn,0,9600,"8N1","NONNON")
I think the problem actually results from trying to FileCopy to a port that is open with a live modem connection. I have used a similar approach to moving data over a direct-connect null-modem cable with no problem. It goes like this:
        AddExtender("wwser34I.dll")
        MyPortIs="COM1"
        port=pComOpen(MyPortIs,0,9600,"8N1","NONNON")
        pTimeout(port,2000)
        pComClose(port,0)
        FileCopy("*.txt", MyPortIs, @FALSE)
The host I have to hit (an AP NewsCenter Data Server) is not capable of dealing with anything but ASCII protocol.

Answer:

Don't use FileCopy.

Try this (undebugged) script:


        AddExtender("wwser34I.dll")
        MyPortIs="COM1"
        port=pComOpen(MyPortIs,0,9600,"8N1","NONNON")

        filelist=FileItemize("*.txt")
        filecount=ItemCount(filelist,@tab)

        for xx=1 to filecount
            thisfile=ItemExtract(xx,filelist,@tab)
            thissize=FileSize(thisfile)
            thisbb=BinaryAlloc(thissize)
            BinaryRead(thisbb,thisfile)
            thisbinaddr=IntControl(42,thisbb,0,0,0)
           
            ; The magic
            pPutBinary(port,thisbinaddr,thissize)

            BinaryFree(thisbb)
            FileDelete(thisfile)
        next

        pComClose(port,0)

Article ID:   W12566
Filename:   Can you do a FileCopy to an Active Port.txt
File Created: 2001:03:01:15:24:50
Last Updated: 2001:03:01:15:24:50