home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 3 Comm / 03-Comm.zip / TE2SC121.ZIP / ChDir.Scr < prev    next >
Text File  |  1992-07-21  |  2KB  |  64 lines

  1. ;; --------------------------------------------------------------------------
  2. ;; ChDir.scr -- TE/2 Script Language Script File
  3. ;;              Copyright (C) 1991 Oberon Software, Mankato, MN
  4. ;;
  5. ;;              Permission is granted to registered TE/2 users to use this
  6. ;;              script without restriction.  If you modify this script and
  7. ;;              subsequently redistribute it, please note the modifications
  8. ;;              in the comment area.  If you do redistribute this this
  9. ;;              script you must also provide the accompanying CHDIRSCR.DOC.
  10. ;;
  11. ;; Author: Brady Flowers
  12. ;; Date:   2 June, 1991
  13. ;;
  14. ;; This script will present the user with a dialog box which will display
  15. ;; the Current Working Directory and prompt for a new directory.  If the
  16. ;; new path contains a drive indicator, the drive is changed also.
  17. ;;
  18. ;; See the file CHDIRSCR.DOC for more information.
  19. ;;
  20. ;; --------------------------------------------------------------------------
  21.  
  22. global  string cwdLast      ; GLOBAL string buffer containing prev response
  23. string  newDir              ; Temporary work string for current response
  24. integer dlgHandle           ; Handle to dialog window
  25. integer hadError = FALSE    ; Error flag
  26.  
  27. ;; --------------------------------------------------------------------------
  28.  
  29. program
  30.  
  31.   ; Open the dialog window, place the Current Working Directory information
  32.   ; and prompt in it and query the user for a response.
  33.  
  34.   dlgHandle = OpenDialog(4, 4, 10, 76, DLogNormAttr)
  35.   StrPut(5, 6, DLogNormAttr, "Current Path is: %s", curdir)
  36.   StrPut(6, 6, DLogNormAttr, "Enter new path spec:")
  37.   newDir = StrGet(cwdLast, 8, 6, 68, 255, DLogEdAttr, DLogEdHiAttr)
  38.  
  39.   ; Examine the response.  It will be the empty string if the user exited
  40.   ; the input by typing ESCape.  Otherwise, check for a colon as the second
  41.   ; character and change disks as well as directories.
  42.  
  43.   if strlen(newDir)
  44.     cwdLast = newDir
  45.     if ASCIIVal(substr(newDir, 1, 1)) == ':'
  46.       hadError = !ChDisk(newDir)
  47.       if hadError == FALSE
  48.         if strlen(newDir) > 2
  49.           hadError = !ChDir(newDir)
  50.         endif
  51.       endif
  52.     else
  53.       hadError = !ChDir(newDir)
  54.     endif
  55.   endif
  56.   CloseDialog(dlgHandle)
  57.  
  58.   ; If there was any sort of error, inform the user here
  59.   if hadError
  60.     ErrorMsg("Error! Cannot change current directory to:", newDir)
  61.   endif
  62.   end
  63.  
  64.