|
Prev: Clock Port 101?
Next: RS232 buffer size
From: xlar54 on 25 Jun 2006 14:20 I was looking at some code to read a disk directory, and it occured to me that the simplest and fastest method would be to use the built in DIRECTORY command. Im not sure where my logic is falling apart, but here's my code: 10 DOPEN#1"TESTDIR,S", u8, w : CMD 1 : DIRECTORY : DCLOSE#1 20 DOPEN#1,"TESTDIR,S", u8 30 FOR T = 1 to 20 40 GET#1, a$ 45 PRINT a$; 50 NEXT T 60 DCLOSE#1 : SCRATCH"TESTDIR" So basically Im doing the DIRECTORY command, redirecting to the sequential file using CMD. When I run this, I get garbage back as it tries to read the file back in. Can someone tell me where Im going wrong? (Note Im just GETing data back, not trying to do anything with it yet) Thanks in advance
From: James @ cbm264 on 25 Jun 2006 18:49 Scott, It's documented on the Plus/4 that one cannot use DIRECTORY and CMD at the same time. Was this fixed for the 128? (Can you CMD a DIRECTORY to the printer?) There exist many BASIC programs that can read a directory in from the disk drive, usually by opening "$0,p,r" and discarding the first two bytes. Adapting some of that code to suit your purpose would probably be more efficient than "printing" a directory to a sequential file, then reading that sequential file back in. James www.cbm264.com
From: Paul Rosenzweig on 25 Jun 2006 20:34 James @ cbm264 wrote: > Scott, > > It's documented on the Plus/4 that one cannot use DIRECTORY and CMD at > the same time. Was this fixed for the 128? (Can you CMD a DIRECTORY to > the printer?) > > There exist many BASIC programs that can read a directory in from the > disk drive, usually by opening "$0,p,r" and discarding the first two > bytes. Adapting some of that code to suit your purpose would probably > be more efficient than "printing" a directory to a sequential file, > then reading that sequential file back in. My C128D SYSTEM GUIDE says that you can't send a directory to a printer using a DIRECTORY command. It doesn't say anything about the CMD:DIRECTORY command combination, but from XLAR54's experience, it must be VERBOTEN (pardon my french). It must be difficult to redirect the DIRECTORY output to a file as well. XLAR54 is adding a logical step that isn't needed if all he wants is to input a directory into a BASIC program. Skip writing the directory data to a file, and input the data from the "directory file" opened as you suggest. XLAR54 should remember that the file length in sectors is a 2 byte integer with the low order byte comming before the high order byte. He also needs to know that a directory entry terminates with a zero byte.
From: Craig Taylor on 25 Jun 2006 23:32 xlar54 wrote: > So basically Im doing the DIRECTORY command, redirecting to the > sequential file using CMD. When I run this, I get garbage back as it > tries to read the file back in. Can someone tell me where Im going > wrong? (Note Im just GETing data back, not trying to do anything with > it yet) As mentioned elsewhere in this thread Directory is a no-go with the CMD command. Why not grab the bytes yourself from the drive? Examples are available on the web. Commodore Hacking also covered this from a learning ML point of view but you should be able to translate it into basic. ( http://www.ctalkobt.net/prog/articles/LearningMLPart3.php ). -- Craig Taylor ============================================================= http://www.ctalkobt.net/cbm Random mumblings and musings of a deranged mind.
From: Paul Rosenzweig on 26 Jun 2006 00:48
Craig Taylor wrote: > > As mentioned elsewhere in this thread Directory is a no-go with the CMD > command. Why not grab the bytes yourself from the drive? Examples are > available on the web. Commodore Hacking also covered this from a > learning ML point of view but you should be able to translate it into > basic. ( http://www.ctalkobt.net/prog/articles/LearningMLPart3.php ). Ordinarily, one implements a prototype algorithm in BASIC, and when all the bugs are worked out, the algorithm is ported to ML. You may want to retain the calls to CHKIN, and CLRCHN, as SYSs and change your calls to GETIN to ordinary GETs, not GET#s. If you can store multiple inputs in string variables, the input will be faster than if you use the conventrional GET#. |