Page 1 of 1

FILE SIZE

Posted: Sat Jun 06, 2009 12:32 am
by DDastardly71
Looking at this procedure that was written by Alex Warren, 18th April 1998, LONG FILENAMES FROM DOS DEMONSTRATION v1.0. does anybody know how to extract & convert the file size thats retured after calling the FindFirst Interrupt?

How do you convert QWord & DWord to QB? Please give some example.

Thanks

'-------------------------



SUB showdirectory

quitloop = 0

' What's done:
' first, call 714Eh to find first matching file, then call 714Fh to find
' next matching file and so on. Use 71A1h to stop the search.

' Attributes masks:
' Bit: 4 = directory
' 3 = volume label
' 2 = system
' 1 = hidden
' 0 = read-only

' ax=&h714E (service)
' ds:dx = filespec, e.g. *.*
' es:di = finddata record (see below)
' cl = allowable attributes mask, set here to FF so ALL attributes allowed
' ch = required attributes mask, set here to 00 so NO attributes required

DIM finddatarecord AS STRING * 500
DIM filespec AS STRING * 4

filespec = "*.*" + CHR$(0)

inregs.ax = &H714E
inregs.ds = VARSEG(filespec)
inregs.dx = VARPTR(filespec)
inregs.es = VARSEG(finddatarecord)
inregs.di = VARPTR(finddatarecord)
inregs.cx = &HFF
inregs.si = &H0
int21
filefindhandle = outregs.ax

numfiles = 1

DO

' finddatarecord$ is now filled with loads of information about the file
' we've retrieved (info from Ralf Brown's Interrupts List):
' offset 00h bits 0-6 are standard DOS file attribs
' 04h QWORD file creation time
' 0Ch QWORD last access time
' 14h QWORD last modification time
' 1Ch DWORD file size (high 32 bits) <----------------
' 20h DWORD file size (low 32 bits) <----------------
' 2Ch 260bytes ASCIZ full filename
' 130h 14bytes ASCIZ short filename

' If required, you could interpret all that stuff but we're only interested
' in the filenames for now:

longfilename$ = truncate$(MID$(finddatarecord, &H2D, 260))
shortfilename$ = truncate$(MID$(finddatarecord, &H131, 14))

' NOTE that shortfilename$ will contain nothing if the short filename
' is *exactly* the same as the long file name.

PRINT longfilename$; TAB(30); shortfilename$

' If longfilename$ is null, we've reached the end of the list.
IF longfilename$ = "" THEN PRINT "*** END OF LIST; PRESS A KEY ***": EXIT DO


' reset finddatarecord
finddatarecord = STRING$(500, 0)

inregs.ax = &H714F
inregs.bx = filefindhandle
int21

IF numfiles MOD 20 = 0 THEN
COLOR 14
PRINT ">> Press a key <<"
COLOR 7
a$ = INPUT$(1)
IF a$ = CHR$(27) THEN quitloop = 1
END IF

numfiles = numfiles + 1

LOOP UNTIL quitloop = 1

IF quitloop = 0 THEN a$ = INPUT$(1)

' It's important to reset the filefind handle:
inregs.ax = &H71A1
inregs.bx = filefindhandle
int21

END SUB

Posted: Mon Jun 15, 2009 11:50 am
by Harry Potter
You can convert the file size to a LONG. Just make sure the high DWORD is 0 by extracting the appropriate field in the buffer and making sure it is four &h00's. Then extract the low DWORD to a LONG variable or type field with a CVTLNG (Is this right?) and making sure it is positive. If either condition is false, then the size is out-of-range. Otherwise, you have the size.

That's CVLNG

Posted: Mon Jun 15, 2009 7:03 pm
by burger2227
In 16 bit Qbasic code:

Words are Integers (2 bytes)
DWords are LONG (4 bytes) ' also called INT 32

Bytes can be done with a variable String * 1.