Author Topic: Check if a File exists  (Read 1940 times)

blueknight

  • Newbie
  • *
  • Posts: 14
Check if a File exists
« on: November 07, 2017, 11:34:03 PM »
Hello so I am working on a command and I would like to make sure that the file exists and if not write a header (comma delimiated) to the file.

I know I have a variable that I am using that looks something like this.

Set Text [VAR-Systems-DIR] to '%userprofile%\Documents\EliteDangerous\BlueKnight\'
Set Text [VAR-Discovered-Systems] to 'Discovered-Systems.txt'
Set Text [VAR-Write-Discovered-Systems] to '{TXT:VAR-Systems-DIR}{TXT:VAR-Discovered-Systems}' (save value to profile)

While this works great in commands when I use this, I would just like to check if it exists first. I found a way to check the directory but not if the file exists in the docs.

TheThingIs

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 278
    • HCS Voicepacks
Re: Check if a File exists
« Reply #1 on: November 08, 2017, 02:03:21 AM »
page 129 of the manual:

{STATE_FILEEXISTS:textVariable} - this will return “1” if the file indicated in the text variable exists, or “0” if it does not.

The Singularity profile - One profile to rule them all and at HCS we bound them ;)

You see, TheThingIs, eventually you'll be allright.