mirror of
https://github.com/QB64Official/qb64.git
synced 2024-08-30 20:00:15 +00:00
63 lines
2.6 KiB
Text
63 lines
2.6 KiB
Text
|
The '''_HIDE''' action statement is used to hide the DOS window opened by a {{KW|SHELL}} statement.
|
||
|
|
||
|
|
||
|
{{PageSyntax}}
|
||
|
:{{KW|SHELL}} {{KW|_HIDE}} {{Parameter|StringCommandLine$}}
|
||
|
|
||
|
|
||
|
* Can only be used in the {{KW|SHELL}} statement when using '''QB64'''.
|
||
|
* Allows any DOS command line window to be hidden from view without affecting the program.
|
||
|
* {{KW|_HIDE}} MUST be used when sending("piping") screen information to a file!
|
||
|
* '''Note:''' Some commands may not work without adding CMD /C to the start of the command line.
|
||
|
|
||
|
|
||
|
''Example:'' Subprogram that displays long and short filenames using the DIR /X option(NT or above) in SCREEN 12:
|
||
|
{{CodeStart}}
|
||
|
'' ''
|
||
|
SUB LFN
|
||
|
IF LEN({{Cl|ENVIRON$}}("OS")) = 0 THEN EXIT SUB ' /X not available Win 9X and ME
|
||
|
SHELL {{Cl|_HIDE}} "cmd /c dir /x > DOS-DATA.INF" ' load display data to a file
|
||
|
OPEN "DOS-DATA.INF" FOR INPUT AS #1
|
||
|
IF {{Cl|LOF}}(1) THEN
|
||
|
Header$ = SPACE$(10) + "Short" + SPACE$(16) + "Long" + SPACE$(20) + "Last Modified"
|
||
|
tmp$ = "\ \ \ \ &" ' print using template format
|
||
|
COLOR 14: LOCATE 2, 4: PRINT Header$
|
||
|
DO UNTIL EOF(1)
|
||
|
{{Cl|LINE INPUT}} #1, line$
|
||
|
IF LEN(line$) AND MID$(line$, 1, 1) <> SPACE$(1) THEN ' ignore other file data
|
||
|
cnt% = cnt% + 1
|
||
|
last$ = MID$(line$, 1, 20): DIR$ = MID$(line$, 26, 3)
|
||
|
IF MID$(line$, 40, 1) <> SPACE$(1) THEN ' found line with short and long name
|
||
|
SHFN$ = MID$(line$, 40, INSTR(40, line$, SPACE$(1)) - 1)
|
||
|
LGFN$ = MID$(line$, 53)
|
||
|
ELSE : SHFN$ = MID$(line$, 53): LGFN$ = "" ' found short name only
|
||
|
END IF
|
||
|
IF cnt% MOD 25 = 0 THEN ' pause every 25 files
|
||
|
COLOR 14: LOCATE 29, 27 "Press a key for more files!"
|
||
|
DO: LOOP UNTIL INKEY$ <> ""
|
||
|
CLS: COLOR 14: LOCATE 2, 4: PRINT Header$
|
||
|
END IF
|
||
|
COLOR 11: LOCATE (cnt% MOD 25) + 3, 4
|
||
|
{{Cl|PRINT USING}} tmp$; DIR$; SHFN$; LGFN$
|
||
|
LOCATE (cnt% MOD 25) + 3, 58: PRINT last$
|
||
|
END IF
|
||
|
LOOP
|
||
|
END IF
|
||
|
COLOR 10: LOCATE {{Cl|CSRLIN}} + 1, 27 "Total folders and files ="; cnt%
|
||
|
CLOSE #1
|
||
|
END SUB '' ''
|
||
|
|
||
|
{{CodeEnd}}
|
||
|
|
||
|
''Explanation:'' The above routine can also be used to place the filename info into string arrays by using the count variable cnt% to determine the index. Long filenames are normally returned by '''QB64'''. To keep older QBasic programs compatible, you may want to only use the short names when displaying the files on the screen.
|
||
|
|
||
|
|
||
|
|
||
|
{{PageSeeAlso}}
|
||
|
* [[SHELL]], [[_DONTWAIT]]
|
||
|
|
||
|
* [[FILELIST$ (function)]] (a better [[FILES]] function)
|
||
|
|
||
|
|
||
|
|
||
|
{{PageNavigation}}
|