Home | Reviews | GUIpedia | Forum | Fun500


Dickfile directory
This is an asm routine that takes files & directories for a specified directory and puts them into a string array with direcotries ending in '\' and file names nicely trimmed. It acts as a function returning the number of files & direcotries in the directory, or in a case where this amount exceeds the array boundary, it will return the ubound. It is a little slow at the moment, probably from the string searching and parsing, but I may upgrade it later. DEFINT A-Z DECLARE FUNCTION getfiles (p$, arr() AS STRING) DIM SHARED f(10) AS LONG f(0) = &H1EE58955 f(1) = &HB80656C5 f(2) = &H21CD1A00 f(3) = &H4CA5D1F f(5) = &H8BE58955 f(6) = &H4E8B0656 f(7) = &HA768B08 f(8) = &H21CD048B f(9) = &HCA5D0489 f(10) = &H6 'push bp 'mov bp,sp 'push ds 'lds dx,[bp+6] 'mov ax,01a00h 'int 21h 'pop ds 'pop bp 'retf 4 ''' 'push bp 'mov bp,sp 'mov dx,[bp+6] 'mov cx,[bp+8] 'mov si,[bp+10] 'mov ax,[si] 'int 21h 'mov [si],ax 'pop bp 'retf 6 DEF SEG = VARSEG(f(0)) TYPE dtatype reserved AS STRING * 21 a AS STRING * 1 time AS INTEGER date AS STRING * 2 size AS LONG fname AS STRING * 13 END TYPE DIM SHARED dta AS dtatype DEF SEG = VARSEG(f(0)) CALL absolute(SEG dta, VARPTR(f(0))) 'the following is an example: CLS DIM fs(550) AS STRING j = getfiles("C:\", fs()) FOR i = 0 TO 20 PRINT fs(i) NEXT ''' FUNCTION getfiles (p$, arr() AS STRING) DEF SEG = VARSEG(f(0)) p$ = p$ + "*.*" + CHR$(0) ax = &H4E00 CALL absolute(ax, BYVAL 16, BYVAL SADD(p$), VARPTR(f(5))) FOR i = 0 TO UBOUND(arr) - 1 ax = &H4F00 CALL absolute(ax, 0, 0, VARPTR(f(5))) IF ax AND &HF 0 THEN EXIT FOR arr(i) = LEFT$(dta.fname, INSTR(dta.fname, CHR$(0)) - 1) + CHR$(32 + (dta.a = CHR$(16)) * -60) NEXT getfiles = i END FUNCTION
2011-04-152:18 AM

Dickfreebasic version
this is the freebasic version with the exact same functionality as the QB one. (for -lang deprecated)

function getfiles(path as string, f() as string) as integer dim s as string = dir(path+"*.*", &h10) for i=0 to ubound(f) s=dir() if s="" then exit for f(i)=s+"\" next s = dir(path+"*.*", not &h10) for i=i to ubound(f) if s="" then exit for f(i)=s s=dir() next getfiles = i end function
2011-11-216:04 PM

Code


2021 Brandon Cornell