Page 1 of 1

Sending text file to serial port - COM1

Posted: Sun Jun 01, 2008 10:47 am
by reeskej
Hi,


I've made a small application to drill some holes on a CNC machine. The output of the program is a text file. I want to transfer this file to my CNC machine by means of a serial cable. To do so, I'm using the print command

Code: Select all

        open "hoekverdraaiing_HAAS.nc" for input as #HaasNC
                open "com1:9600,n,8,1,ds0,cs0,rs" for random as #comm2Handle
                while EOF(#HaasNC)=0
            input #HaasNC, lijn$
            'print #comm2Handle, lijn$
            print lijn$
            print #main.statusbalk, lijn$
        wend

        'sluit com2 poort
        close #comm2Handle
        'sluit HAASNC file
        close #HaasNC

This is working well, except for one thing. The file contains some commas (","). During the transfer these commas are transformed in CR/LF.

How can I overcome this problem? When I'm using a dedicated transfer program, this problem does not occur.

Thanks for your input.

Posted: Sun Jun 01, 2008 11:13 am
by JanetTerra
Try using line input instead of input.
From the Help File
Description:This gets the next data line from the open file or device using handle #handle and assigns the data to var$. If no device or file exists that uses the handle named #handle, then it returns an error. The line input statement reads from the file, ignoring commas in the input stream and completing the data item only at the next carriage return or at the end of file. This is useful for reading text with embedded commas

Line input

Posted: Sun Jun 01, 2008 2:18 pm
by reeskej
Thanks Janet,

You pointed me to the right direction. It's all in the documentation. I should have used LINE INPUT instead of INPUT, because this command sees the comma as a delimiter.
Thank you for your fast reply.


Jos Reeskens