Difference between revisions of "FILEEXISTS"

From QB64 Wiki
Jump to navigation Jump to search
imported>Clippy
m
imported>SMcNeill
m (-)
 
(4 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
{{DISPLAYTITLE:_FILEEXISTS}}
 
{{DISPLAYTITLE:_FILEEXISTS}}
The '''_FILEEXISTS''' function determines if a designated file name exists and returns True or False.
+
The '''_FILEEXISTS''' function determines if a designated file name exists and returns true (-1) or false (0).
  
  
 
{{PageSyntax}}
 
{{PageSyntax}}
 +
: {{Parameter|theFileExists%}} = [[_FILEEXISTS]]({{Parameter|filename$}})
  
::: IF _FILEEXISTS(''filename$'') THEN
 
  
 
+
{{PageDescription}}
* The ''filename'' parameter can be a literal or variable [[STRING|string]] value that can include a path.
+
* The {{Parameter|filename$}} parameter can be a literal or variable [[STRING|string]] value that can include a path.
 
* The function returns -1 when a file exists and 0 when it does not.
 
* The function returns -1 when a file exists and 0 when it does not.
 
* The function reads the system information directly without using a [[SHELL]] procedure.
 
* The function reads the system information directly without using a [[SHELL]] procedure.
* The function can use the appropriate Operating System path separators. [[_OS$]] can determine the operating system.
+
* The function will use the appropriate Operating System path separators. [[_OS$]] can determine the operating system.
* '''This function does not guarantee that a file can be accessed or opened'''
+
* '''This function does not guarantee that a file can be accessed or opened, just that it exists.'''
 +
 
 +
 
 +
{{PageExamples}}
 +
{{Parameter|Example:'' Checks if a file exists before opening it.
 +
{{CodeStart}}
 +
{{Cl|IF}} {{Cl|_FILEEXISTS}}("mysettings.ini") THEN
 +
    {{Cl|PRINT}} "Settings file found."
 +
{{Cl|END IF}}
 +
{{CodeEnd}}}}
  
  
''See also:''
+
{{PageSeeAlso}}
* [[_DIREXISTS]]
+
* [[_DIREXISTS]], [[_OS$]]
* [[SHELL]]
+
* [[SHELL]], [[FILES]]
* [[_OS$]]
+
* [[KILL]]
  
  
 
{{PageNavigation}}
 
{{PageNavigation}}

Latest revision as of 23:34, 5 September 2017

The _FILEEXISTS function determines if a designated file name exists and returns true (-1) or false (0).


Syntax

theFileExists% = _FILEEXISTS(filename$)


Description

  • The filename$ parameter can be a literal or variable string value that can include a path.
  • The function returns -1 when a file exists and 0 when it does not.
  • The function reads the system information directly without using a SHELL procedure.
  • The function will use the appropriate Operating System path separators. _OS$ can determine the operating system.
  • This function does not guarantee that a file can be accessed or opened, just that it exists.


Examples

Example: Checks if a file exists before opening it.

IF _FILEEXISTS("mysettings.ini") THEN PRINT "Settings file found." END IF


See also



Navigation:
Go to Keyword Reference - Alphabetical
Go to Keyword Reference - By usage
Go to Main WIKI Page