Mac Path Blues

I have something really weird going on with paths on Mac its Mountain Lion This bit of code reads the row from Magic listbox and fires up Thea Render with arguments based on the content of the cells

[code]Dim sh As New Shell
sh.Mode = 1
Dim saving as String = Savetxt.Text
dim f3 as folderitem = GetFolderItem(ScenePathtxt.Text)
Dim iptPath as string = f3.NativePath
#if TargetWin32 then
Dim thea3 As string =“C:\Program Files\Thea Render\thea.exe”
#elseif TargetMacOS then
Dim thea3 As string = “/Applications/”
Dim i as Integer

for i = 0 to lb1.ListCount -1
dim Scene as string= lb1.cell((i),1)
dim Imagename as string= lb1.cell((i),2)
dim imgformat as string= lb1.cell((i),3)
dim ActCam as string= lb1.cell((i),4)
dim maxsamples as string= lb1.cell((i),5)
dim maxtime as string= lb1.cell((i),6)

// args to send
dim thea as string =  " -nosplash -load " + Scene _
 + " -message ""./Scenes/Active/Cameras/" + ActCam + "/Make Active"""  _
 + " -maxsamples " + maxsamples _
+ " -timelimit " +  maxtime _
+ " -render " _
+  " -save " +  saving+ "/" + Imagename + imgformat 

while sh.IsRunning
  app.DoEvents ()


The Problem I’m having is for some strange reason even though “Scene” is the right path ie /Users/nige/Documents/shad.pack.thea Thea tries to load the file but the path is changed to /Users/nige/Documents/shad.png inside Thea’s console it seems it can’t handle a 4 digit extension, using the command line it works fine also if the extension is *.scn.thea this also works

this is the commandline which worked

do shell script " open -a '/Applications/' --args -load /Users/nige/Documents/shad.pack.thea"

I’ve tried

dim f3 as folderitem = GetFolderItem(ScenePathtxt.Text) Dim iptPath as string = f3.NativePath
But no luck, its fine on windows… or was I’m pretty much doing it all on Mac now

Also how do you get it to launch the /Applications/ rather than digging deeper

It works fine with .scn.thea but croaks with pack.thea, I’ve tried with single quotes, I can’t see it being a Thea issue as it works with various Xojo, C# and VB projects under windows
sorry for the dumb questions I’m a Mac virgin

Try quoting the parameters. This function should do the trick:

Function QuoteParam (s As String) As String

  #if TargetWin32 then
  const kQuote = """"
  s = kQuote + s + kQuote
  s = s.ReplaceAll( "'", "'\\''" )
  s = "'" + s + "'"

  return s
End Function

In your method, you’d do something like:

    dim thea as string =  " -nosplash -load " + QuoteParam( Scene ) _

Did you trace the code to make sure Scene has what you think it has?

And a couple of other things:

You can dim a variable right in the For loop like this:

for i as integer = 0 to 10

Do not… let me say again, do not! use App.DoEvents in a desktop app. It’s meant for console apps only and should have never been allowed in desktop apps. Instead, either set the Shell mode to 0, or better, drag a Shell onto your window, use it in your method, and implement its events to modify the ListBox when done.

Thanks I’ll give it a try :slight_smile:

right now the do events doesn’t appear to do anything bad, once you hit run there’s very little interaction needed with the app
In the ideal world I’d be using Thea’s remote server and send instructions via that but as yet I’ve failed dismally getting that working with Xojo

thanks again

Regardless of appearances, it’s doing something bad in a desktop app. Treat it like it is a CrashMyAppHere statement.

Thanks Kem… I think I’ve come up with a plan to do away with it… usually we/I use a script and the thing just runs to the end, with the items being in a list the do event was mainly there to stop it trying to do the entire list at once, I had this go seriously wrong once, render jobs which are 2gb+ x10 can totally screw up a 8gb system if all of them render at once lol