I’m trying to run an asynchronous shell command like
Using Xojo.Core
Dim StartTime As Date
Dim Name As String
StartTime = Date.Now
Name = Name.ReplaceAll(":", "-")
Name = Name.ReplaceAll(" ", "_")
Name = Name + ".mp4"
Dim s As Shell
s = New Shell
s.Mode = 1
s.Execute("a very long ffmpeg command that creates a video named with the variable name")
You need to declare the shell property outside of the method. The way youve written this, the property goes out of scope at the end of the method and may be destroyed.
To fix, get rid of the Dim s as Shell line and instead make a property on the containing object (window, class, module, etc) to make sure itll stick around.
Thanks Greg
It took 4 minutes to get not only a solution but also an explanation. THIS FORUM ROCKS!!!
This is what i ended up doing
I added a property named “RenderShell” to my main window and in the opening event of the window i added:
Me.RenderShell = New Shell
Now my code looks like this and it works on Mac and Windows
Using Xojo.Core
Dim StartTime As Date
Dim Name As String
StartTime = Date.Now
Name = Name.ReplaceAll(":", "-")
Name = Name.ReplaceAll(" ", "_")
Name = Name + ".mp4"
Main.RenderShell.Mode = 1
s.Execute("a very long ffmpeg command that creates a video named with the variable name")
Using Xojo.Core
Dim StartTime As Date
Dim Name As String
StartTime = Date.Now
Name = StartTime.ToText
Name = Name.ReplaceAll(":", "-")
Name = Name.ReplaceAll(" ", "_")
Name = Name + ".mp4"
Main.RenderShell.Mode = 1
s.Execute("a very long ffmpeg command that creates a video named with the variable name")