Jump to content

Window Management in Scripts


This topic is 5766 days old. Please don't post here. Open a new topic instead.

Recommended Posts

I have an application in which I script almost everything from navigation to searching and sorting to record creation, and I have found that a huge scripting problem arises due to the windowing features of FM7. Many of my scripts are used in combination to achieve my ends, and I have found it difficult to keep track of which window is currently active and which layout is displayed in that window.

This gets particularly problematic when creating or deleting records in a script; if the window gets changed for reasons I haven't accounted for, the action will take place on the wrong table. OUCH!

One way I had been working around this was to have each script establish its own context (usually by opening a new window), but this resulted in a lot of flashy screens.

I am now considering implementing a practice of checking the current layout before doing any of these steps. Before I begin the arduous process of locating all the places I add or delete records and installing the tests, I am wondering whether anyone else has worked out a nifty solution to the problem.

TIA,

David

Link to comment
Share on other sites

The ability to have multiple windows is both a blessing and a curse. I ran into this very quickly.

For me, I set up to have one window for only one layout. In other words, each window only had the ability to "view" only one layout at any time. I named each window title according to the layout it's going to display. This adds more windows than may be desired, but at least I know what is what.

I also use a generic script to open new windows and go to the specified layout. It needs to have a parameter passed from the calling script. The parameter is the name of the layout desired. It checks to see if the window is aready opened by PatternCount ( WindowNames; Get (ScriptParameter) ). If so, goto that window. If not, open a new window and Go to Layout [Get (Scriptparameter)].

Link to comment
Share on other sites

Thanks for the tip on checking whether a window's already open; I'll look into how I might apply that. I have a similar generic Set Window script, but it doesn't check for whether the window is already open.

I've actually taken to naming my windows for the script that opens them, when the window is opened for that script's needs. That way I have a clue when I'm debugging what it's there for.

David

Link to comment
Share on other sites

This topic is 5766 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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.