Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Error when inputting ASCII text from COM port
#11
I put in a few test statements so I can 'try' to figure out what is going on. It 'appears' that right off the bat, before I enter anything, it pops right out and displays a blank for the KILLFILE$ variable. If I change the test for Chr$(13) to be not equal instead of greater than, I see the screen fill up with the ASCII code it 'thinks' is being input. And then it still shows a File Not Found error because the KILLFILE$ is either empty or garbage.

But, after looking at all the suggestions you all provided, a little light bulb started to glow and I found something interesting about the results I was getting. I was thinking, why not just test for a CR right away, and if not one, then see if the data is a character that you would expect to find in a filename. So I came up with this, and it works!

'------------------------------------------------------------------------------
DEL1: 'Request file deletion COM5
Close #1
Open "COM5:9600,N,8,1,RS0,CS0,DS0,CD0" For Random As #1
KILLFILE$ = ""
BYTELOOP:
    If Loc(1) <> 0 Then Get #1, , byte
    If Asc(byte) = 13 GoTo DELFILE
    If Asc(byte) < 46 Or Asc(byte) > 90 GoTo BYTELOOP
    KILLFILE$ = KILLFILE$ + byte
GoTo BYTELOOP
DELFILE:
KILL1$ = "E:\SERVER\CPM\" + KILLFILE$
Kill KILL1$
Put #1, , EOT$
STATLINE$ = Date$ + " - " + Time$ + " - COM5 File Delete Request " + KILLFILE$
GoSub EVENTSAVE
GoSub PRINTSTAT
Return
'------------------------------------------------------------------------------
Reply
#12
Great!

If you want to get rid of the Goto's you can replace your BYTELOOP with:

Code: (Select All)
Do
  If Loc(1) <> 0 Then Get #1, , byte
  If Asc(byte) = 13 Then Exit Do
  If Asc(byte) >= 46 And Asc(byte) <= 90 Then KILLFILE$ = KILLFILE$ + byte
Loop
45y and 2M lines of MBASIC>BASICA>QBASIC>QBX>QB64 experience
Reply




Users browsing this thread: 1 Guest(s)