Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
I built a file requester...
#1
Ok guys, I know have a personal grudge with QB 7.1. After looking through
100s of file requester routines developed by 'brilliant' programmers, I
took it upon myself to code a great file requester that should work on all
comps. So here it is. The only problem that I am facing right now is what
value should I put in the CX register to get only files or only directories.

TYPE FType
reserved AS STRING * 20
Attribute AS STRING * 1
CreateTime AS INTEGER
CreateDate AS INTEGER
FileSize AS LONG
FileName AS STRING * 13
END TYPE

DIM DTA AS FType
DIM inregs AS regtypex
DIM outregs AS regtypex
DIM FlName AS STRING
DIM DirName AS STRING

CONST ATTR = 16

CLS

FlName = "C:\*.*" + CHR$(0)

inregs.ax = &H1A00
inregs.ds = VARSEG(DTA)
inregs.dx = VARPTR(DTA)
interruptx &H21, inregs, outregs

inregs.ax = &H4E00
inregs.ds = SSEG(FlName)
inregs.dx = SADD(FlName)
inregs.cx = ATTR
interruptx &H21, inregs, outregs

PRINT outregs.ax
PRINT outregs.flags
DO
i% = i% + 1
DTA.FileName = ""
inregs.ax = &H4F00
inregs.cx = ATTR
interruptx &H21, inregs, outregs
PRINT DTA.FileName
SLEEP
LOOP UNTIL outregs.ax <> 0
PRINT i%
Reply
#2
You should have said you were using 7.1 before ... all the other DIR replacements you tried would have worked if you had swapped SSEG for VARSEG with variable-length strings. (4.5 doesn't even have the SSEG keyword)

Try this now:

Code:
' DIR$ replacement for by Plasma357

DEFINT A-Z
'$INCLUDE: 'QB.BI'

DECLARE FUNCTION DIR2$ (FileSpec$, Attr)

CONST ANYDIR = &H10
CONST ANYFILE = &H27

CLS
n$ = DIR2$("C:\*.*", ANYDIR)
DO WHILE LEN(n$)
  PRINT n$
  n$ = DIR2$("", ANYDIR)
LOOP

FUNCTION DIR2$ (FileSpec$, Attr) STATIC

  'Settings for Attr: (may be combined)
  '
  ' &H40 Device
  ' &H20 Archive
  ' &H10 Directory
  ' &H8  Volume Label
  ' &H4  System File
  ' &H2  Hidden File
  ' &H1  Read-Only File

  DIM DTA AS STRING * 44
  FileSpecZ$ = FileSpec$ + CHR$(0)

  DO

    DIM Regs AS RegTypeX
    
    Regs.ax = &H1A00
    Regs.ds = VARSEG(DTA)
    Regs.dx = VARPTR(DTA)
    InterruptX &H21, Regs, Regs

    IF FileSpecZ$ <> CHR$(0) THEN
      Regs.ax = &H4E00
      Regs.cx = Attr
      Regs.ds = SSEG(FileSpecZ$) ' there ya go
      Regs.dx = SADD(FileSpecZ$)
    ELSE
      Regs.ax = &H4F00
    END IF

    InterruptX &H21, Regs, Regs
  
    IF Regs.flags AND 1 THEN
      DIR2$ = ""
      EXIT FUNCTION
    ELSE
      RealAttr = ASC(MID$(DTA, 22, 1))
      IF RealAttr AND Attr THEN
        Null = INSTR(31, DTA, CHR$(0))
        DIR2$ = MID$(DTA, 31, Null - 31)
        EXIT FUNCTION
      ELSE
        FileSpecZ$ = CHR$(0)
      END IF
    END IF

  LOOP

END FUNCTION
Reply
#3
I have completed my file requester. It works in qb7.1. Can u tell me what is the difference between VARSEG and SSEG? Why does SSEG work and not VARSEG in qb7.1?

and

How do i get hidden/read only files/dirs?
Reply
#4
I'm not going to move your eyes for you. Look at the code.
Reply
#5
Sorry but I have been messing up things since yesterday! :oops:
Reply
#6
Quote:I have completed my file requester. It works in qb7.1. Can u tell me what is the difference between VARSEG and SSEG? Why does SSEG work and not VARSEG in qb7.1?

and

How do i get hidden/read only files/dirs?

Look at IN|T 21h, subfunctions(I think) 4ch to 440eh. :*)

Check BITS, AND xxxxxxxx ARCHIVE=BIT 5
y smiley is 24 bit.
[Image: anya2.jpg]

Genso's Junkyard:
http://rel.betterwebber.com/
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)