The Mad Jammer Posted June 28, 2005 Posted June 28, 2005 I have two global fields called glb_Filename, which is a radio button and populated by a static value list, and glb_Year, which is also a radio button and populated by a static value list, and a button to execute a script. The idea is to be able to open and view archived files that we save from year to year. The button executes a script that looks like this. If glb_Year = "1998" Perform [sub-script "Select 1998 Files"] Else If glb_Year = "1999" Perform [sub-script "Select 1999 Files"] Else If glb_Year = "2000" ...End IF End IF The "Select 1998 Files" script looks like this If glb_Filename = "Referrals" Perform Script[sub-scripts, "Open Referrals 1998"] Else If glb_Filename = "Memo Log" Perform Script[sub-scripts, "Open Memo Log 1998"] ...End IF End IF The "Open Referrals 1998" script looks like this Open["Referrals 1998.fp5"] Its a really simple process but when the file finally opens the focus comes back to the original archive selection layout instead of staying on the newly opened file. How do I get the opened file to be displayed in this instance? One other thing, not every file listed in glb_Filename had an associated archive file in every year. I have trapped those instances with a user message. If I perform just the last script that directly opens the file I don't have this problem, but that would require a button for every Open File script which is becoming unwieldy. Thanks The Mad Jammer
RalphL Posted June 28, 2005 Posted June 28, 2005 Try putting a Halt Script step as the last step in your Open Scripts, I.e., the script that open the selected file.
The Mad Jammer Posted June 28, 2005 Author Posted June 28, 2005 RalphL, Just tried your suggestion with no luck. The behavior returning from a script seems like it may reinitialize some setting, I just don't know which one. The Mad Jammer
RalphL Posted June 28, 2005 Posted June 28, 2005 The FMP help says: "Forces all scripts (including any sub-scripts or external scripts) to stop immediately." That is why I suggested it as the last step in your Scripts that open the file. This should break the return to the calling script(s). You might try to put a pause in each script so you can slow the process down to see what is happening.
The Mad Jammer Posted June 28, 2005 Author Posted June 28, 2005 RalphL, I wrote a new script that directly opened one of two files based on the value in global variable like this. If glb_File = "File 1" Open["File 1"] End If If glb_File = "File 2" Open["File 2"] End If Oddly enough when i ran the script for File 1 it opened and then was hidden. When I selected File 2 and ran the script it opened up and stayed on screen. being the cynic that I am i reran the script for File 1 but the same thing happened, it hid itself after being opened. Weird stuff. The Halt Script command after the Open [file] command made the file hidden when I performed the script from the script editor dialog screen. when i removed the Halt script command the files would open and stay on screen. Perhaps it has something to do with the fact that these files are on a remote server but are not being hosted, or maybe it's just some weirdness in FMP version 5. The Mad Jammer
-Queue- Posted June 28, 2005 Posted June 28, 2005 The Halt Script step needs to be in the on open script for the files that are being opened or in a script that is called from the main file directly after a file is opened. Otherwise the main file will still have control. Also, make sure that your on open scripts in the other files maximize the window before halting.
Vaughan Posted June 28, 2005 Posted June 28, 2005 Rather than use the Open [] script step, I use... Perform Script [ external, <Otherfile::SomeScript> ] ...where the "SomeScript" in the other file setus up the window the way I want, then ends with the Refresh Window [bring to front] script step. I have found that the Open script step is not reliable and does not always perform as expected, usually when the target file is already open.
The Mad Jammer Posted June 29, 2005 Author Posted June 29, 2005 -Queue- and Vaughan, Thanks for your responses. I inserted the Halt Script script step command immediately after the Open[filename] script step. That command was at the end of the tree of scripts that opened the file. The script "Open Archive File' is nothing more than this Open["archive filename"] Halt Script So that should have taken care of it but it didn't. This script was called by another script which, in turn, was called by the first script in this chain. I also took special care to be sure the file was closed before issuing the Open[] script step. The idea of opening the file from an external script is appealing except for the fact that there are currently 45 files in the archives for this one location and I'd have to edit each file to add the script that can be called externally. All told there are sevearl hundred archive files for all locations that I'd have to do this with. That would take a lot of time to retrofit. I agree with you that he Open[] script step seems be unreliable. The Mad Jammer
-Queue- Posted June 29, 2005 Posted June 29, 2005 No, the Halt Script step needs to be in the called file, not the calling one. Otherwise the calling file still maintains control. If you have no scripts in the other files that are set to run when they open, create a simple one like Go to Layout [someLayout] Toggle Window [Maximize] Halt Script and set this to run on open.
The Mad Jammer Posted August 24, 2005 Author Posted August 24, 2005 Thanks -Queue-, I'll give this a try. The Mad Jammer
T-Square Posted August 24, 2005 Posted August 24, 2005 The behavior you're seeing is, as Queue hints, a result of the fact that your calling script has lines in it that need to execute to finish the script. Your example: If glb_File = "File 1" Open["File 1"] End If If glb_File = "File 2" Open["File 2"] End If Results in a hidden window for File 1 because the script has to finish up (checking for File 2)--after the file's been opened. That returns the focus to this window. The way I handle this in simpler scripts is to use nested Ifs: If glb_File = "File 1" Open["File 1"] Else If glb_File = "File 2" Open["File 2"] End If End If For some reason, the closing of the If statement isn't considered an executed line. For more complicated situations, look for some other solutions. If you were to update to Version 7, you could use the free plugin EventScript to manage all these file openings using one straightforward script. You'd select the archive file from a dropdown, and then open the file based on that value.
Recommended Posts
This topic is 7033 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now