cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Browse apps to extend the software in the new JMP Marketplace
Choose Language Hide Translation Bar
DannyORegan94
Level II

Button box prevents relative filepath from working

Hi all,

 

I was messing around and discovered something strange. If I save the below script into the same folder as the 'Config File.jmp" file and then try to run it, the following error is produced when i press the button to open the config file: "Error with file: Path is invalid: \Config File.jmp."

F_Open  = function({columntoread},{defaultlocal},
	Open("Config File.jmp")
);

new window("test",
	buttonbox("go",
		script(
			F_Open("Directories");
		);
	);
);

Yet if I just run the line "Open("Config File.jmp")"  from within the script without moving any files around, the data table opens fine.

Also, if I change the relative filepath to the full filepath, ie "C:\....\Config.File.jmp", suddenly the button box works.

 

Any idea why this is happening???

1 ACCEPTED SOLUTION

Accepted Solutions
pmroz
Super User

Re: Button box prevents relative filepath from working

Looks like the function doesn't know the current directory.  Try this code, which passes the current directory into the function as an argument:

F_Open  = function({columntoread, current_path},{defaultlocal},
	Open(current_path || "Config File.jmp");
);
curpath = get default directory();
new window("test",
	buttonbox("go",
		script(
			F_Open("Directories", curpath);
		);
	);
);

View solution in original post

3 REPLIES 3
DannyORegan94
Level II

Re: Button box prevents relative filepath from working

Anybody??

pmroz
Super User

Re: Button box prevents relative filepath from working

Looks like the function doesn't know the current directory.  Try this code, which passes the current directory into the function as an argument:

F_Open  = function({columntoread, current_path},{defaultlocal},
	Open(current_path || "Config File.jmp");
);
curpath = get default directory();
new window("test",
	buttonbox("go",
		script(
			F_Open("Directories", curpath);
		);
	);
);
DannyORegan94
Level II

Re: Button box prevents relative filepath from working

This does indeed work. Any idea though why the relative filepathing wasn't working the way it usually does?