Difference between revisions of "KILL"

From QB64 Wiki
Jump to navigation Jump to search
imported>Clippy
m
m (Text replacement - "Qbasic" to "QBasic")
 
(4 intermediate revisions by 2 users not shown)
Line 1: Line 1:
The '''KILL''' statement deletes a file on a relative path designated by a [[STRING]] value or variable.
The [[KILL]] statement deletes a file designated by a [[STRING]] value or variable.
 




{{PageSyntax}}
{{PageSyntax}}
:: KILL filespec$
: [[KILL]] {{Parameter|fileSpec$}}




* Filespec is a literal or variable string path and filename. Wildcards * and ? can be used but '''be careful!'''
* {{Parameter|fileSpec$}} is a literal or variable string path and filename. Wildcards * and ? can be used with caution.
::'''*''' denotes one or more wildcard letters of a name or extension
::'''*''' denotes one or more wildcard letters of a name or extension
::'''?''' denotes one wildcard letter of a name or extension
::'''?''' denotes one wildcard letter of a name or extension


* Path can be relative to program's current location or use an absolute path from the root drive.
* {{Parameter|fileSpec$}} can include a path that can be either relative to the program's current location or absolute, from the root drive.
* KILL cannot remove an [[OPEN]] file. The program MUST [[CLOSE]] it first.   
* [[KILL]] cannot remove an [[OPEN]] file. The program must [[CLOSE]] it first.   
* If the path or file does not exist, a "File not found" or "Path not found" [[ERROR Codes|error]] will result.
* If the path or file does not exist, a "File not found" or "Path not found" [[ERROR Codes|error]] will result. See [[_FILEEXISTS]].
* [[SHELL]] ''"DEL /Q " + filename$'' does the same without a prompt or verification for wildcard deletions.
* {{InlineCode}}[[SHELL]] "DEL /Q " + fileName${{InlineCodeEnd}} does the same without a prompt or verification for wildcard deletions.
* [[SHELL]] ''"DEL /P " + filename$'' will ask for user verification.  
* {{InlineCode}}[[SHELL]] "DEL /P " + fileName${{InlineCodeEnd}} will ask for user verification.  
* Cannot delete folders or directories! Use [[RMDIR]] to remove empty folders only!
* Cannot delete folders or directories. Use [[RMDIR]] to remove empty folders.
* '''Warning! Files deleted in DOS or QB64 will NOT go to the Recycle Bin and they CANNOT be restored!'''
* '''Warning: files deleted with [[KILL]] will not go to the Recycle Bin and they cannot be restored.'''
 




''Example:''
{{PageExamples}}
{{CodeStart}}
{{CodeStart}}
KILL "C:\Qbasic\data\2000data.dat"
KILL "C:\QBasic\data\2000data.dat"
{{CodeEnd}}
{{CodeEnd}}




''See also:''
{{PageSeeAlso}}
* [[RMDIR]], [[FILES]], [[SHELL]], [[OPEN]]
* [[RMDIR]], [[FILES]], [[SHELL]], [[OPEN]]
* [[CHDIR]], [[MKDIR]], [[NAME]]
* [[CHDIR]], [[MKDIR]], [[NAME]]
* [[_FILEEXISTS]], [[_DIREXISTS]]
* [[_FILEEXISTS]], [[_DIREXISTS]]
* [[DOS]], [[Batch Files]], [[DOS#DEL|DEL]]




{{PageNavigation}}
{{PageNavigation}}

Latest revision as of 13:11, 10 February 2021

The KILL statement deletes a file designated by a STRING value or variable.


Syntax

KILL fileSpec$


  • fileSpec$ is a literal or variable string path and filename. Wildcards * and ? can be used with caution.
* denotes one or more wildcard letters of a name or extension
? denotes one wildcard letter of a name or extension
  • fileSpec$ can include a path that can be either relative to the program's current location or absolute, from the root drive.
  • KILL cannot remove an OPEN file. The program must CLOSE it first.
  • If the path or file does not exist, a "File not found" or "Path not found" error will result. See _FILEEXISTS.
  • SHELL "DEL /Q " + fileName$ does the same without a prompt or verification for wildcard deletions.
  • SHELL "DEL /P " + fileName$ will ask for user verification.
  • Cannot delete folders or directories. Use RMDIR to remove empty folders.
  • Warning: files deleted with KILL will not go to the Recycle Bin and they cannot be restored.


Examples

KILL "C:\QBasic\data\2000data.dat"


See also



Navigation:
Keyword Reference - Alphabetical
Keyword Reference - By Usage
Main Wiki Page