Sublime Forum

Build System issue with paths containing spaces

#1

Hi Guys,
I am writing a Syntax Highliter for MaxScript and have some issues with the custom build system. I use a COM component I didn’t write, that allows me to send the code to 3ds Max to be executed. It accepts the full file path of the current script.

My build file is:

{ "cmd": "mxscom.exe", "-f", "$file"], "selector": "source.MaxScript" }

where:
mxscom.exe is the com object, in the same directory of sublime_text.exe
-f is the option to let the com object accept file paths
$file is the Sublime Text variable of the current full file path

The build works perfectly if there are not spaces in the file path:
C:\DevDirectory\MyScript.ms - works

If there are spaces, the OS adds double quotes to define the path so the $file variable becomes:
“C:\Dev Directory\MyScript.ms” - does not work

The error in 3ds Max Listener looks like:

-- Runtime error: fileIn: can't open file - ""C:\Dev Directory\MyScript.ms"" during OLE automation function call

Is there any way to make it work with paths containing spaces?
Is there any way to strip the double quotes, provided it is the actual issue?

Thank you very much

  • Enrico
0 Likes

#2

I tried a Python source on a path with spaces and it work fine on my:
startup, version: 2199 windows x64 channel: nightly

What’s your OS and ST2 version ?

Are you sure the issue is not in your MyScript.ms ?
Try writing a shell script that only print input parameter to the console.

0 Likes

#3

Hi bizoo,
I’m using Sublime Text 2 Beta 2181 on Windows 7 x64.

The script is fine, as it works if I put it into a folder where the path does not contain any space.
It actually is just a print statement.

If I run the script from a DOS command prompt it is about the same, i.e.:

C:\mxscom.exe -f C:\test.ms - works

C:\mxscom.exe -f “C:\test.ms” - does not work

-- Runtime error: fileIn: can't open file - ""c:\test.ms"" during OLE automation function call
C:\mxscom.exe -f C:\MyFolder\test.ms - works

C:\mxscom.exe -f “C:\My Folder\test.ms” - does not work

-- Runtime error: fileIn: can't open file - ""C:\My Folder\test.ms"" during OLE automation function call

As an interesting debugging information if I feed the com with an invalid file, I get as an error in 3ds Max:

C:\mxscom.exe -f c:\testMe.ms - the file does not exists, so cannot work

-- Runtime error: fileIn: can't open file - "c:\testMe.ms" -- Note quotes are not doubled during OLE automation function call

This is the reason why I was wondering if there is any way to strip the double quotes.
I have been using this com object with PSPad for years, and never got a problem, but Sublime Text is way better and more customizable.

Thanks

  • Enrico
0 Likes

#4

If you open the console (View->Show Console) after running your build there must be something like:

Running python -u C:\Temp\folder with space\test.py

What do you have on your system ?

There is a brand new build on http://www.sublimetext.com/dev, try if it’s resolve your issue.

0 Likes

#5

Hi bizoo,
thanks for your help.

After running the build, in console I’ve got:

Running mxscom.exe -f C:\My Folder\test.ms

Which seems perfectly fine to me.

But I still get the issue with Max:

-- Runtime error: fileIn: can't open file - ""C:\My Folder\test.ms"" during OLE automation function call

I am going to try the new dev build as soon I can. I’ll keep you posted with it.
Thanks!

  • Enrico
0 Likes

#6

You can try adding this to your build file:

{ "cmd": "mxscom.exe", "-f", "$file"], "shell": true, "selector": "source.MaxScript" }
Not sure it help, but actually your issue is very strange and I’ve no other idea.
Good luck.

0 Likes

#7

Hi bizoo,
I tried the “shell” option on both versions of Sublime Text 2181 and 2200 with no luck.

I put the mxscom.exe in the Packages\user folder

{ "cmd": "mxscom.exe", "-f", "$file"], "working_dir": "$packages\\User", "shell": true, "selector": "source.MaxScript" }

The com is called but still in 3ds Max it appears the file path with doubled double-quotes.

Thanks

  • Enrico
0 Likes

#8

SyncViewS: Your earlier post indicated that mxscom.exe doesn’t handle paths with spaces even when called from the command line: is this true? If so, there’s not much that can be done from within Sublime Text to help this.

0 Likes

#9

Hi Jon,
thanks for your reply.

I don’t exactly know what is going on, because I can use this com component with PSPad and Notepad++ without issues, by specifying the same “-f” parameter and the full filepath.

In particular PSPad synthax is:

[code]Compiler
%PSPath%MaxScript\mxscom.exe

Parameters
-f %File%[/code]
Provided mxscom.exe is located in a folder within PSPad called MaxScript.

Please let me know if I can help in any other way.

Thank you

  • Enrico
0 Likes

#10

Sublime Text expects command line utilities to work with quoted paths, if the command line program in question can’t, then I can only suggest writing a wrapper program that will.

0 Likes

#11

Enrico: I was having this same exact problem when trying to get this running today. I ended up fixing it by making my own plugin to use as the target command in the the build-system.

Create a new plugin like this:

import sublime, sublime_plugin
import subprocess

class ExecMsxCommand(sublime_plugin.WindowCommand):
	def run(self, cmd = ], **kwargs):
		subprocess.call(cmd[0] + " " + cmd[1] + " " + cmd[2], shell=False)

Set up your build file like this:

{
   "cmd": "mxscom.exe", "-f", "$file"],
   "selector": "source.MaxScript",
   "target": "exec_msx"
}

Do you have plans on releasing the maxscript syntax highlighting to the community when they are done? I was going to begin that process as well, it seems pretty daunting.

0 Likes