1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
|
<?xml version="1.0" encoding="UTF-8"?>
<!--
***********************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* This file is part of OpenOffice.org.
*
* OpenOffice.org is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 3
* only, as published by the Free Software Foundation.
*
* OpenOffice.org is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License version 3 for more details
* (a copy is included in the LICENSE file that accompanied this code).
*
* You should have received a copy of the GNU Lesser General Public License
* version 3 along with OpenOffice.org. If not, see
* <http://www.openoffice.org/license.html>
* for a copy of the LGPLv3 License.
*
************************************************************************
-->
<helpdocument version="1.0">
<meta>
<topic id="textsbasicshared03020411xml" indexer="include" status="PUBLISH">
<title id="tit" xml-lang="en-US">MkDir Statement [Runtime]</title>
<filename>/text/sbasic/shared/03020411.xhp</filename>
</topic>
</meta>
<body>
<section id="mkdir">
<bookmark xml-lang="en-US" branch="index" id="bm_id3156421"><bookmark_value>MkDir statement</bookmark_value>
</bookmark>
<paragraph role="heading" id="hd_id3156421" xml-lang="en-US" level="1" l10n="U" oldref="1"><link href="text/sbasic/shared/03020411.xhp" name="MkDir Statement [Runtime]">MkDir Statement [Runtime]</link></paragraph>
<paragraph role="paragraph" id="par_id3147000" xml-lang="en-US" l10n="U" oldref="2">Creates a new directory on a data medium.</paragraph>
</section>
<paragraph role="heading" id="hd_id3148520" xml-lang="en-US" level="2" l10n="U" oldref="3">Syntax:</paragraph>
<bascode>
<paragraph role="bascode" id="par_id3155150" xml-lang="en-US" l10n="U" oldref="4">MkDir Text As String</paragraph>
</bascode>
<paragraph role="heading" id="hd_id3156027" xml-lang="en-US" level="2" l10n="U" oldref="5">Parameters:</paragraph>
<paragraph role="paragraph" id="par_id3153750" xml-lang="en-US" l10n="U" oldref="6">
<emph>Text:</emph> Any string expression that specifies the name and path of the directory to be created. You can also use <link href="text/sbasic/shared/00000002.xhp" name="URL notation">URL notation</link>.</paragraph>
<paragraph role="paragraph" id="par_id3153311" xml-lang="en-US" l10n="U" oldref="7">If the path is not determined, the directory is created in the current directory.</paragraph>
<embed href="text/sbasic/shared/00000003.xhp#errorcode"/>
<embed href="text/sbasic/shared/00000003.xhp#err5"/>
<embed href="text/sbasic/shared/00000003.xhp#err76"/>
<paragraph role="heading" id="hd_id3155388" xml-lang="en-US" level="2" l10n="U" oldref="8">Example:</paragraph>
<bascode>
<paragraph role="bascode" localize="false" xml-lang="en-US">Sub ExampleFileIO</paragraph>
<paragraph role="bascode" id="par_id3149762" xml-lang="en-US" l10n="CHG" oldref="10">' Example for functions of the file organization</paragraph>
<paragraph role="bascode" localize="false" xml-lang="en-US">Const sFile1 As String = "file://c|/autoexec.bat"</paragraph>
<paragraph role="bascode" localize="false" xml-lang="en-US">Const sDir1 As String = "file://c|/Temp"</paragraph>
<paragraph role="bascode" id="par_id3149669" xml-lang="en-US" l10n="U" oldref="13">Const sSubDir1 As String ="Test"</paragraph>
<paragraph role="bascode" id="par_id3148663" xml-lang="en-US" l10n="U" oldref="14">Const sFile2 As String = "Copied.tmp"</paragraph>
<paragraph role="bascode" id="par_id3154071" xml-lang="en-US" l10n="U" oldref="15">Const sFile3 As String = "Renamed.tmp"</paragraph>
<paragraph role="bascode" localize="false" xml-lang="en-US">Dim sFile As String</paragraph>
<paragraph role="bascode" localize="false" xml-lang="en-US"> sFile = sDir1 + "/" + sSubDir1</paragraph>
<paragraph role="bascode" localize="false" xml-lang="en-US"> ChDir( sDir1 )</paragraph>
<paragraph role="bascode" id="par_id3154217" xml-lang="en-US" l10n="U" oldref="19"> If Dir(sSubDir1,16)="" Then ' Does the directory exist?</paragraph>
<paragraph role="bascode" localize="false" xml-lang="en-US"> MkDir sSubDir1</paragraph>
<paragraph role="bascode" id="par_id3147228" xml-lang="en-US" l10n="U" oldref="21"> MsgBox sFile,0,"Create directory"</paragraph>
<paragraph role="bascode" localize="false" xml-lang="en-US"> End If</paragraph>
<paragraph role="bascode" localize="false" xml-lang="en-US"> sFile = sFile + "/" + sFile2</paragraph>
<paragraph role="bascode" localize="false" xml-lang="en-US"> FileCopy sFile1 , sFile</paragraph>
<paragraph role="bascode" id="par_id3153770" xml-lang="en-US" l10n="U" oldref="26"> MsgBox fSysURL(CurDir()),0,"Current directory"</paragraph>
<paragraph role="bascode" id="par_id3159154" xml-lang="en-US" l10n="U" oldref="27"> MsgBox sFile & Chr(13) & FileDateTime( sFile ),0,"Creation time"</paragraph>
<paragraph role="bascode" id="par_id3149484" xml-lang="en-US" l10n="U" oldref="28"> MsgBox sFile & Chr(13)& FileLen( sFile ),0,"File length"</paragraph>
<paragraph role="bascode" id="par_id3152885" xml-lang="en-US" l10n="U" oldref="29"> MsgBox sFile & Chr(13)& GetAttr( sFile ),0,"File attributes"</paragraph>
<paragraph role="bascode" localize="false" xml-lang="en-US"> Name sFile As sDir1 + "/" + sSubDir1 + "/" + sFile3</paragraph>
<paragraph role="bascode" id="par_id3153952" xml-lang="en-US" l10n="U" oldref="31"> ' Rename in the same directory</paragraph>
<paragraph role="bascode" localize="false" xml-lang="en-US"> sFile = sDir1 + "/" + sSubDir1 + "/" + sFile3</paragraph>
<paragraph role="bascode" id="par_id3147426" xml-lang="en-US" l10n="U" oldref="34"> SetAttr( sFile, 0 ) 'Delete all attributes</paragraph>
<paragraph role="bascode" id="par_id3148647" xml-lang="en-US" l10n="U" oldref="35"> MsgBox sFile & Chr(13) & GetAttr( sFile ),0,"New file attributes"</paragraph>
<paragraph role="bascode" localize="false" xml-lang="en-US"> Kill sFile</paragraph>
<paragraph role="bascode" localize="false" xml-lang="en-US"> RmDir sDir1 + "/" + sSubDir1</paragraph>
<paragraph role="bascode" localize="false" xml-lang="en-US">End Sub</paragraph>
<paragraph role="bascode" id="par_id3153157" xml-lang="en-US" localize="false"> </paragraph>
<paragraph role="bascode" id="par_id3150092" xml-lang="en-US" l10n="U" oldref="40">' Converts a system path in URL</paragraph>
<paragraph role="bascode" localize="false" xml-lang="en-US">Function fSysURL( fSysFp As String ) As String</paragraph>
<paragraph role="bascode" localize="false" xml-lang="en-US">Dim iPos As String</paragraph>
<paragraph role="bascode" localize="false" xml-lang="en-US"> iPos = 1</paragraph>
<paragraph role="bascode" localize="false" xml-lang="en-US"> iPos = Instr(iPos,fSysFp, getPathSeparator())</paragraph>
<paragraph role="bascode" localize="false" xml-lang="en-US"> Do While iPos > 0</paragraph>
<paragraph role="bascode" localize="false" xml-lang="en-US"> Mid( fSysFp, iPos , 1,"/")</paragraph>
<paragraph role="bascode" localize="false" xml-lang="en-US"> iPos = Instr(iPos+1,fSysFp, getPathSeparator())</paragraph>
<paragraph role="bascode" localize="false" xml-lang="en-US"> Loop</paragraph>
<paragraph role="bascode" id="par_id3156276" xml-lang="en-US" l10n="U" oldref="49"> ' the colon with DOS</paragraph>
<paragraph role="bascode" localize="false" xml-lang="en-US"> iPos = Instr(1,fSysFp,":")</paragraph>
<paragraph role="bascode" localize="false" xml-lang="en-US"> If iPos > 0 Then Mid( fSysFp, iPos , 1,"|")</paragraph>
<paragraph role="bascode" localize="false" xml-lang="en-US"> fSysURL = "file://" & fSysFp</paragraph>
<paragraph role="bascode" localize="false" xml-lang="en-US">End Function</paragraph>
</bascode>
</body>
</helpdocument>
|