Difference between revisions of "Zbex directory handling"

From CCARH Wiki
Jump to navigation Jump to search
(created page)
 
(added chapter navigator at top and bottom of page)
 
Line 1: Line 1:
__TOC__
+
{{ZbexChap
 +
  | before =  [[Zbex tables|Tables]]
 +
  | after = [[Zbex special variables and labels|Special variables and labels]]
 +
}}
 +
<center>__TOC__</center>
  
 
Zbex gives you two commands which relate to directories: <tt>getdir</tt> and <tt>createdir</tt>.  In addition, you can read the contents of a directory by opening it as a file.   
 
Zbex gives you two commands which relate to directories: <tt>getdir</tt> and <tt>createdir</tt>.  In addition, you can read the contents of a directory by opening it as a file.   
Line 88: Line 92:
 
         C:\RELEASE\INTERNET/rivet created  
 
         C:\RELEASE\INTERNET/rivet created  
 
         Ready for program
 
         Ready for program
 +
 +
 +
{{ZbexChap
 +
  | before =  [[Zbex tables|Tables]]
 +
  | after = [[Zbex special variables and labels|Special variables and labels]]
 +
}}

Latest revision as of 05:17, 20 October 2010

Previous chapter
Tables
Zbex
Manual
Next Chapter
Special variables and labels

Zbex gives you two commands which relate to directories: getdir and createdir. In addition, you can read the contents of a directory by opening it as a file.

getdir

The getdir statement will provide you with the path of the current directory. There is no way with Zbex to change the current directory. The following example will open the current directory, read its contents, and display them on the screen.

              Program 
        --------------------- 
        str curdir.80,rec.80 
   
        getdir curdir 
        open [1,1] curdir 
        loop 
          getf [1] rec 
          putc ~rec 
        repeat 
        run 
                     Execution 
        ------------------------------------- 
        ** S=8, P=25, L=239, M=452 ** 
        DISP         <DIR>     7-18-95 10:12p 
        FORMATS      <DIR>     8-10-95 11:01p 
        MKSLURS      <DIR>    11-01-95 10:08p 
        SPECS        <DIR>     7-18-95 10:11p 
        COMPRESS OLD    59427  7-05-95  3:12p 
        DECOMP   OLD    26037  7-05-95  3:12p 
        BUG      Z        197  7-05-95  3:12p 
        EXPAND   Z      28179 10-08-95 12:18a 
        MAKECFT  Z      66767 10-09-95  7:22a 
               9 Files(s) 
        Ready for program 

createdir

The createdir statement lets you create a new directory. The path to the new directory must already exist (you can create it, one sub-directory at a time). Zbex does not provide you with a means of removing directories (or removing files, either). The following example will create a new directory in the current directory.

              Program 
        --------------------- 
           str newdir.80,curdir.80 
           str rec.80,temp.80 
     
           getdir curdir 
        B: 
           putc Name of new directory?  
           getc newdir 
           temp = ucs(newdir)     /* for comparing with current names 
     
           Make sure that this directory doesn't already exist 
     
           open [1,1] curdir 
           loop 
             getf [1] rec 
             if rec{1} = " "      /* no more entries in directory 
               goto A 
             end 
             if rec{18} = ">"     /* looking for sub-directories 
               if rec con " " 
                 rec = rec{1,mpt-1}   /* keep only the name 
               end 
               if rec = temp 
                 putc This directory already exists 
                 close [1]        /* must close [1] so we can open it an 
                 goto B 
               end 
             end 
           repeat 
        A: 
           close [1] 
     
           Directory doesn't exist; try to create it.  
     
           newdir = curdir // "/" // newdir 
           createdir newdir 
           putc ~newdir  created 
           run 
                     Execution 
        ------------------------------------- 
        Name of new directory?  
        specs 
        This directory already exists 
        Name of new directory?  
        rivet 
        C:\RELEASE\INTERNET/rivet created 
        Ready for program


Previous chapter
Tables
Zbex
Manual
Next Chapter
Special variables and labels