This code won't execute until compiled.

I have the following code in an application:

Dim F5 as FolderItem
Try
F5 = SpecialFolder.Applications.Child(“gnuplot”).Child(“bin”).Child(“wgnuplot.exe”)
F5.Launch(“Gp.txt”)
Catch e As NilObjectException
MsgBox(“The 32 bit version of Gnu plot must be installed on this system in order to plot top the top speed performance.”)
Return
End Try
End

‘Gp.txt’ is a file next to the executable, in the project folder using a relative path. The code works perfectly after building, but does not work on IDE ‘Run’. I believe the debugger is getting the wrong paths.

I would much prefer to run it in the IDE. It is kind of a pain to rebuild each time I make a project code change.

Can anyone help on this?

Use a build step to copy gp.txt next to the built executable

http://developer.xojo.com/userguide/build-automation

The file is currently next to the executable. It is placed there when the build is created.

I meant to say:

The file is currently next to the executable. It is placed there when the built executable runs.

the executable creates it ?

Yes, the executable builds and saves the file next to the executable.

Put it here instead:

SpecialFolder.Applications.Child("gnuplot").Child("bin").Child("Gp.txt")

or if your app is not gnuplot, put it here:

SpecialFolder.Applications.Child("myapp").Child("Gp.txt")

[quote=337648:@Jeff Tullin]Put it here instead:

SpecialFolder.Applications.Child("gnuplot").Child("bin").Child("Gp.txt")

or if your app is not gnuplot, put it here:

SpecialFolder.Applications.Child("myapp").Child("Gp.txt")

On OS X SpecialFolder.Applications may require elevated privileges making it so you CAN’T write there

Write Gp.txt to a directory you create in SpecialFolder.ApplicationData for your app
Or just use GetTemporaryFolderItem to get one in the temporary files dir and then use that http://documentation.xojo.com/index.php/GetTemporaryFolderItem

// assuming that gp.txt has been written to a folderitem obtained via gettemporaryfolderitem
// and that temporary is called gpTemporaryFolderItem

Dim F5 as FolderItem
Try
  F5 = SpecialFolder.Applications.Child("gnuplot").Child("bin").Child("wgnuplot.exe")
       
  F5.Launch(gpTemporaryFolderItem.NativePath)

  Catch e As NilObjectException
    MsgBox("The 32 bit version of Gnu plot must be installed on this system in order to plot top the top speed performance.")
    Return
  End Try
End

Ok, Thanks Norman, I think that may work. I will try it when I get some time.