Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!evax!cs4344af From: cs4344af@evax.arl.utexas.edu (Fuzzy Fox) Newsgroups: comp.sys.cbm Subject: Re: inputting from the modem port in commdore basic Message-ID: <1991Jan4.054251.1348@evax.arl.utexas.edu> Date: 4 Jan 91 05:42:51 GMT References: <1991Jan3.204035.20778@news.nd.edu> Organization: Computer Science Engineering Univ. of Texas at Arlington Lines: 52 In article <1991Jan3.204035.20778@news.nd.edu> treesh@vangogh.helios.nd.edu writes: >1000 for t=1to1500:get#131,a$:a=peek(rs232status) >1010 ifa=anda$=""then next:a$="timeout":return >1020 ifa=thena$="Loss of Carrier":return >1030 ifa$=chr$(13)thena$=a1$:return >1040 a1$=a1$+a$:goto1000 Two things I noticed first off. First, you are looping from 1 to 1500. There is no guarantee that looping from 1 to 1500 will produce a one- second delay. C128 and C64 Basic are written differently and take different amounts of time to do their tasks, even if you discount 1 MHz/ 2 Mhz modes. Second, I noticed you have a "conditional NEXT" statement, which means that the FOR loop may or may not hit its corresponding NEXT statement before you RETURN from the subroutine. This can cause stack overflows, depending on how the Basic is written. It is definitely not a good programming practice. I suppose this is more a "peeve" of mine than anything else. >In 128 basic, this code does the job perfectly so long as the string size >does not get too large, since the C128 has a 512 byte rs232 buffer... The C128 and C64 both have a 256 byte input buffer and a 256 byte output buffer. The RS-232 routines are almost identical. Here's how I would write the above routine (for what it's worth): 1000 a1$="" 1010 t=ti 1020 ifti60thena$="Timeout":return 1040 a=peek(rs232status):ifa=thena$="Loss of Carrier":return 1050 get#131,a$:ifa$=chr$(13)thena$=a1$:return 1060 a1$=a1$+a$:goto1020 The use of the variable TI allows you to use the Jiffy Clock (accurate enough over 1 second) to measure the amount of time since input began, and works regardless of whether the Basic is compiled, running on a C128 or C64, 1 or 2 MHz, whatever. Line 1020 is only there to check that the Jiffy Clock hasn't wrapped around from 235959 to 000000. It will turn a 1-second delay into a 2-second delay if it occurs at a 24-hour boundary. Big deal. :) I'm using code almost identical to this in my own BBS software, so I think it works. :) -- begin 644 .signature G5&AI