QB / QB64 Discussion Forum      Other Subforums, Links and Downloads
 

 Return to Index  

You don't need Interrupt to get long filenames in NT or XP or above.

February 23 2010 at 11:33 AM
  (Login burger2227)
R


Response to get long filenames in QBasic

 
You must use CMD /C so you can read the filenames from a file where the information is piped to. Will not work on Win 9X machines, but the following SUB checks for that:

SUB LFN
IF LEN(ENVIRON$("OS")) = 0 THEN EXIT SUB ' not 9x machines
SHELL "cmd /c dir /x > DOS-DATA.INF"
SCREEN 0: SCREEN 12: BGround: Border 13 ' use if program is fullscreen
OPEN "DOS-DATA.INF" FOR INPUT AS #1
IF LOF(1) THEN
FOR i = 1 TO 5
IF EOF(1) THEN EXIT FOR
LINE INPUT #1, line$
NEXT
Border 13
COLOR 14: LOCATE 2, 4: PRINT " Short Long Last Modified" ' add spacing lost in forum
tmp$ = "\ \ \ \ & " ' add spacing lost in forum

DO UNTIL EOF(1)
cnt% = cnt% + 1
LINE INPUT #1, line$
IF MID$(line$, 1, 1) = SPACE$(1) THEN EXIT DO 'end of file info
last$ = MID$(line$, 1, 20): DIR$ = MID$(line$, 26, 3)
IF MID$(line$, 40, 1) <> SPACE$(1) THEN
SHFN$ = MID$(line$, 40, INSTR(40, line$, SPACE$(1)) - 1)
LGFN$ = MID$(line$, 53)
ELSE : SHFN$ = MID$(line$, 53): LGFN$ = SPACE$(12)
END IF
IF cnt% MOD 25 = 0 THEN
Align 14, 29, "Press a key for more files!"
DO: LOOP UNTIL INKEY$ <> ""
CLS : Border 13
COLOR 14: LOCATE 2, 4: PRINT " Short Long Last Modified" ' add spacing lost in forum

END IF
COLOR 11: LOCATE (cnt% MOD 25) + 3, 4
PRINT USING tmp$; DIR$; SHFN$; LGFN$
LOCATE (cnt% MOD 25) + 3, 59: PRINT last$;
LOOP
END IF
Align 10, CSRLIN + 1, "Total folders and files =" + STR$(cnt%)
CLOSE #1
END SUB

SUB Align (Tclr, Trow, Txt$)
Tcol = 41 - (LEN(Txt$) \ 2)
COLOR Tclr: LOCATE Trow, Tcol: PRINT Txt$;
END SUB

SUB Border (clr%)
COLOR clr%
FOR Row = 1 TO 30
LOCATE Row, 1: PRINT CHR$(179);
LOCATE Row, 80: PRINT CHR$(179);
NEXT Row
FOR Col = 1 TO 80
LOCATE 1, Col: PRINT CHR$(196);
LOCATE 30, Col: PRINT CHR$(196);
NEXT Col
LOCATE 1, 1: PRINT CHR$(218);
LOCATE 1, 80: PRINT CHR$(191);
LOCATE 30, 1: PRINT CHR$(192);
LOCATE 30, 80: PRINT CHR$(217);
END SUB

SUBs are formatted for SCREEN 12, but you can reformat them for any size screen.

Ted


    
This message has been edited by burger2227 on Feb 23, 2010 11:46 AM
This message has been edited by burger2227 on Feb 23, 2010 11:35 AM


 
 Respond to this message   
Responses

 Copyright © 1999-2014 Network54. All rights reserved.   Terms of Use   Privacy Statement  

Newbies usually go to www.qbasic.com and click on The QBasic Forum
Forum regulars have their own ways, which include The QBasic Community Forums