home *** CD-ROM | disk | FTP | other *** search
- REM Description: Delete a file and its backup
- REM Filename: delfile.wmc
- REM Created by: Steven Wylie - 11/08/93
-
- start:
- REM
- currentDir$ = GetCurrentDir$()
- REM Start at the document directory. The user can always change it in the dialog box.
- GetPrivateProfileString "Preferences", "DocumentDirectory", curDir$, docDir$, "wsw.ini"
- CHDIR docDir$
-
- title$ = "Choose a File to Delete"
-
- REM Get a filename from the user. Only one file at a time will be used.
- filename$ = GetFileBox$("*.*", title$)
-
- IF filename$ = "" THEN STOP
-
- IF Access(filename$, 0) = 0 THEN
- msg$ = filename$ + chr$(13) + chr$(13) + "This file does not exist."
- ret% = MESSAGEBOX(msg$, "Delete File Error", 16)
- STOP
- ENDIF
-
- IF Access(filename$, 2) = 0 THEN
- msg$ = filename$ + chr$(13) + chr$(13) + "This file is read only and cannot be deleted."
- ret% = MESSAGEBOX(msg$, "Delete File Error", 16)
- STOP
- ENDIF
-
- bakfilename$ = filename$
- dot% = INSTR(bakfilename$, ".")
- IF dot% > 0 THEN
- MID$(bakfilename$, dot% + 1, 3) = "BAK"
- ELSE
- bakfilename$ = bakfilename$ + ".BAK"
- ENDIF
-
- REM See if the backup file exists
- bakexist% = Access(bakfilename$, 0)
-
- REM If the backup file is the same as the original file, then only one file to delete.
- IF UCASE$(bakfilename$) = UCASE$(filename$) THEN bakexist% = 0
-
- IF bakexist% <> 0 THEN
- message$ = filename$+chr$(13)+chr$(13)+"Are you sure you want to delete this file and its backup file?"
- ELSE
- message$ = filename$+chr$(13)+chr$(13)+"Are you sure you want to delete this file?"
- ENDIF
- ret2% = MessageBox(message$, "Delete File", 33)
- IF ret2% = 2 THEN STOP
- KILL filename$
- IF bakexist% > 0 THEN KILL bakfilename$
-
- REM Restore the original directory.
- CHDIR currentDir$
- ***** WARNING *****
- This is a WSWin macro file.
- Subsequent data is binary information and should not be modified.