Spaces in Path Names

Ok I’m having problems with spaces in a path name, in the below example iptPath the text field which the user has defined as their save Path, on Mac I just added a single quote and it works fine but the script fails on Windows, the exe starts but fails as it can’t get its head around the space
What has me puzzled is my C# had no issues with adding either double quotes or single

This is the Mac version with the single quotes between +iptPath +“Script.ipt.thea”
I don’t have a problem launching Thea which is in “Program Files” which is weird

[code] Dim iptPath as string = Savetxt.Text
Dim thea As string = " -nosplash" +noshow +" -load " +"’" +iptPath +“Script.ipt.thea” +"’" + " -exit"

#if TargetWin32 then
Dim thea3 As string =TheaPath.Text+ “thea.exe”
#elseif TargetMacOS then
Dim thea3 As string =TheaPath.Text+ “Thea”
#elseif TargetLinux then
Dim thea3 As string =TheaPath.Text+ “thea”
#endif
Dim sh As New Shell
sh.Mode = 1

sh.Execute(thea3,thea)

[/code]

thanks

path=f.child(chrb(34)+“this filename has spaces”+chrb(34))

it fails to start the exe, the same as if it has double quotes :confused:

I’ve re built this project 4 times with different languages and never had this before, the single quotes usually worked

[quote=131911:@nige cope]it fails to start the exe, the same as if it has double quotes :confused:

I’ve re built this project 4 times with different languages and never had this before, the single quotes usually worked[/quote]

" -nosplash" +noshow +" -load " +"'" +iptPath   +"Script.ipt.thea"  +"'" + " -exit"

If you have spaces in ipPath, Windows will not work. In Windows, you must enter information containing spaces within double quotes. Try :

" -nosplash" +noshow +" -load " +chr(34) +iptPath   +"Script.ipt.thea"  +chr(34) + " -exit"

If it still does not work, try placing your iptPath in a textfield so you can see exactly what the result is, and experiment in the Command Prompt manually until you get the syntax right.

Check the exact contents of thea3. You will likely see the problem. If not, post the string here.

I tried :

" -nosplash" +noshow +" -load " +chr(34) +iptPath   +"Script.ipt.thea"  +chr(34) + " -exit"

And Thea fails to start
If I just have

" -nosplash" +noshow +" -load " +"'" +iptPath   +"Script.ipt.thea"  +"'" + " -exit"

Thea runs but fails:

Inspecting command line Executing command line Failed during parsing message "Load C:\\Users\ ige\\Documents\\a" Error at line 1: message "Load C:\\Users\ ige\\Documents\\a" Finished in 0 seconds!

The path that is getting sent looks right:

IF there’s no spaces it works great and does everything its supposed to do… it wasn’t until I gave a beta tester it to try that I noticed it… I don’t use folders with spaces or files

I could give someone the project but it won’t do much without Thea and its a 120meg download

The path doesn’t look right. It should be

“C:\Program Files\Thea Render\thea.exe” -nosplash -load “C:\Users
ige\Documents\a test\temp.ipt.thea” -exit

Note the placement of the quotes.

Ie., you need quotes around BOTH paths.

[quote=131948:@nige cope]I tried :

" -nosplash" +noshow +" -load " +chr(34) +iptPath   +"Script.ipt.thea"  +chr(34) + " -exit"

And Thea fails to start
If I just have

" -nosplash" +noshow +" -load " +"'" +iptPath   +"Script.ipt.thea"  +"'" + " -exit"

Thea runs but fails:

Inspecting command line Executing command line Failed during parsing message "Load C:\\Users\ ige\\Documents\\a" Error at line 1: message "Load C:\\Users\ ige\\Documents\\a" Finished in 0 seconds!

The path that is getting sent looks right:

IF there’s no spaces it works great and does everything its supposed to do… it wasn’t until I gave a beta tester it to try that I noticed it… I don’t use folders with spaces or files[/quote]

The only way you will be able to solve that is to experiment with the interactive Command Prompt application until you get it to work, and only after build your string properly in Xojo.

Thanks Tim and Michel, I’ll give it a try

For windows you’ll need to double quote the path to the exe as Tim said above.

theapath = “”“C:\Program Files\Thea Render\thea.exe”""

It fails to start Thea with double quotes
I’m going to leave it and take a look next week, I’d been on this two days before I asked lol and now I’m losing the will to live… can’t believe something that is in 5 different projects can be such a problem :confused:

For a “quick fix” I’ve made it save/open the file from the application folder, the XML files that it subsequently loads aren’t proving a problem… at least I can now get it out for testing and worry about this hiccup at my leisure :slight_smile:

thanks for the help/advice

Dim thea as string = "  ""-nosplash " + noshow + """ ""-load " + iptPath + "Script.ipt.thea"" ""-exit"""

At least on Windows, this syntax should work, per this site:
http://ss64.com/nt/cmd.html

Under:
Spaces in Program Path + parameters with spaces:
CMD /k ““c:\batch files\demo.cmd” “Parameter 1 with space” “Parameter2 with space””

You may have to take the space following -nosplash out… as I wasn’t sure whether it needed to be included or not.

I just worked with a Windows path for another thread, and I realize we do not know how iptPath is created. FolderItem normally reports a short path (Dos path) so it contains no spaces. I bet iptPath is created using NativePath which is the “long path” with spaces. Switch to shellPath and it will work right away.

This whole thread got messed up but I think the code you posted originally will work fine (as you indicated), if you fill iptPath with shellPath. This turns the path with spaces into the Dos path (in your original post) :

dim f as folderitem = GetFolderItem(Savetxt.Text) Dim iptPath as string = f.shellpath Dim thea As string = " -nosplash" +noshow +" -load " +"'" +iptPath +"Script.ipt.thea" +"'" + " -exit"

You also have to deal with TheaPath.Text. it contains a space too.

That is precisely the point : TheaPath.Text is most probably a field where the user enters the long path which contains spaces. By adding dim f as folderitem = GetFolderItem(Savetxt.Text) it sets f to that path, which converts iptPath to f.shellpath which is the short (Dos) version which contains no path, so extra quotes become unnecessary.

Why go to such lengths when all you have to do is put quotes around it?