Open file and continue scriptHi,
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
Re: Open file and continue scriptAre you looking something like this?
Names Default To Here( 1 );
New Window( "Data and Limits file",
<<MODAL></MODAL>
Re: Open file and continue scriptWait(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.
Re: Open file and continue scriptOk - 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?
Re: Open file and continue scriptYou 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.
Re: Open file and continue scriptHi,
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
);
Re: Open file and continue scriptIt's better if you do something like this maybe? See the bold text, and then everything else is just optional, based on what I needed to do with my data.
Open(
Pick File(),
Worksheets( "Data" ),
Use for all sheets( 1 ),
Concatenate Worksheets( 0 ),
Create Concatenation Column( 0 ),
Worksheet Settings(
1,
Has Column Headers( 1 ),
Number of Rows in Headers( 4 ),
Headers Start on Row( 21 ),
Data Starts on Row( 25 ),
Data Starts on Column( 1 ),
Data Ends on Row( 0 ),
Data Ends on Column( 0 ),
Replicated Spanned Rows( 1 ),
Replicated Spanned Headers( 0 ),
Suppress Hidden Rows( 1 ),
Suppress Hidden Columns( 1 ),
Suppress Empty Columns( 1 ),
Treat as Hierarchy( 0 ),
Multiple Series Stack( 0 ),
Import Cell Colors( 0 ),
Limit Column Detect( 0 ),
Column Separator String( "-" )
)
)
Re: Open file and continue scriptSo basically this...
Open(
Pick File(),
.....
)