home *** CD-ROM | disk | FTP | other *** search
/ BMUG PD-ROM 1995 Fall / PD-ROM F95.toast / Programming / Programming Utilities / MPW Extras ƒ / Scripts / NewClose < prev    next >
Encoding:
Text File  |  1991-07-29  |  2.5 KB  |  80 lines  |  [TEXT/ttxt]

  1. # NewClose - replacement "Close" script supporting file backup and remember
  2.  
  3. Set NFile "{#}"                                                                                    # get number of command line arguments
  4. If ({NFile} == 0)
  5.     # no command line arguments - act on active window
  6.     Set LeafName "`ParseFileName -l "{Active}"`"                                                # get the file's leafname
  7.     Close "{Active}" ∑∑ Dev:Null
  8.     If ({Status} == 0)
  9.         # the Close was successful
  10.         Set RemFiles "`Begin; Files -f "{Backup}{LeafName}".[0-9]+; End ≥ Dev:Null`"
  11.         If ("{RemFiles}" != "")
  12.             # Remember Files exist
  13.             Set Exit 0
  14.             Confirm "Delete the old Remember files?"
  15.             If ({Status} == 0)
  16.                 # Delete all the old "Remember" backup files
  17.                 For i in "{RemFiles}"
  18.                     Delete {i}
  19.                 End  # For i
  20.             End  # If {Status}
  21.         End  # If RemFiles
  22.     End  # If {Status}
  23. Else
  24.     Loop
  25.         Break If ({NFile} <= 0)                                                                    # exit if all arguments have been processed
  26.         If ("{1}" == "-a")
  27.             # Close all windows option
  28.             For i in "`Windows -q`"
  29.                 Set LeafName "`ParseFileName -l "{i}"`"                                            # get the file's leafname
  30.                 Close "{i}" ∑∑ Dev:Null
  31.                 If ({Status} == 0)
  32.                     # the Close was successful
  33.                     Set RemFiles "`Begin; Files -f "{Backup}{LeafName}".[0-9]+; End ≥ Dev:Null`"
  34.                     If ("{RemFiles}" != "")
  35.                         # Remember Files exist
  36.                         Set Exit 0
  37.                         Confirm "Delete the old Remember files?"
  38.                         If ({Status} == 0)
  39.                             # Delete all the old "Remember" backup files
  40.                             For j in "{RemFiles}"
  41.                                 Delete {j}
  42.                             End  # For j
  43.                         End  # If {Status}
  44.                     End  # If RemFiles
  45.                 End  # If {Status}
  46.             End  # For i
  47.         Else
  48.             If (("{1}" == "-C") || ("{1}" == "-n") || ("{1}" == "-y"))
  49.                 Set CloseOption "{1}"
  50.                 Set NShift 2
  51.                 Set LeafName "`ParseFileName -l "{2}"`"                                            # get the file's leafname
  52.                 Close "{1}" "{2}" ∑∑ Dev:Null
  53.             Else
  54.                 Set CloseOption ""
  55.                 Set NShift 1
  56.                 Set LeafName "`ParseFileName -l "{1}"`"                                            # get the file's leafname
  57.                 Close "{1}" ∑∑ Dev:Null
  58.             End  # If {1}
  59.             If ({Status} == 0)
  60.                 # the Close was successful
  61.                 Set RemFiles "`Begin; Files -f "{Backup}{LeafName}".[0-9]+; End ≥ Dev:Null`"
  62.                 If ("{RemFiles}" != "")
  63.                     # Remember Files exist
  64.                     Set Exit 0
  65.                     Confirm "Delete the old Remember files?"
  66.                     If ({Status} == 0)
  67.                         # Delete all the old "Remember" backup files
  68.                         For i in "{RemFiles}"
  69.                             Delete {i}
  70.                         End  # For i
  71.                     End  # If {Status}
  72.                 End  # If RemFiles
  73.             End  # If {Status}
  74.         Shift {NShift}
  75.         Evaluate NFile -= {NShift}                                                                # update the argument counter
  76.         End  # If {1}
  77.     End  # Loop
  78. End  # If {NFile}
  79.  
  80. # end of NewClose