cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Submit your abstract to the call for content for Discovery Summit Americas by April 23. Selected abstracts will be presented at Discovery Summit, Oct. 21- 24.
Discovery is online this week, April 16 and 18. Join us for these exciting interactive sessions.
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?