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
FILE SIZE
-
- Veteran
- Posts: 111
- Joined: Sat Feb 21, 2009 8:19 am
- Location: New York, U.S.
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.
Joseph Rose, a.k.a. Harry Potter
Creating magic in the computer community...or at least striving to!
Creating magic in the computer community...or at least striving to!
- burger2227
- Veteran
- Posts: 2466
- Joined: Mon Aug 21, 2006 12:40 am
- Location: Pittsburgh, PA
That's CVLNG
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.
Words are Integers (2 bytes)
DWords are LONG (4 bytes) ' also called INT 32
Bytes can be done with a variable String * 1.
Please acknowledge and thank members who answer your questions!
QB64 is a FREE QBasic compiler for WIN, MAC(OSX) and LINUX : https://www.qb64.org/forum/index.php
Get my Q-Basics demonstrator: https://www.dropbox.com/s/fdmgp91d6h8ps ... s.zip?dl=0
QB64 is a FREE QBasic compiler for WIN, MAC(OSX) and LINUX : https://www.qb64.org/forum/index.php
Get my Q-Basics demonstrator: https://www.dropbox.com/s/fdmgp91d6h8ps ... s.zip?dl=0