home *** CD-ROM | disk | FTP | other *** search
-
- DOS & Don'ts -- Part 30
- by Jimmy Weiler
-
-
-
- 1110 FOR C1=164 TO 255: GET#8,K$: NEXT
-
- We are not interested in the next
-
- 91 characters, so we throw them away.
-
-
- 1120 FOR FILE=1 TO 144
-
- Here we start reading the file
-
- names out of the directory. There
-
- is room for 144 files in a normal
-
- 1541 directory.
-
-
- 1130 FOR BYTE=0 TO 29: GET#8,F$(BYTE):
- NEXT: IF ST=66 THEN FILE=150:
- GOTO 1240
-
- Each file name in a directory
-
- is 29 characters long. We read those
-
- characters into our file name array,
-
- F$. If we reach the end of the
-
- directory while we read the file name,
-
- STATUS will equal 66. In that case,
-
- we set our file counter to 150 and
-
- exit the for-next loop we are using
-
- to read the file names.
-
-
- 1140 F$(0)=F$(0)+Z$
- 1150 IF F$(0)<IL$ THEN 1220
-
- The first character of any directory
-
- file entry describes the file type.
-
- These are:
-
- DELeted: 0 or 128
- SEQuential: 129
- PRoGram: 130
- USeR: 131
- RELative: 132
-
- If the file name we are processing
-
- was scratched from the directory or
-
- improperly closed this code will let
-
- us proceed to the next file.
-
-
- 1160 PRINT TY$(ASC(F$(0))-128);": ";
-
- We subtract 128 from the file type
-
- character, use the resulting value to
-
- index into TY$, and print the
-
- appropriate type.
-
-
- 1170 PRINT Q$;:FOR LTTR=3 TO 18:
- IF F$(LTTR)<>SP$ THEN PRINT
- F$(LTTR);
- 1180 NEXT: PRINT Q$;
-
- We print the file name in quotes.
-
- If we encounter a shifted space (SP$)
-
- before the sixteenth character, it
-
- means we have reached the end of the
-
- file name.
-
-
- 1190 SZ=256*ASC(F$(29)+Z$)+ASC(F$(28))
-
- The 28th and 29th characters of each
-
- file name entry contain the size in
-
- blocks of that particular file. This
-
- code calculates that size.
-
-
- 1200 PRINT TAB(23-(SZ<100)-(SZ<10))SZ
- "BLOCK";:IF SZ<>1 THEN PRINT "S";
-
- To make the file size column of our
-
- printout line up nicely, we use some
-
- BOOLEAN magic. Any expression that
-
- evaluates as either true or false is
-
- said to be a Boolean expression.
-
- "E = F" is an example. If the value
-
- of E equals the value of F then the
-
- expression is true. Otherwise it is
-
- false.
-
- When your Commodore evaluates
-
- a Boolean expression as "true" it
-
- assigns a value of -1 to the result.
-
- "False" evaluates as 0.
-
- 10 LET E=1: LET F=1
- 20 LET B = E = F
- 30 PRINT B
-
- Line 30 of this example will print -1.
-
- The Boolean calculations in line
-
- 1200 will add 1 to the TAB position if
-
- the size of the file is less than 100
-
- and will add one more if the size is
-
- also less than 10.
-
-
- 1210 PRINT
-
- We print a carriage return because
-
- we have finished with the file name
-
- we were working on.
-
-
- 1220 IF FILE/8<>INT(FILE/8) THEN
- GET#8,L$,M$
-
- Every directory block on the disk
-
- can hold eight file names. There
-
- are two unused characters between each
-
- of the names. We GET# those
-
- characters and throw them away.
-
- However, between the last file entry
-
- in one block and the first entry in
-
- the next there are NO unused
-
- characters. So, every eight file
-
- names, we DON'T GET# those extra
-
- characters.
-
-
- 1230 BU=BU+SZ: SZ=0
-
- We add the size of the last file
-
- to the number of blocks used on the
-
- disk.
-
-
- 1240 NEXT FILE:
- PRINT BU"OF 664 BLOCKS USED."
-
- This is the end of the for-next
-
- loop that counts through the
-
- files in the directory. When we have
-
- printed the last file, we then
-
- print the number of blocks they have
-
- used.
-
-
- 1250 CLOSE 8: CLOSE 15
-
- When we're done, we close all the
-
- disk I/O channels we used to read the
-
- directory.
-
- -------< continued in Part 31 >-------
-