Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Plasma, I have a question about your file function.
#1
Hi.

&H27 (change long filename to short filename) works fine, but &H10 (and the rest, too) does not work. I need to change the long directory to short before I change the long filename to short filename, but it isn't happening.

Any ideas?

Code:
FUNCTION dir2$ (fileSpec$, attr) STATIC
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 = VARSEG(FileSpecZ$)
Regs.dx = SADD(FileSpecZ$)
ELSE Regs.ax = &H4F00
END IF
INTERRUPTX &H21, Regs, Regs
IF Regs.flags AND 1 THEN dir2$ = "": EXIT FUNCTION
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
END IF
FileSpecZ$ = CHR$(0): LOOP: END FUNCTION
Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."

Visit www.neobasic.net to see rubbish in all its finest.
Reply
#2
27h is the allowed attributes for files. 10h is the allowed attributes for directories.

Code:
Bit(s)  Description
7      shareable (Novell NetWare)
7      pending deleted files (Novell DOS, OpenDOS)
6      unused
5      archive
4      directory
3      volume label.
2      system
1      hidden
0      read-only

That function has nothing to do with long filenames. If you want to change long file/pathnames to short, you need to use Int 21/AX=7160h/CL=01h.
Reply
#3
For some strange reason I thought that I could get as output a short filename AND a short directory.

EDIT: Never mind......

D'oh......
Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."

Visit www.neobasic.net to see rubbish in all its finest.
Reply
#4
I already had it written when you edited your post, so here it is anyway:

Code:
DEFINT A-Z
FUNCTION LongToShort$ (LongName$)

  LongNameZ$ = LongName$ + CHR$(0)
  ShortNameZ$ = SPACE$(128)

  DIM Regs AS RegTypeX
  Regs.ax = &H7160
  Regs.cx = &H1
  Regs.ds = VARSEG(LongNameZ$)
  Regs.si = SADD(LongNameZ$)
  Regs.es = VARSEG(ShortNameZ$)
  Regs.di = SADD(ShortNameZ$)
  InterruptX &H21, Regs, Regs

  IF Regs.ax = &H2 THEN
    PRINT "Invalid component in directory path or drive letter."
    EXIT FUNCTION
  ELSEIF Regs.ax = &H3 THEN
    PRINT "Malformed path or invalid drive letter."
    EXIT FUNCTION
  END IF

  StringEnd = INSTR(ShortNameZ$, CHR$(0)) - 1
  IF StringEnd < 1 THEN
    ShortName$ = ""
  ELSE
    ShortName$ = LEFT$(ShortNameZ$, StringEnd)
  END IF
  LongToShort$ = ShortName$

END FUNCTION
Reply
#5
Thanks.

I'll use it and in the process remove an entire library. Smile
Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."

Visit www.neobasic.net to see rubbish in all its finest.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)