1cdf0e10cSrcweir<?xml version="1.0" encoding="UTF-8"?> 2cdf0e10cSrcweir 3d33d0967SAndrew Rist<!--*********************************************************** 4cdf0e10cSrcweir * 5d33d0967SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 6d33d0967SAndrew Rist * or more contributor license agreements. See the NOTICE file 7d33d0967SAndrew Rist * distributed with this work for additional information 8d33d0967SAndrew Rist * regarding copyright ownership. The ASF licenses this file 9d33d0967SAndrew Rist * to you under the Apache License, Version 2.0 (the 10d33d0967SAndrew Rist * "License"); you may not use this file except in compliance 11d33d0967SAndrew Rist * with the License. You may obtain a copy of the License at 12cdf0e10cSrcweir * 13d33d0967SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 14cdf0e10cSrcweir * 15d33d0967SAndrew Rist * Unless required by applicable law or agreed to in writing, 16d33d0967SAndrew Rist * software distributed under the License is distributed on an 17d33d0967SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 18d33d0967SAndrew Rist * KIND, either express or implied. See the License for the 19d33d0967SAndrew Rist * specific language governing permissions and limitations 20d33d0967SAndrew Rist * under the License. 21cdf0e10cSrcweir * 22d33d0967SAndrew Rist ***********************************************************--> 23d33d0967SAndrew Rist 24cdf0e10cSrcweir<helpdocument version="1.0"> 25cdf0e10cSrcweir<meta> 26cdf0e10cSrcweir<topic id="textsbasicshared03020411xml" indexer="include" status="PUBLISH"> 27cdf0e10cSrcweir<title id="tit" xml-lang="en-US">MkDir Statement [Runtime]</title> 28cdf0e10cSrcweir<filename>/text/sbasic/shared/03020411.xhp</filename> 29cdf0e10cSrcweir</topic> 30cdf0e10cSrcweir</meta> 31cdf0e10cSrcweir<body> 32cdf0e10cSrcweir<section id="mkdir"> 33734551d2Smseidel<bookmark xml-lang="en-US" branch="index" id="bm_id3156421"> 34734551d2Smseidel<bookmark_value>MkDir statement</bookmark_value> 35cdf0e10cSrcweir</bookmark> 36*ef9a2fb8Smseidel<paragraph role="heading" id="hd_id3156421" xml-lang="en-US" level="1" l10n="U"><link href="text/sbasic/shared/03020411.xhp" name="MkDir Statement [Runtime]">MkDir Statement [Runtime]</link></paragraph> 37*ef9a2fb8Smseidel<paragraph role="paragraph" id="par_id3147000" xml-lang="en-US" l10n="U">Creates a new directory on a data medium.</paragraph> 38cdf0e10cSrcweir</section> 39*ef9a2fb8Smseidel<paragraph role="heading" id="hd_id3148520" xml-lang="en-US" level="2" l10n="U">Syntax:</paragraph> 40*ef9a2fb8Smseidel<paragraph role="code" id="par_id3155150" xml-lang="en-US" l10n="U">MkDir Text As String</paragraph> 41*ef9a2fb8Smseidel<paragraph role="heading" id="hd_id3156027" xml-lang="en-US" level="2" l10n="U">Parameters:</paragraph> 42*ef9a2fb8Smseidel<paragraph role="paragraph" id="par_id3153750" xml-lang="en-US" l10n="U"><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> 43*ef9a2fb8Smseidel<paragraph role="paragraph" id="par_id3153311" xml-lang="en-US" l10n="U">If the path is not determined, the directory is created in the current directory.</paragraph> 44cdf0e10cSrcweir<embed href="text/sbasic/shared/00000003.xhp#errorcode"/> 45cdf0e10cSrcweir<embed href="text/sbasic/shared/00000003.xhp#err5"/> 46cdf0e10cSrcweir<embed href="text/sbasic/shared/00000003.xhp#err76"/> 47*ef9a2fb8Smseidel<paragraph role="heading" id="hd_id3155388" xml-lang="en-US" level="2" l10n="U">Example:</paragraph> 48*ef9a2fb8Smseidel<paragraph role="code" id="par_id3148473" xml-lang="en-US" l10n="U">Sub ExampleFileIO</paragraph> 49*ef9a2fb8Smseidel<paragraph role="code" id="par_id3149762" xml-lang="en-US" l10n="CHG">' Example for functions of the file organization</paragraph> 50*ef9a2fb8Smseidel<paragraph role="code" id="par_id3145610" xml-lang="en-US" l10n="U">Const sFile1 as String = "file://c|/autoexec.bat"</paragraph> 51*ef9a2fb8Smseidel<paragraph role="code" id="par_id3147264" xml-lang="en-US" l10n="U">Const sDir1 as String = "file://c|/Temp"</paragraph> 52*ef9a2fb8Smseidel<paragraph role="code" id="par_id3149669" xml-lang="en-US" l10n="U">Const sSubDir1 as String ="Test"</paragraph> 53*ef9a2fb8Smseidel<paragraph role="code" id="par_id3148663" xml-lang="en-US" l10n="U">Const sFile2 as String = "Copied.tmp"</paragraph> 54*ef9a2fb8Smseidel<paragraph role="code" id="par_id3154071" xml-lang="en-US" l10n="U">Const sFile3 as String = "Renamed.tmp"</paragraph> 55*ef9a2fb8Smseidel<paragraph role="code" id="par_id3150792" xml-lang="en-US" l10n="U">Dim sFile as String</paragraph> 56*ef9a2fb8Smseidel<paragraph role="code" id="par_id3154366" xml-lang="en-US" l10n="U">sFile = sDir1 + "/" + sSubDir1</paragraph> 57*ef9a2fb8Smseidel<paragraph role="code" id="par_id3149204" xml-lang="en-US" l10n="U">ChDir( sDir1 )</paragraph> 58*ef9a2fb8Smseidel<paragraph role="code" id="par_id3154217" xml-lang="en-US" l10n="U">If Dir(sSubDir1,16)="" then ' Does the directory exist?</paragraph> 59*ef9a2fb8Smseidel<paragraph role="code" id="par_id3156423" xml-lang="en-US" l10n="U">MkDir sSubDir1</paragraph> 60*ef9a2fb8Smseidel<paragraph role="code" id="par_id3147228" xml-lang="en-US" l10n="U">MsgBox sFile,0,"Create directory"</paragraph> 61*ef9a2fb8Smseidel<paragraph role="code" id="par_id3153970" xml-lang="en-US" l10n="U">End If</paragraph> 62*ef9a2fb8Smseidel<paragraph role="code" id="par_id3148451" xml-lang="en-US" l10n="U">sFile = sFile + "/" + sFile2</paragraph> 63*ef9a2fb8Smseidel<paragraph role="code" id="par_id3155132" xml-lang="en-US" l10n="U">FileCopy sFile1 , sFile</paragraph> 64*ef9a2fb8Smseidel<paragraph role="code" id="par_id3153770" xml-lang="en-US" l10n="U">MsgBox fSysURL(CurDir()),0,"Current directory"</paragraph> 65*ef9a2fb8Smseidel<paragraph role="code" id="par_id3159154" xml-lang="en-US" l10n="U">MsgBox sFile & Chr(13) & FileDateTime( sFile ),0,"Creation time"</paragraph> 66*ef9a2fb8Smseidel<paragraph role="code" id="par_id3149484" xml-lang="en-US" l10n="U">MsgBox sFile & Chr(13)& FileLen( sFile ),0,"File length"</paragraph> 67*ef9a2fb8Smseidel<paragraph role="code" id="par_id3152885" xml-lang="en-US" l10n="U">MsgBox sFile & Chr(13)& GetAttr( sFile ),0,"File attributes"</paragraph> 68*ef9a2fb8Smseidel<paragraph role="code" id="par_id3152596" xml-lang="en-US" l10n="U">Name sFile as sDir1 + "/" + sSubDir1 + "/" + sFile3</paragraph> 69*ef9a2fb8Smseidel<paragraph role="code" id="par_id3153952" xml-lang="en-US" l10n="U">' Rename in the same directory</paragraph> 70*ef9a2fb8Smseidel<paragraph role="code" id="par_id3152576" xml-lang="en-US" l10n="U">sFile = sDir1 + "/" + sSubDir1 + "/" + sFile3</paragraph> 71*ef9a2fb8Smseidel<paragraph role="code" id="par_id3147426" xml-lang="en-US" l10n="U">SetAttr( sFile, 0 ) 'Delete all attributes</paragraph> 72*ef9a2fb8Smseidel<paragraph role="code" id="par_id3148647" xml-lang="en-US" l10n="U">MsgBox sFile & Chr(13) & GetAttr( sFile ),0,"New file attributes"</paragraph> 73*ef9a2fb8Smseidel<paragraph role="code" id="par_id3153363" xml-lang="en-US" l10n="U">Kill sFile</paragraph> 74*ef9a2fb8Smseidel<paragraph role="code" id="par_id3151113" xml-lang="en-US" l10n="U">RmDir sDir1 + "/" + sSubDir1</paragraph> 75*ef9a2fb8Smseidel<paragraph role="code" id="par_id3153157" xml-lang="en-US" l10n="U">end sub</paragraph> 76*ef9a2fb8Smseidel<paragraph role="code" id="par_id3150092" xml-lang="en-US" l10n="U">' Converts a system path in URL</paragraph> 77*ef9a2fb8Smseidel<paragraph role="code" id="par_id3147396" xml-lang="en-US" l10n="U">Function fSysURL( fSysFp as String ) as String</paragraph> 78*ef9a2fb8Smseidel<paragraph role="code" id="par_id3153878" xml-lang="en-US" l10n="U">Dim iPos As String</paragraph> 79*ef9a2fb8Smseidel<paragraph role="code" id="par_id3150420" xml-lang="en-US" l10n="U">iPos = 1</paragraph> 80*ef9a2fb8Smseidel<paragraph role="code" id="par_id3145253" xml-lang="en-US" l10n="U">iPos = Instr(iPos,fSysFp, getPathSeparator())</paragraph> 81*ef9a2fb8Smseidel<paragraph role="code" id="par_id3153415" xml-lang="en-US" l10n="U">do while iPos > 0</paragraph> 82*ef9a2fb8Smseidel<paragraph role="code" id="par_id3153512" xml-lang="en-US" l10n="U">mid( fSysFp, iPos , 1,"/")</paragraph> 83*ef9a2fb8Smseidel<paragraph role="code" id="par_id3146899" xml-lang="en-US" l10n="U">iPos = Instr(iPos+1,fSysFp, getPathSeparator())</paragraph> 84*ef9a2fb8Smseidel<paragraph role="code" id="par_id3145652" xml-lang="en-US" l10n="U">loop</paragraph> 85*ef9a2fb8Smseidel<paragraph role="code" id="par_id3156276" xml-lang="en-US" l10n="U">' the colon with DOS</paragraph> 86*ef9a2fb8Smseidel<paragraph role="code" id="par_id3146913" xml-lang="en-US" l10n="U">iPos = Instr(1,fSysFp,":")</paragraph> 87*ef9a2fb8Smseidel<paragraph role="code" id="par_id3145640" xml-lang="en-US" l10n="U">if iPos > 0 then mid( fSysFp, iPos , 1,"|")</paragraph> 88*ef9a2fb8Smseidel<paragraph role="code" id="par_id3155443" xml-lang="en-US" l10n="U">fSysURL = "file://" & fSysFp</paragraph> 89*ef9a2fb8Smseidel<paragraph role="code" id="par_id3148995" xml-lang="en-US" l10n="U">End Function</paragraph> 90cdf0e10cSrcweir</body> 91cdf0e10cSrcweir</helpdocument> 92