From 940b4d1848e8c70ab7642901a68594e8016caffc Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sat, 27 Apr 2024 18:51:28 +0200 Subject: Adding upstream version 1:7.0.4. Signed-off-by: Daniel Baumann --- .../source/text/sbasic/shared/03020404.xhp | 85 ++++++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 helpcontent2/source/text/sbasic/shared/03020404.xhp (limited to 'helpcontent2/source/text/sbasic/shared/03020404.xhp') diff --git a/helpcontent2/source/text/sbasic/shared/03020404.xhp b/helpcontent2/source/text/sbasic/shared/03020404.xhp new file mode 100644 index 000000000..7a763a9f2 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03020404.xhp @@ -0,0 +1,85 @@ + + + + + + + Dir Function + /text/sbasic/shared/03020404.xhp + + + + + + +
+ + Dir function + + + +Dir Function +Returns the name of a file, a directory, or all of the files and the directories on a drive or in a directory that match the specified search path. +
+ +Syntax: + +Dir [(Text As String) [, Attrib As Integer]] + + +Return value: +String + +Parameters: + Text: Any string expression that specifies the search path, directory or file. This argument can only be specified the first time that you call the Dir function. If you want, you can enter the path in URL notation. + Attrib: Any integer expression that specifies bitwise file attributes. The Dir function only returns files or directories that match the specified attributes. You can combine several attributes by adding the attribute values: +0 : Normal files. +16 : Returns the name of the directory only. +Use this attribute to check if a file or directory exists, or to determine all files and folders in a specific directory. +To check if a file exists, enter the complete path and name of the file. If the file or directory name does not exist, the Dir function returns a zero-length string (""). +To generate a list of all existing files in a specific directory, proceed as follows: The first time you call the Dir function, specify the complete search path for the files, for example, "D:\Files\*.ods". If the path is correct and the search finds at least one file, the Dir function returns the name of the first file that matches the search path. To return additional file names that match the path, call Dir again, but with no arguments. +To return directories only, use the attribute parameter. The same applies if you want to determine the name of a volume (for example, a hard drive partition). + + + + +Example: + +Sub ExampleDir +' Displays all files and directories +Dim sPath As String +Dim sDir As String, sValue As String + sDir="Directories:" + sPath = CurDir + sValue = Dir$(sPath + getPathSeparator + "*",16) + Do + If sValue <> "." And sValue <> ".." Then + If (GetAttr( sPath + getPathSeparator + sValue) And 16) >0 Then + ' Get the directories + sDir = sDir & chr(13) & sValue + End If + End If + sValue = Dir$ + Loop Until sValue = "" + MsgBox sDir,0,sPath +End Sub + + + +
-- cgit v1.2.3