home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / magazine / dbms_mag / 9107 / olympia2 < prev    next >
Text File  |  1991-05-20  |  2KB  |  108 lines

  1.  
  2. ***************************************************************
  3. * Program: Cdir.prg
  4. * Author : P.L. Olympia, Platinum Software International
  5. * Purpose: Demonstrates use of DOS and file functions from the
  6. *        :  Jeff Davis Library. Program shows a graphical directory
  7. *        :  tree and changes the default directory to the one
  8. *        :  selected by the user.
  9. * Syntax : C>Cdir
  10. * Notes  : From DBMS Set Expert On column, 07/91
  11. ***************************************************************
  12.  
  13. # include string.hdr
  14. # include system.hdr
  15. # include jdfil.hdr
  16. # include jdio.hdr
  17. # include jddos.hdr
  18.  
  19. DBFDEF Jddir
  20.   CHAR(12)  DirName
  21.   CHAR(32)  DirKey
  22.   UINT(3)   LevelMax
  23. ENDDEF
  24.  
  25. DBFDEF JDDIRPIC
  26.   CHAR(64) DirLine
  27. ENDDEF
  28.  
  29. VARDEF
  30.   CHAR(30)  DirFile = "Dirtree.Dbf"
  31.   CHAR(30)  PicFile = "Dirpic.Dbf"
  32. ENDDEF
  33.  
  34. PROCEDURE force_main
  35. * PARAMETERS CHAR mpath
  36.   VARDEF
  37.     UINT      level, winrec
  38.     CHAR      mpath
  39.     CHAR(32)  mkey
  40.     CHAR(64)  selected_dir
  41.     LOGICAL   mescape, ok
  42.     CHAR(8)   ColorSay,ColorGet,ColorBord
  43.   ENDDEF
  44.  
  45. *-- Initialize vars
  46.   level = 0
  47.   mkey = SPACE(32)
  48.   winrec = 1
  49.   mpath = "D:\"
  50.  
  51.   IF ISCOLOR()
  52.         ColorSay = "gr+/b"
  53.         ColorGet = "w+/rb"
  54.         ColorBord = "n"
  55.         Set Color to ColorSay,ColorGet,ColorBord
  56.   ENDIF
  57.  
  58.   ok = .F.
  59. REPEAT
  60.   CLEAR
  61.   GetAnswer("Enter drive/path:", 10, mpath, mescape, ;
  62.              .T., .F., 0, 0, 32)
  63.  
  64.   mpath = RTRIM(mpath)
  65.   @ 20, 0
  66.   IF LEN(mpath) = 0
  67.      QUIT
  68.   ENDIF
  69.  
  70.   IF SUBSTR(mpath,2,1) <> ":"
  71.      ? "Path/Directory should be in the form D:\path\"
  72.      WAIT
  73.   ELSE
  74.     IF .NOT. ISDRIVE(SUBSTR(mpath, 1, 1))
  75.        ? "Valid drive letters are: ", DRIVESTR()
  76.        WAIT
  77.     ELSE
  78.        ok = .T.
  79.     ENDIF
  80.   ENDIF
  81.  
  82. UNTIL ok
  83.  
  84.   IF RIGHT(mpath, 1) <> "\"
  85.      mpath = mpath + "\"
  86.   ENDIF
  87.   mpath = mpath + "*.*"
  88.  
  89.   FindAllDir(level, mpath, mkey, dirfile)  && creates dirfile
  90.   MakeDirPic(dirfile, picfile, mpath)
  91.  
  92.   selected_dir =  PicDir(picfile, 0, 0, 20, 35, winrec, mpath)
  93.   selected_dir = RTRIM(selected_dir)
  94.   @ 23, 0
  95.  
  96.   IF .NOT. SETDRIVE(SUBSTR(selected_dir, 1, 1))
  97.      ? "Cannot change default drive"
  98.      QUIT
  99.   ENDIF
  100.  
  101.   IF .NOT. CHDIR(selected_dir)
  102.      ? "Cannot change to directory/path: ", selected_dir
  103.   ENDIF
  104. ENDPRO
  105.  
  106.  
  107. -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  108.