summaryrefslogtreecommitdiffstats
path: root/helpcontent2/source/text/sbasic/shared/03020411.xhp
blob: 2051628f20a4c690c8d30af3c69269947315a8b5 (plain)
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
<?xml version="1.0" encoding="UTF-8"?>
<helpdocument version="1.0">
<!--
 * This file is part of the LibreOffice project.
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 *
 * This file incorporates work covered by the following license notice:
 *
 *   Licensed to the Apache Software Foundation (ASF) under one or more
 *   contributor license agreements. See the NOTICE file distributed
 *   with this work for additional information regarding copyright
 *   ownership. The ASF licenses this file to you under the Apache
 *   License, Version 2.0 (the "License"); you may not use this file
 *   except in compliance with the License. You may obtain a copy of
 *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
-->

<meta>
  <topic id="textsbasicshared03020411xml" indexer="include" status="PUBLISH">
    <title id="tit" xml-lang="en-US">MkDir Statement</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>


<h1 id="hd_id3156421" xml-lang="en-US"><link href="text/sbasic/shared/03020411.xhp" name="MkDir Statement">MkDir Statement</link></h1>
<paragraph role="paragraph" id="par_id971587473488701">
  <image src="media/helpimg/sbasic/MkDir_statement.svg" id="img_id4156296484514"><alt xml-lang="en-US" id="alt_id15152796484514">MkDir Statement diagram</alt></image>
</paragraph>
<paragraph id="par_id3147000" role="paragraph" xml-lang="en-US">Creates a new directory on a data medium.</paragraph>
</section>

<embed href="text/sbasic/shared/00000003.xhp#functsyntax"/>
<bascode>
<paragraph id="par_id3155150" role="bascode" xml-lang="en-US">MkDir path</paragraph>
</bascode>

<embed href="text/sbasic/shared/00000003.xhp#functparameters"/>
<paragraph id="par_id3153750" role="paragraph" xml-lang="en-US"> <emph>path:</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 id="par_id3153311" role="paragraph" xml-lang="en-US">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"/>

<embed href="text/sbasic/shared/00000003.xhp#functexample"/>
<bascode>
<paragraph id="par_idm1341385136" role="bascode" localize="false">Sub ExampleFileIO</paragraph>
<paragraph id="par_id3149762" role="bascode" xml-lang="en-US">' Example for functions of the file organization</paragraph>
<paragraph id="par_idm1341382112" role="bascode" localize="false">Const sFile1 As String = "file://c|/autoexec.bat"</paragraph>
<paragraph id="par_idm1341380848" role="bascode" localize="false">Const sDir1 As String = "file://c|/Temp"</paragraph>
<paragraph id="par_id3149669" role="bascode" xml-lang="en-US">Const sSubDir1 As String ="Test"</paragraph>
<paragraph id="par_id3148663" role="bascode" xml-lang="en-US">Const sFile2 As String = "Copied.tmp"</paragraph>
<paragraph id="par_id3154071" role="bascode" xml-lang="en-US">Const sFile3 As String = "Renamed.tmp"</paragraph>
<paragraph id="par_idm1341374400" role="bascode" localize="false">Dim sFile As String</paragraph>
<paragraph id="par_idm1341373168" role="bascode" localize="false">    sFile = sDir1 + "/" + sSubDir1</paragraph>
<paragraph id="par_idm1341371920" role="bascode" localize="false">    ChDir( sDir1 )</paragraph>
<paragraph id="par_id3154217" role="bascode" xml-lang="en-US">    If Dir(sSubDir1,16)="" Then ' Does the directory exist?</paragraph>
<paragraph id="par_idm1341368880" role="bascode" localize="false">        MkDir sSubDir1</paragraph>
<paragraph id="par_id3147228" role="bascode" xml-lang="en-US">        MsgBox sFile,0,"Create directory"</paragraph>
<paragraph id="par_idm1341365904" role="bascode" localize="false">    End If</paragraph>
<paragraph id="par_idm1341364672" role="bascode" localize="false">    sFile = sFile + "/" + sFile2</paragraph>
<paragraph id="par_idm1341363424" role="bascode" localize="false">    FileCopy sFile1 , sFile</paragraph>
<paragraph id="par_id3153770" role="bascode" xml-lang="en-US">    MsgBox fSysURL(CurDir()),0,"Current directory"</paragraph>
<paragraph id="par_id3159154" role="bascode" xml-lang="en-US">    MsgBox sFile &amp; Chr(13) &amp; FileDateTime( sFile ),0,"Creation time"</paragraph>
<paragraph id="par_id3149484" role="bascode" xml-lang="en-US">    MsgBox sFile &amp; Chr(13)&amp; FileLen( sFile ),0,"File length"</paragraph>
<paragraph id="par_id3152885" role="bascode" xml-lang="en-US">    MsgBox sFile &amp; Chr(13)&amp; GetAttr( sFile ),0,"File attributes"</paragraph>
<paragraph id="par_idm1341354896" role="bascode" localize="false">    Name sFile As sDir1 + "/" + sSubDir1 + "/" + sFile3</paragraph>
<paragraph id="par_id3153952" role="bascode" xml-lang="en-US">    ' Rename in the same directory</paragraph>
<paragraph id="par_idm1341351856" role="bascode" localize="false">    sFile = sDir1 + "/" + sSubDir1 + "/" + sFile3</paragraph>
<paragraph id="par_id3147426" role="bascode" xml-lang="en-US">    SetAttr( sFile, 0 ) 'Delete all attributes</paragraph>
<paragraph id="par_id3148647" role="bascode" xml-lang="en-US">    MsgBox sFile &amp; Chr(13) &amp; GetAttr( sFile ),0,"New file attributes"</paragraph>
<paragraph id="par_idm1341346992" role="bascode" localize="false">    Kill sFile</paragraph>
<paragraph id="par_idm1341345760" role="bascode" localize="false">    RmDir sDir1 + "/" + sSubDir1</paragraph>
<paragraph id="par_idm1341344512" role="bascode" localize="false">End Sub</paragraph>
<paragraph id="par_id3153157" role="bascode" localize="false"> </paragraph>
<paragraph id="par_id3150092" role="bascode" xml-lang="en-US">' Converts a system path in URL</paragraph>
<paragraph id="par_idm1341100304" role="bascode" localize="false">Function fSysURL( fSysFp As String ) As String</paragraph>
<paragraph id="par_idm1341099040" role="bascode" localize="false">Dim iPos As String</paragraph>
<paragraph id="par_idm1341097808" role="bascode" localize="false">    iPos = 1</paragraph>
<paragraph id="par_idm1341096576" role="bascode" localize="false">    iPos = Instr(iPos,fSysFp, getPathSeparator())</paragraph>
<paragraph id="par_idm1341095312" role="bascode" localize="false">    Do While iPos &gt; 0</paragraph>
<paragraph id="par_idm1341093984" role="bascode" localize="false">        Mid( fSysFp, iPos , 1,"/")</paragraph>
<paragraph id="par_idm1341092768" role="bascode" localize="false">        iPos = Instr(iPos+1,fSysFp, getPathSeparator())</paragraph>
<paragraph id="par_idm1341091504" role="bascode" localize="false">    Loop</paragraph>
<paragraph id="par_id3156276" role="bascode" xml-lang="en-US">    ' the colon with DOS</paragraph>
<paragraph id="par_idm1341088544" role="bascode" localize="false">    iPos = Instr(1,fSysFp,":")</paragraph>
<paragraph id="par_idm1341087296" role="bascode" localize="false">    If iPos &gt; 0 Then Mid( fSysFp, iPos , 1,"|")</paragraph>
<paragraph id="par_idm1341085952" role="bascode" localize="false">    fSysURL = "file://" &amp; fSysFp</paragraph>
<paragraph id="par_idm1341084688" role="bascode" localize="false">End Function</paragraph>
</bascode>

</body>
</helpdocument>