REM $DYNAMIC SUB GetFileAttributes (fileName$, attr AS FileAttributesType) STATIC ' +---------------------------------------------------------------------+ ' | - S U B G e t F i l e A t t r i b u t e s - | ' | | ' | Public Domain - FreeWare | ' +---------------------------------------------------------------------+ ' | Author: Donald Bernard "Don" Smith | ' | Email : smithdonb@earthlink.net | ' +---------------------------------------------------------------------+ ' | - ABOUT THE AUTHOR - | ' +---------------------------------------------------------------------+ ' | | ' | Hello. My name is Don Smith and I am a thirty-year retired teacher | ' | of Math/History/Spanish residing in Orange County, California. I | ' | am also a former six-year Sergeant of Marines. Who-Rah! On certain | ' | forums I am known as MarineDon. My email is: smithdonb@earthlink.net| ' | | ' +---------------------------------------------------------------------+ ' | - COPYING AND DISTIBUTING - | ' +---------------------------------------------------------------------+ ' | Since this code is public domain and freeware, anyone may freely | ' | copy and distribute it. If you use the QuickBasic code in one of | ' | your own programs, you do not have to cite my name as the author, | ' | and you may even change its name. | ' +---------------------------------------------------------------------+ ' +---------------------------------------------------------------------+ ' | GetFileAttributes is used to determine if a file exists or not. | ' | See example, below: | ' +---------------------------------------------------------------------+ ' | | ' | +--------------------------------------------------------------+ | ' | | Use these next 19 lines at the very top of your program, | | ' | | even before declared subs and functions to set up SUB | | ' | | GetFileAttributes and SUB InterruptX | | ' | | | | ' | | SUB GetFileAttributes uses these SUBs to check the | | ' | | existence of a file | | ' | +--------------------------------------------------------------+ | ' | | | | ' | |TYPE RegTypeX | | ' | | ax AS INTEGER | | ' | | bx AS INTEGER | | ' | | cx AS INTEGER | | ' | | dx AS INTEGER | | ' | | bp AS INTEGER | | ' | | si AS INTEGER | | ' | | di AS INTEGER | | ' | | flags AS INTEGER | | ' | | ds AS INTEGER | | ' | | es AS INTEGER | | ' | |END TYPE | | ' | |TYPE FileAttributesType | | ' | | readOnly AS INTEGER | | ' | | hidden AS INTEGER | | ' | | systemFile AS INTEGER | | ' | | archive AS INTEGER | | ' | | result AS INTEGER | | ' | |END TYPE | | ' | +--------------------------------------------------------------+ | ' | +--------------------------------------------------------------+ | ' | | | | ' | | Also, for SUB GetFileAttributes to work, you must | | ' | | use QuickBasic 4.5's QB.Lib and must declare its | | ' | | SUB InterruptX as seen here: | | ' | | +----+----+ ' | | DECLARE SUB InterruptX (intnum%, inreg AS RegTypeX, outreg AS RegTypeX)| ' | +-------------------------------------------------------------------+----+ ' | | ' | To use SUB GetFileAttributes -> | ' | | ' | CALL GetFileAttributes (fileName$, attr) | ' | | ' | IF attr.archive > 0 then | ' | 'file does not exist. Use a pop-up screen and | ' | 'back out. | ' | ELSE | ' | 'file does indeed exist. Continue with routine. | ' | END IF | ' | | ' +---------------------------------------------------------------------+ DIM regX AS RegTypeX regX.ax = &H4300 F$ = fileName$ + CHR$(0) regX.ds = VARSEG(F$) regX.dx = SADD(F$) InterruptX &H21, regX, regX IF regX.flags AND 1 THEN attr.result = regX.ax ELSE attr.result = 0 END IF attr.readOnly = regX.cx AND 1 attr.hidden = (regX.cx \ 2) AND 1 attr.systemFile = (regX.cx \ 4) AND 1 attr.archive = (regX.cx \ 32) AND 1 END SUB