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
|
<?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>
<paragraph id="hd_id3156421" role="heading" level="1" xml-lang="en-US"><link href="text/sbasic/shared/03020411.xhp" name="MkDir Statement">MkDir Statement</link></paragraph>
<paragraph id="par_id3147000" role="paragraph" xml-lang="en-US">Creates a new directory on a data medium.</paragraph>
</section>
<paragraph id="hd_id3148520" role="heading" level="2" xml-lang="en-US">Syntax:</paragraph>
<bascode>
<paragraph id="par_id3155150" role="bascode" xml-lang="en-US">MkDir Text As String</paragraph>
</bascode>
<paragraph id="hd_id3156027" role="heading" level="2" xml-lang="en-US">Parameters:</paragraph>
<paragraph id="par_id3153750" role="paragraph" xml-lang="en-US"> <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 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"/>
<paragraph id="hd_id3155388" role="heading" level="2" xml-lang="en-US">Example:</paragraph>
<bascode>
<paragraph id="par_idm1341385136" role="bascode" localize="false" xml-lang="en-US">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" xml-lang="en-US">Const sFile1 As String = "file://c|/autoexec.bat"</paragraph>
<paragraph id="par_idm1341380848" role="bascode" localize="false" xml-lang="en-US">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" xml-lang="en-US">Dim sFile As String</paragraph>
<paragraph id="par_idm1341373168" role="bascode" localize="false" xml-lang="en-US"> sFile = sDir1 + "/" + sSubDir1</paragraph>
<paragraph id="par_idm1341371920" role="bascode" localize="false" xml-lang="en-US"> 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" xml-lang="en-US"> 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" xml-lang="en-US"> End If</paragraph>
<paragraph id="par_idm1341364672" role="bascode" localize="false" xml-lang="en-US"> sFile = sFile + "/" + sFile2</paragraph>
<paragraph id="par_idm1341363424" role="bascode" localize="false" xml-lang="en-US"> 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 & Chr(13) & FileDateTime( sFile ),0,"Creation time"</paragraph>
<paragraph id="par_id3149484" role="bascode" xml-lang="en-US"> MsgBox sFile & Chr(13)& FileLen( sFile ),0,"File length"</paragraph>
<paragraph id="par_id3152885" role="bascode" xml-lang="en-US"> MsgBox sFile & Chr(13)& GetAttr( sFile ),0,"File attributes"</paragraph>
<paragraph id="par_idm1341354896" role="bascode" localize="false" xml-lang="en-US"> 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" xml-lang="en-US"> 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 & Chr(13) & GetAttr( sFile ),0,"New file attributes"</paragraph>
<paragraph id="par_idm1341346992" role="bascode" localize="false" xml-lang="en-US"> Kill sFile</paragraph>
<paragraph id="par_idm1341345760" role="bascode" localize="false" xml-lang="en-US"> RmDir sDir1 + "/" + sSubDir1</paragraph>
<paragraph id="par_idm1341344512" role="bascode" localize="false" xml-lang="en-US">End Sub</paragraph>
<paragraph id="par_id3153157" role="bascode" localize="false" xml-lang="en-US"> </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" xml-lang="en-US">Function fSysURL( fSysFp As String ) As String</paragraph>
<paragraph id="par_idm1341099040" role="bascode" localize="false" xml-lang="en-US">Dim iPos As String</paragraph>
<paragraph id="par_idm1341097808" role="bascode" localize="false" xml-lang="en-US"> iPos = 1</paragraph>
<paragraph id="par_idm1341096576" role="bascode" localize="false" xml-lang="en-US"> iPos = Instr(iPos,fSysFp, getPathSeparator())</paragraph>
<paragraph id="par_idm1341095312" role="bascode" localize="false" xml-lang="en-US"> Do While iPos > 0</paragraph>
<paragraph id="par_idm1341093984" role="bascode" localize="false" xml-lang="en-US"> Mid( fSysFp, iPos , 1,"/")</paragraph>
<paragraph id="par_idm1341092768" role="bascode" localize="false" xml-lang="en-US"> iPos = Instr(iPos+1,fSysFp, getPathSeparator())</paragraph>
<paragraph id="par_idm1341091504" role="bascode" localize="false" xml-lang="en-US"> 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" xml-lang="en-US"> iPos = Instr(1,fSysFp,":")</paragraph>
<paragraph id="par_idm1341087296" role="bascode" localize="false" xml-lang="en-US"> If iPos > 0 Then Mid( fSysFp, iPos , 1,"|")</paragraph>
<paragraph id="par_idm1341085952" role="bascode" localize="false" xml-lang="en-US"> fSysURL = "file://" & fSysFp</paragraph>
<paragraph id="par_idm1341084688" role="bascode" localize="false" xml-lang="en-US">End Function</paragraph>
</bascode>
</body>
</helpdocument>
|