how to cancel an INPUT FROM from a serial device.

benji00

New Member
Hi,
This is driving me nuts !!
I have an RFID tag reader attached to serial com port 3 of my Windows XP pc.

At its most basic, I have following code.

input from com3.
repeat:
import lv_tag.
end.
input close.

Once I open INPUT FROM, the program will wait forever for an RFID tag read.
Is there any way to interrupt (END-KEY) the loop ?

Best Regards,
Brendan
 
leave a monkey alone and he'll solve the problem.....

will this work ?

DEFINE BUTTON stop-it LABEL "STOP".
DEFINE VARIABLE stop-sel AS LOGICAL INITIAL FALSE.

DISPLAY stop-it.

ON CHOOSE OF stop-it
stop-sel = TRUE.

ENABLE stop-it.

input from com3.
repeat:
process events.
import lv_tag.
end.
input close.
 
The INPUT FROM is not the problem.

The IMPORT is what blocks waiting for input. If there is no input then there are no events to process and there will never be an endkey etc.

IMPORT does not support a timeout so you would have to convert it to use READKEY or some other statement that supports a timeout to get such behavior (if that is what you want).
 
Code example

Code:
def var doloop as logical.
doloop = true.
def var str as char.
str = ''.
do while doloop= true:
 
  readkey pause 0. 
  if lastkey < 0 then 
    doloop = false.
  else
    str = str + chr(lastkey).
 
end.
message str.
 
Back
Top