Re: Query on Basic From: John Iannetta <73510.2152@CompuServe.COM> Reply to: John Iannetta Date: Thu, 12 Nov 1998 18:26:09 -0500 Organization: CompuServe, Inc. (1-800-689-0736) References: <72auvq$d23@chronicle.concentric.net> Andrew Vardy said, "I came upon a little funny thing I can't understand. Take the following lines. 10 OPEN 4,4:CMD4:PRINT"HELLO, WE BEGIN" 20 OPEN15,8,15:PRINT#15,"UJ":CLOSE15 30 PRINT"WE ARE DONE!" 40 PRINT#4 50 CLOSE4 It should just print the stuff to printer. Yet, well, try it out. I don't follow why, it seems not to work out.". The CMD4 sends a LISTEN to device 4, and puts 4 into address 154 (as the active output device). It also sends a chr$(13) (). If you don't want the , use: 10 open4,4:cmd4,"";:etc. The string in line 10 is sent to the printer, except for the terminating (since one byte is always buffered when data are sent to IEC [serial] devices). In line 20, the OPEN doesn't send anything to the IEC port, since no string is attached. But the PRINT#15 sends a LISTEN for device 8, after first sending the buffered chr$(13) to the printer. When the drive gets the command, it is listened. But when the printer gets the command, it goes off-line (wrong device number). Also, 8 is put into address 154. The "uj" string (followed by the ) is then sent to the drive. PRINT#15 then sends an UNLISTEN; that commands the drive stop listening. The UNLISTEN also executes the "uj" command, and it puts 3 (screen) back into 154. If the drive is a 1581, it will be reset and the string in line 30 will go to the screen. But if the drive is a 1541, that will happen only with a "ui" or a "u9". A "uj" or a "u:", before doing a reset, makes a destructive RAM check; it takes a second or so. If you send a command to the drive before it is finished, the drive will hang the computer in a KERNAL routine. -- I pressed RETURN, and the message said, "Missing GOSUB". John