[Coco] Does the DIR option of OPEN work in Basic09 ?

coco at jechar.ca coco at jechar.ca
Sun May 23 13:56:11 EDT 2021


Thanks worked fine after I replaced
DIM dirpathname:STRING2[256]
with
DIM dirpathname:STRING[256]

On 2021-05-22 22:58, L. Curtis Boyle wrote:
> As others have mentioned, directory entries are not just the
> filenames, but also include a 24 bit start cluster number. The name is
> also high bit terminated (so basically +$80 on the ASCII value). You
> also should be checking for filenames that start with a CHR$(0), which
> is a directory entry for a deleted file.
> 
> A program to do this would look something like this:
> 
> PROCEDURE ReadDir
> DIM dirprintname:STRING[29]
> TYPE direntry=name:STRING[29];startcluster(3):BYTE
> DIM dirent:direntry
> DIM c:INTEGER
> DIM curchar,dirpath:BYTE
> DIM dirpathname:STRING2[256]
> 
> dirpathname="/dd/sys"
> OPEN #dirpath,dirpathname:READ+DIR
> WHILE NOT(EOF(#dirpath)) DO
>   GET #dirpath,dirent
>   IF LEFT$(dirent.name,1)<>CHR$(0) THEN
>     dirprintname=""
>     FOR c=1 TO 29
>       curchar=ASC(MID$(dirent.name,c,1))
>     EXITIF curchar>127 THEN
>       dirprintname=dirprintname+CHR$(curchar-128)
>     ENDEXIT
>     dirprintname=dirprintname+CHR$(curchar)
>     NEXT c
>     PRINT dirprintname
>   ENDIF
> ENDWHILE
> CLOSE #dirpath
> END
> 
> 
> 
> L. Curtis Boyle
> curtisboyle at sasktel.net
> 
> TRS-80 Color Computer Games website
> http://www.lcurtisboyle.com/nitros9/coco_game_list.html
> 
> NitrOS-9 Ease of Use (EOU) Project
> http://www.lcurtisboyle.com/nitros9/nitros9.html
> 
> 
> 
> 
>> On May 22, 2021, at 1:33 PM, coco at jechar.ca wrote:
>> 
>> 
>> I tried this OPEN #dp,dline$:READ+DIR
>> 
>> But
>>   dline$="/dd/SYS"
>>   OPEN #dp,dline$:READ+DIR
>>   REPEAT
>>      READ #dp,line$
>>      PRINT line$
>>   UNTIL EOF(#dp)
>> 
>> Did not print the SYS directory, Why ?
>> 
>> Charlie
>> 
>> --
>> Coco mailing list
>> Coco at maltedmedia.com
>> https://pairlist5.pair.net/mailman/listinfo/coco
>> 


More information about the Coco mailing list