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