mpj@sequoia.cray.com (M. P. Johnson) (06/28/91)
Hi there, Some BASICs include a timeout option for the INP(#n) function which polls for a byte on an input port. For example, the Sinclair QL had A=INP(#1,5) which meant "if you get no input from the port #1 within 5 seconds, return zero and continue". Some BASICs use SNS(#n) which returns immediately (with 0 if no input was present) so that the program can continue. Does anyone know if GFA Basic will allow this ? Apparently not; so far my programs hang on the INP if there is no more input. I'd like to unblock the situation without manual intervention! I am hoping there is some darker way of checking for data in the input buffer for the port. Thanks, Marvin.
wernst@sdcc13.ucsd.edu (WarDoggie woof woof..) (06/28/91)
In article <035236.9564@timbuk.cray.com> mpj@sequoia.cray.com (M. P. Johnson) writes: > >Does anyone know if GFA Basic will allow [timeouts]? Apparently not; >so far my programs hang on the INP if there is no more input. Check if there's anything waiting for you with INP?(#channel). It'll return a TRUE if there is, a FALSE if there ain't. If you want to time input, say with a FOR loop: FUNCTION get_input FOR i%=1 TO 1000 IF INP?(#1)=TRUE THEN RETURN INP(#1) ENDIF NEXT i% RETURN 0 ! Or whatever ENDFUNC (I assume you're using GFA 3.x, too. I don't know about 2.x...) -- Greg Knauss, on a friend's account...
steve@thelake.mn.org (Steve Yelvington) (06/29/91)
[In article <21046@sdcc6.ucsd.edu>, wernst@sdcc13.ucsd.edu (WarDoggie woof woof..) writes ... ] > In article <035236.9564@timbuk.cray.com> mpj@sequoia.cray.com (M. P. Johnson) writes: >> >>Does anyone know if GFA Basic will allow [timeouts]? Apparently not; >>so far my programs hang on the INP if there is no more input. > > Check if there's anything waiting for you with INP?(#channel). > It'll return a TRUE if there is, a FALSE if there ain't. If you > want to time input, say with a FOR loop: > > FUNCTION get_input > FOR i%=1 TO 1000 > IF INP?(#1)=TRUE THEN > RETURN INP(#1) > ENDIF > NEXT i% > RETURN 0 ! Or whatever > ENDFUNC Using a counted loop as a timer is not a good idea in this day of multiple processors and speeds. Better to check the value of a system clock, so that the program will not behave in a strange fashion when executed on a Mega STE or TT030. ---- Steve Yelvington <steve@thelake.mn.org> If mail fails, try steve%thelake@cs.umn.edu ... the Minnesota domain MX site jhereg.osa.com apparently has been having difficulties.
logajan@ns.network.com (John Logajan) (06/30/91)
mpj@sequoia.cray.com (M. P. Johnson) writes: >Does anyone know if GFA Basic will allow this ? Apparently not; >so far my programs hang on the INP if there is no more input. >I'd like to unblock the situation without manual intervention! >I am hoping there is some darker way of checking for data in the >input buffer for the port. Use the INP?(x) command before each INP(x) command to see if a character is available. -- - John Logajan @ Network Systems; 7600 Boone Ave; Brooklyn Park, MN 55428 - logajan@ns.network.com, 612-424-4888, Fax 612-424-2853