FILEEXISTS: Difference between revisions

From QB64 Phoenix Edition Wiki
Jump to navigation Jump to search
No edit summary
Tag: Reverted
No edit summary
 
(2 intermediate revisions by the same user not shown)
Line 16: Line 16:


{{PageExamples}}
{{PageExamples}}
{{Parameter|Example:'' Checks if a file exists before opening it.
''Example:'' Checks if a file exists before opening it.
{{CodeStart}}
{{CodeStart}}
{{Cl|IF}} {{Cl|_FILEEXISTS}}("mysettings.ini") THEN
{{Cl|IF}} {{Cl|_FILEEXISTS}}({{Text|<nowiki>"mysettings.ini"</nowiki>|#FFB100}}) {{Cl|THEN}}
     {{Cl|PRINT}} "Settings file found."
     {{Cl|PRINT}} {{Text|<nowiki>"Settings file found."</nowiki>|#FFB100}}
{{Cl|END IF}}
{{Cl|END IF}}
{{CodeEnd}}}}
{{CodeEnd}}




Line 31: Line 31:


{{PageNavigation}}
{{PageNavigation}}
[[Category:Latest]]

Latest revision as of 10:09, 29 March 2023

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:
Main Page with Articles and Tutorials
Keyword Reference - Alphabetical
Keyword Reference - By usage
Report a broken link