home *** CD-ROM | disk | FTP | other *** search
/ Chip 2003 December / Chip_2003-12_cd2.bin / oo / download / f_0019 / sbasic.jar / text / sbasic / common / 03020404.xml < prev    next >
Extensible Markup Language  |  2003-01-16  |  5KB  |  65 lines

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <html><head><title>Funkce Dir [Runtime]</title><meta name="filename" content="text/sbasic/common/03020404"/><meta name="language" content="en-US"/><help:css-file-link xmlns:help="http://openoffice.org/2000/help"/><!--The CSS style header method for setting styles--><style type="text/css">
  3.  
  4.         p.P1{
  5.                 }
  6.         p.P2{
  7.                 }
  8.         span.T1{
  9.                 font-weight:bold;}
  10.         </style></head><body>
  11.   
  12.   
  13.   <help:to-be-embedded Eid="dir" xmlns:help="http://openoffice.org/2000/help">
  14.   <p class="Head1"><help:link Id="66557">Funkce Dir [Runtime]</help:link></p>
  15.   <p class="Paragraph">Vr├ít├¡ n├ízev souboru, adres├í┼Öe nebo v┼íechny soubory a slo┼╛ky na jednotce nebo v adres├í┼Öi, kter├╜ je shodn├╜ se zadanou cestou pro vyhled├ív├ín├¡.</p>
  16.   </help:to-be-embedded>
  17.   <p class="Paragraph"><span class="T1">Syntaxe</span>:</p>
  18.   <p class="Paragraph">Dir [(Text typu String) [, Atribut typu Integer]] <help:key-word value="Dir" tag="kw66557_1" xmlns:help="http://openoffice.org/2000/help"/></p>
  19.   <p class="Paragraph"><span class="T1">Vr├ícen├í hodnota</span>:</p>
  20.   <p class="Paragraph">Typu String</p>
  21.   <p class="Paragraph"><span class="T1">Parametr</span>:</p>
  22.   <p class="Paragraph">Text: Libovoln├╜ ┼Öet─¢zec, kter├╜ ur─ìuje cestu, adres├í┼Ö nebo soubor pro vyhled├ív├ín├¡. Tento argument je nutno zadat pouze p┼Öi prvn├¡m vol├ín├¡ funkce Dir. Jako parametr lze tak├⌐ pou┼╛├¡t <help:link Id="66636" Eid="urllocal" xmlns:help="http://openoffice.org/2000/help">adresu URL</help:link>.</p>
  23.   <p class="Paragraph">Atribut: Libovoln├╜ celo─ì├¡seln├╜ v├╜raz, kter├╜ ur─ìuje atributy souboru pro jednotliv├⌐ bity. Funkce Dir vr├ít├¡ pouze soubory nebo adres├í┼Öe, kter├⌐ odpov├¡daj├¡ zadan├╜m atribut┼»m. R┼»zn├⌐ atributy lze kombinovat p┼Öid├ín├¡m hodnot atribut┼»:</p>
  24.   <p class="P2">Atribut:</p>
  25.   <p class="Paragraph">0 : Norm├íln├¡ soubory</p>
  26.   <p class="Paragraph">2 : Skryt├⌐ soubory</p>
  27.   <p class="Paragraph">4 : Syst├⌐mov├⌐ soubory</p>
  28.   <p class="Paragraph">8 : Vr├ít├¡ n├ízev svazku.</p>
  29.   <p class="Paragraph">16 : Vr├ít├¡ pouze n├ízev adres├í┼Öe.</p>
  30.   <p class="Paragraph">Touto funkc├¡ lze ov─¢┼Öit, zda soubor nebo adres├í┼Ö existuje, nebo ji lze vyu┼╛├¡t k vyhled├ín├¡ v┼íech soubor┼» a slo┼╛ek v ur─ìit├⌐m adres├í┼Öi.</p>
  31.   <p class="Paragraph">Chcete-li ov─¢┼Öit, zda soubor existuje, zadejte ├║pln├╜ n├ízev cesty a n├ízev souboru. Pokud funkce Dir vr├ít├¡ n├ízev, adres├í┼Ö nebo soubor existuje. Pokud se ┼╛├ídn├⌐ n├ízvy soubor┼» nebo adres├í┼Ö┼» neshoduj├¡, vr├ít├¡ funkce Dir ┼Öet─¢zec s nulovou d├⌐lkou ("").</p>
  32.   <p class="Paragraph">Chcete-li vytvo┼Öit seznam v┼íech soubor┼», kter├⌐ se nach├ízej├¡ v ur─ìit├⌐m adres├í┼Öi, postupujte n├ísleduj├¡c├¡m zp┼»sobem: P┼Öi prvn├¡m vol├ín├¡ funkce Dir zadejte ├║plnou cestu pro vyhled├ín├¡ soubor┼», nap┼Ö. D:\OFFICE4\*.SDW. Pokud je cesta spr├ívn├í a byl nalezen alespo┼ê jeden soubor, vr├ít├¡ funkce n├ízev prvn├¡ho souboru, kter├╜ se shoduje s vyhled├ívanou cestou. Chcete-li, aby funkce vr├ítila v┼íechny dal┼í├¡ soubory, kter├⌐ se shoduj├¡ s n├ízvem cesty, volejte funkci Dir bez argument┼». Pokud funkce Dir vr├ít├¡ ┼Öet─¢zec s nulou d├⌐lkou (""), neexistuj├¡ ┼╛├ídn├⌐ n├ízvy soubory, jejich┼╛ n├ízvy by se shodovaly s krit├⌐rii pro hled├ín├¡.</p>
  33.   <p class="Paragraph">Chcete-li, aby funkce vr├ítila pouze adres├í┼Öe, pou┼╛ijte parametr atributu. Stejn├╜ postup pou┼╛ijte, pokud chcete ur─ìit n├ízev svazku (nap┼Ö. odd├¡lu na pevn├⌐m disku).</p>
  34.   <p class="P2">P┼Ö├¡klad:</p>
  35.   <p class="PropText">Sub ExampleDir</p>
  36.   <p class="PropText">REM Displays all files and directories</p>
  37.   <p class="PropText">Dim sFile as String, sPath As String</p>
  38.   <p class="PropText">Dim sDir as String, sValue as String</p>
  39.   <p class="PropText">Dim iFIle as Integer</p>
  40.   <p class="PropText">sFile= "Files: "</p>
  41.   <p class="PropText">sDir="Directories:"</p>
  42.   <p class="PropText">iFile = 0</p>
  43.   <p class="PropText">sPath = CurDir</p>
  44.   <p class="PropText">sValue = Dir$(sPath,22) <text:s text:c="2" xmlns:text="http://openoffice.org/2000/text"/>REM 16 + 2 + 4</p>
  45.   <p class="PropText">Do</p>
  46.   <p class="PropText">If sValue <> "." and sValue <> ".." Then</p>
  47.   <p class="PropText">if (GetAttr( sPath + getPathSeparator + sValue) AND 16) >0 then</p>
  48.   <p class="PropText">REM here the directories</p>
  49.   <p class="PropText">sDir = sDir & chr(13) & sValue</p>
  50.   <p class="PropText">else</p>
  51.   <p class="PropText">REM here the files</p>
  52.   <p class="PropText"/>
  53.   <p class="PropText">if iFile Mod 3 = 0 then sFile = sFile + Chr(13)</p>
  54.   <p class="PropText">iFile = iFile + 1</p>
  55.   <p class="PropText">sFile = sFile + sValue &"; "</p>
  56.   <p class="PropText">End If</p>
  57.   <p class="PropText">End If</p>
  58.   <p class="PropText">sValue = Dir$</p>
  59.   <p class="PropText">Loop Until sValue = ""</p>
  60.   <p class="PropText">MsgBox sDir,0,sPath</p>
  61.   <p class="PropText">MsgBox "" & iFile & " " & sFile,0,sPath</p>
  62.   <p class="PropText">End sub</p>
  63.   <p class="PropText"/>
  64.  </body></html>
  65.