DIR$: Difference between revisions
Jump to navigation
Jump to search
Navigation:
Main Page with Articles and Tutorials
Keyword Reference - Alphabetical
Keyword Reference - By usage
Report a broken link
(Created page with "{{DISPLAYTITLE:_DIR$}} The _DIR$ function returns common paths in '''Windows''' only such as My Documents, My Pictures, My Music, Desktop. {{PageSyntax}} : {{Parameter|d$}} = _DIR$("{{Parameter|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...") |
No edit summary |
||
(4 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
{{DISPLAYTITLE:_DIR$}} | {{DISPLAYTITLE:_DIR$}} | ||
The | The '''_DIR$''' function returns common paths such as Documents, Pictures, Music, Desktop, etc. | ||
Line 7: | Line 7: | ||
{{ | {{PageParameters}} | ||
* ''folderspecification'' may be "desktop", " | * ''folderspecification'' may be "desktop", "downloads", "documents", "music", "video", "pictures", "appdata", "common program data", "local data", "program files", "program files (x86)", "temp", "home", "fonts", "user fonts". | ||
* 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 15: | Line 15: | ||
:: MY VIDEOS, VIDEO, VIDEOS, MOVIE, MOVIES, | :: MY VIDEOS, VIDEO, VIDEOS, MOVIE, MOVIES, | ||
:: DATA, APPDATA, APPLICATION DATA, PROGRAM DATA, LOCAL DATA, LOCALAPPDATA, LOCAL APPLICATION DATA, LOCAL PROGRAM DATA | :: DATA, APPDATA, APPLICATION DATA, PROGRAM DATA, LOCAL DATA, LOCALAPPDATA, LOCAL APPLICATION DATA, LOCAL PROGRAM DATA | ||
:: PROGRAMFILES, PROGRAMFILESX86, PROGRAMFILES X86, PROGRAM FILES X86, PROGRAM FILES 86, PROGRAMFILES (X86), PROGRAM FILES(X86), PROGRAMFILES(X86) | |||
:: FONT, USERFONT, USERFONTS, USER FONT | |||
:: USER, PROFILE, USERPROFILE, USER PROFILE | |||
{{PageDescription}} | {{PageDescription}} | ||
* The path returned ends with a backslash | * The path returned ends with a backslash on Windows and a forward-slash on Linux and macOS. | ||
* A nonexistent folder specification usually defaults to the Desktop folder path. | * A nonexistent folder specification usually defaults to the Desktop folder path. | ||
* In | |||
{{PageAvailability}} | |||
<!-- QB64 = a version or none, QBPE = a version or all, Platforms = yes or no --> | |||
<gallery widths="48px" heights="48px" mode="nolines"> | |||
File:Qb64.png|'''v1.1''' | |||
File:Qbpe.png|'''all''' | |||
File:Apix.png | |||
File:Win.png|'''yes''' | |||
File:Lnx.png|'''yes''' | |||
File:Osx.png|'''yes''' | |||
</gallery> | |||
<!-- additional availability notes go below here --> | |||
* In '''QB64-PE v3.11.0''' support for "font" & "user font" and full Linux and macOS support was added. | |||
{{PageExamples}} | {{PageExamples}} | ||
Example: Displaying default paths in Windows | ;Example: Displaying default paths in Windows. | ||
{{CodeStart}}{{Cl|PRINT}} "DESKTOP=" + _DIR$("desktop") | {{CodeStart}} | ||
{{Cl|PRINT}} "DOWNLOADS=" + {{Cl|_DIR$}}("download") | {{Cl|PRINT}} {{Text|<nowiki>"DESKTOP="</nowiki>|#FFB100}} + {{Cl|_DIR$}}({{Text|<nowiki>"desktop"</nowiki>|#FFB100}}) | ||
{{Cl|PRINT}} "DOCUMENTS=" + {{Cl|_DIR$}}("my documents") | {{Cl|PRINT}} {{Text|<nowiki>"DOWNLOADS="</nowiki>|#FFB100}} + {{Cl|_DIR$}}({{Text|<nowiki>"download"</nowiki>|#FFB100}}) | ||
{{Cl|PRINT}} "PICTURES=" + {{Cl|_DIR$}}("pictures") | {{Cl|PRINT}} {{Text|<nowiki>"DOCUMENTS="</nowiki>|#FFB100}} + {{Cl|_DIR$}}({{Text|<nowiki>"my documents"</nowiki>|#FFB100}}) | ||
{{Cl|PRINT}} "MUSIC=" + {{Cl|_DIR$}}("music") | {{Cl|PRINT}} {{Text|<nowiki>"PICTURES="</nowiki>|#FFB100}} + {{Cl|_DIR$}}({{Text|<nowiki>"pictures"</nowiki>|#FFB100}}) | ||
{{Cl|PRINT}} "VIDEO=" + {{Cl|_DIR$}}("video") | {{Cl|PRINT}} {{Text|<nowiki>"MUSIC="</nowiki>|#FFB100}} + {{Cl|_DIR$}}({{Text|<nowiki>"music"</nowiki>|#FFB100}}) | ||
{{Cl|PRINT}} "APPLICATION DATA=" + {{Cl|_DIR$}}("data") | {{Cl|PRINT}} {{Text|<nowiki>"VIDEO="</nowiki>|#FFB100}} + {{Cl|_DIR$}}({{Text|<nowiki>"video"</nowiki>|#FFB100}}) | ||
{{Cl|PRINT}} "LOCAL APPLICATION DATA=" + {{Cl|_DIR$}}("local application data" | {{Cl|PRINT}} {{Text|<nowiki>"APPLICATION DATA="</nowiki>|#FFB100}} + {{Cl|_DIR$}}({{Text|<nowiki>"data"</nowiki>|#FFB100}}) | ||
{{Cl|PRINT}} {{Text|<nowiki>"LOCAL APPLICATION DATA="</nowiki>|#FFB100}} + {{Cl|_DIR$}}({{Text|<nowiki>"local application data"</nowiki>|#FFB100}}) | |||
{{CodeEnd}} | {{CodeEnd}} | ||
{{OutputStart}}DESKTOP=C:\Documents and Settings\Administrator\Desktop\ | {{OutputStart}}DESKTOP=C:\Documents and Settings\Administrator\Desktop\ | ||
Line 41: | Line 58: | ||
VIDEO=C:\Documents and Settings\Administrator\My Documents\My Videos\ | VIDEO=C:\Documents and Settings\Administrator\My Documents\My Videos\ | ||
APPLICATION DATA=C:\Documents and Settings\Administrator\Application Data\ | APPLICATION DATA=C:\Documents and Settings\Administrator\Application Data\ | ||
LOCAL APPLICATION DATA=C:\Documents and Settings\Administrator\Local Settings\Application Data\ | LOCAL APPLICATION DATA=C:\Documents and Settings\Administrator\Local Settings\Application Data\ | ||
{{OutputEnd}} | {{OutputEnd}} | ||
Line 48: | Line 65: | ||
* [[_CWD$]] | * [[_CWD$]] | ||
* [[_STARTDIR$]] | * [[_STARTDIR$]] | ||
{{PageNavigation}} | {{PageNavigation}} |
Latest revision as of 00:04, 3 January 2024
The _DIR$ function returns common paths such as Documents, Pictures, Music, Desktop, etc.
Syntax
- d$ = _DIR$("folderspecification")
Parameters
- folderspecification may be "desktop", "downloads", "documents", "music", "video", "pictures", "appdata", "common program data", "local data", "program files", "program files (x86)", "temp", "home", "fonts", "user fonts".
- 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
- PROGRAMFILES, PROGRAMFILESX86, PROGRAMFILES X86, PROGRAM FILES X86, PROGRAM FILES 86, PROGRAMFILES (X86), PROGRAM FILES(X86), PROGRAMFILES(X86)
- FONT, USERFONT, USERFONTS, USER FONT
- USER, PROFILE, USERPROFILE, USER PROFILE
Description
- The path returned ends with a backslash on Windows and a forward-slash on Linux and macOS.
- A nonexistent folder specification usually defaults to the Desktop folder path.
Availability
- In QB64-PE v3.11.0 support for "font" & "user font" and full Linux and macOS support was added.
Examples
- Example
- Displaying default paths in Windows.
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