Share your ideas for the JMP Scripting Unsession at Discovery Summit by September 17th. We hope to see you there!
Choose Language Hide Translation Bar
Highlighted
JulieSAppel
Level IV

Open file and continue script

Hi,

In a script I´m prompting a user to open a file:

LBSelect = Open( "file path", 
	Use Labels For Var Names( 1 )
	);

This opens a folder and the user has to pick the correct file. When the file has been opened the script should continue with a series of actions based on that file.

How can I make the script wait until a file has been opened? I thought about wait() but that will just state how many seconds it has to wait and as these files tend to be very big this is not a good fit. 

How can I make it wait for the file to open?

Can a modal window be used in any way?

 

Br Julie

 

 

4 REPLIES 4
Highlighted
tom_abramov
Level V

Re: Open file and continue script

Hi,

I have a couple of ideas.

1. try to use wait() with no number inside. It will wait until all previous commands are complete (I hope it is true)

2. make a loop with wait and try

 

For( i = 1, i <= 100, i++, 
	Try(
		LBSelect << Bring Window to front();//run any command on table which will fail in case the table is not ready
		Break();//if not failed - terminate the loop
	,
		Wait( 1 )
	);//if failed - wait 1 second and try again

);

 

Highlighted

Re: Open file and continue script

You are confused. The Open() function opens a file. The Pick File() function presents a dialog and returns a full path to the selected file or missing. So you should call the Pick File() function and use the result to open the file with the Open() function, or call the Open() function without a path.

Learn it once, use it forever!
Highlighted
JulieSAppel
Level IV

Re: Open file and continue script

Ok - I can see that.

Normally I do that when I prompt for a user to open a file (where they navigate to the file themselves). In this case I wanted to add the file path in there to reduce the amount of clicks and then I managed to confuse myself.

Now I´ve done this:

path = Pick File("Select lb", "file path");

LBSelect = Open( path, 
	Use Labels For Var Names( 1 )
	);

But it doesn´t seem to work. The lb file is opened as lb, not as LBSelect.

What am I doing wrong?

Highlighted
David_Burnham
Super User

Re: Open file and continue script

Wait(0)

... is a common method of waiting until a task is completed.  Not sure I've ever had to use it in the context of opening files.  

-Dave
Article Labels

    There are no labels assigned to this post.