BookmarkSubscribeSubscribe to RSS Feed
Jaz

Frequent Contributor

Joined:

Jun 11, 2018

RE: File Not Found

Hi,

 

Is there any way I could open the file without specifying the prefix path? In one of my scripts when I type Open(filename.jmp) it works, but doesn't when I try and open it from a window in the follwing example, any idea as to why? I  keep getting the error with a \ in front of the file name for some reason? If I specify the full path for the file it works, but I need it to work when only the file name is provided.

OKScript = Expr(
	win1 << CloseWindow;
	lf = ListF << GetItems;
	If( N Items( lf ) < 1,
		Warning( "ERROR: You need to select at least one file" );
		Throw();
	);  
	For( i = 1, i <= N Items( lf ), i++,
	print(lf[i]); 
	dt=Open(lf[i]); 
	); 
	);
); 
5 REPLIES
Jaz

Frequent Contributor

Joined:

Jun 11, 2018

RE: File Not Found

Update:

I  tried to utilise the get path variable(filename) function but it returns "" and I'm not sure as to why.

markbailey

Staff

Joined:

Jun 23, 2011

RE: File Not Found

The Get Path Variable() function returns the current value (a path) stored in a JMP path variable. The argument is not a file name but a path variable. See Help > Books > Scripting Guide and look up path variables.

Learn it once, use it forever!
Jaz

Frequent Contributor

Joined:

Jun 11, 2018

RE: File Not Found

I read up and realised I was using the wrong function so tried convert file path instead. This works sometimes but not other times. For example in my program I have a file called "Test 1 PFD.jmp" and when I print the convert file path of "Test 1 PFD.jmp" it returns "/Test 1 PFD.jmp" in the log, instead of the full file path.

Jaz

Frequent Contributor

Joined:

Jun 11, 2018

RE: File Not Found

I'm experimenting with get path now.

Highlighted
Jaz

Frequent Contributor

Joined:

Jun 11, 2018

RE: File Not Found

Also tried the following which doesn't seem to be working:

dt = Open("123456700000.csv");
path = Arg(dt << get property("Source"), 1);
print("path: " || Arg(dt << get property("Source"), 1)); 

Again, it prints the name of the file with a \ instead of the file path.