Patch Path on load

Wesley Smith's icon

Hi,
The following code won't work if the mxj is loaded at the same time the patch file is opened:

//gets the path of the mxj's parent patcher
    private void patchPath()
    {
        _patcher = this.getParentPatcher();
        _patchPath = _patcher.getFilePath().substring(0, _patcher.getFilePath().lastIndexOf('/') + 1);
    }

You get "" as the path. If you reinitialize the mxj once the patch is loaded, then it works. Are there any plans to fix this? I'm tempted to file a bug report about this.

thanks,
wes

topher lafata's icon

This is not necessarily specific to mxj.
Could you fix the problem by putting that code in
a loadbang method? This is called after the patch is loaded.

public void loadbang()

Topher

Wesley Smith's icon

Ah, Yes I could. Right now I've got it hidden in an if statement when
I receive the first input, which is super ugly. I always forget that
mxj has a loadbang method.

thanks,
wes