Difference between revisions of "DIR$"

From QB64 Wiki
Jump to navigation Jump to search
imported>Clippy
m
(Added missing ")" in example #1)
(3 intermediate revisions by 3 users not shown)
Line 1: Line 1:
{{DISPLAYTITLE:_DIR$}}
{{DISPLAYTITLE:_DIR$}}
The '''_DIR$''' function returns common paths in Windows only such as My Documents, My Pictures, My Music, Desktop.
The [[_DIR$]] function returns common paths in '''Windows''' only such as My Documents, My Pictures, My Music, Desktop.




{{PageSyntax}}
{{PageSyntax}}
::: d$ = '''_DIR$('''"''folderspecification''"''')'''
: {{Parameter|d$}} = [[_DIR$]]("{{Parameter|folderspecification}}")




{{Parameters}}
{{PageParameters}}
* ''folder specification'' may be "desktop", "download", "documents", "music", "video", "pictures", "appdata", "program data", "local data".
* ''folderspecification'' may be "desktop", "download", "documents", "music", "video", "pictures", "appdata", "program data", "local data".
* Some variation is accepted for the folder specification:
* Some variation is accepted for the folder specification:
:: MY DOCUMENTS, TEXT, DOCUMENT, DOCUMENTS, DOWNLOAD, DOWNLOADS
:: MY DOCUMENTS, TEXT, DOCUMENT, DOCUMENTS, DOWNLOAD, DOWNLOADS
Line 18: Line 18:


{{PageDescription}}
{{PageDescription}}
* The path returned will always end with a backslash (Windows only).
* The path returned ends with a backslash (Windows).
* A nonexistent folder specification usually defaults to the Desktop folder path.
* A nonexistent folder specification usually defaults to the Desktop folder path.
* '''Windows OS only!''' Linux or MacOS it'll always return "./"
* In Linux and macOS the function always returns '''"./"'''




Example:
{{PageExamples}}
Example: Displaying default paths in Windows only.
{{CodeStart}}{{Cl|PRINT}} "DESKTOP=" + _DIR$("desktop")
{{CodeStart}}{{Cl|PRINT}} "DESKTOP=" + _DIR$("desktop")
{{Cl|PRINT}} "DOWNLOADS=" + {{Cl|_DIR$}}("download")
{{Cl|PRINT}} "DOWNLOADS=" + {{Cl|_DIR$}}("download")
Line 31: Line 32:
{{Cl|PRINT}} "VIDEO=" + {{Cl|_DIR$}}("video")
{{Cl|PRINT}} "VIDEO=" + {{Cl|_DIR$}}("video")
{{Cl|PRINT}} "APPLICATION DATA=" + {{Cl|_DIR$}}("data")
{{Cl|PRINT}} "APPLICATION DATA=" + {{Cl|_DIR$}}("data")
{{Cl|PRINT}} "LOCAL APPLICATION DATA=" + {{Cl|_DIR$}}("local application data"
{{Cl|PRINT}} "LOCAL APPLICATION DATA=" + {{Cl|_DIR$}}("local application data")
{{CodeEnd}}
{{CodeEnd}}
{{OutputStart}}DESKTOP=C:\Documents and Settings\Administrator\Desktop\
{{OutputStart}}DESKTOP=C:\Documents and Settings\Administrator\Desktop\

Revision as of 09:26, 24 July 2021

The _DIR$ function returns common paths in Windows only such as My Documents, My Pictures, My Music, Desktop.


Syntax

d$ = _DIR$("folderspecification")


Parameters

  • folderspecification may be "desktop", "download", "documents", "music", "video", "pictures", "appdata", "program data", "local data".
  • Some variation is accepted for the folder specification:
MY DOCUMENTS, TEXT, DOCUMENT, DOCUMENTS, DOWNLOAD, DOWNLOADS
MY MUSIC, MUSIC, AUDIO, SOUND, SOUNDS
MY PICTURES, PICTURE, PICTURES, IMAGE, IMAGES, PHOTO, PHOTOS, DCIM, CAMERA, CAMERA ROLL
MY VIDEOS, VIDEO, VIDEOS, MOVIE, MOVIES,
DATA, APPDATA, APPLICATION DATA, PROGRAM DATA, LOCAL DATA, LOCALAPPDATA, LOCAL APPLICATION DATA, LOCAL PROGRAM DATA


Description

  • The path returned ends with a backslash (Windows).
  • A nonexistent folder specification usually defaults to the Desktop folder path.
  • In Linux and macOS the function always returns "./"


Examples

Example: Displaying default paths in Windows only.

PRINT "DESKTOP=" + _DIR$("desktop") PRINT "DOWNLOADS=" + _DIR$("download") PRINT "DOCUMENTS=" + _DIR$("my documents") PRINT "PICTURES=" + _DIR$("pictures") PRINT "MUSIC=" + _DIR$("music") PRINT "VIDEO=" + _DIR$("video") PRINT "APPLICATION DATA=" + _DIR$("data") PRINT "LOCAL APPLICATION DATA=" + _DIR$("local application data")

DESKTOP=C:\Documents and Settings\Administrator\Desktop\ DOWNLOADS=C:\Documents and Settings\Administrator\Downloads\ DOCUMENTS=C:\Documents and Settings\Administrator\My Documents\ PICTURES=C:\Documents and Settings\Administrator\My Documents\My Pictures\ MUSIC=C:\Documents and Settings\Administrator\My Documents\My Music\ VIDEO=C:\Documents and Settings\Administrator\My Documents\My Videos\ APPLICATION DATA=C:\Documents and Settings\Administrator\Application Data\ LOCAL APPLICATION DATA=C:\Documents and Settings\Administrator\Local Settings\Application Data\


See also



Navigation:
Keyword Reference - Alphabetical
Keyword Reference - By Usage
Main Wiki Page