KurtW Posted July 15, 2004 Posted July 15, 2004 Hi: Get (WindowName), according to FM: "Returns the name of the window that the script is acting on (not necessarily the foreground window)." I have created a floating menu that can appear alongside many different layouts as a new window. They share screen space. I have a 'Print' button on the floating menu that I would like to affect whatever OTHER window is present. Is there a way to determine that other window's name programatically? Since the script for 'Print' will only work on the window it resides in, without specifically naming the other window, is there a method to grab the names of all open windows, then subtract the known Menu window mame from that list? Doesn't look so. Anyone else have a method to do this so that my floating menu can work on whatever window it is placed with? Thanks Kurt
KurtW Posted July 15, 2004 Author Posted July 15, 2004 Found the WindowNames calc function which returns the names of all windows open. I suppose I can combine that with text functions as a comparison. But does FM use arrays when storing multiple items? FM says it will return the names of the windows separated by carriage returns, but how does that allow for looping and individual comparison like an array?
Fenton Posted July 15, 2004 Posted July 15, 2004 It's just a 1 column "array". But if you put it into a text field, with global storage, then you can do whatever you want. PatternCount ( "
KurtW Posted July 15, 2004 Author Posted July 15, 2004 Thanks Fenton: This sort-of works for me: Set Field[Trips::gWindowName; Middle(WindowNames; Position(WindowNames; "Menu Right"; 1; 1); 10)] My logic being that window: Menu Right must always remove itseld from a list of open windows to determine whatever is left. What is left is obviously the 'other' open window. And that script seems to work (even though I did nothing to remove the HR's between.) But it assumes that there are only TWO windows open at any given time: the Menu Right and windowX. I will control my environment so that this is actually the case at all times. In other circumstances I would feel better if I had a more generic function to account for multiple open window, but with things like Print I will only want to print one particular screen at a time, so keeping just two windows open is good for now. But for other functions, like resetting the DB back to a 'park' position where I might want to close all open windows (except my target), how could I do that using the list of windows I have stored in the global field? I suppose I could loop through the list, but can't figure out how to create the counter value. Windows: Invoices, Menu Right, Open Schedule account for 5 words, but only 3 windows, so word count won't work. Unless I underscored spaces! Now Menu_Right is 1 word, so a word count would create a loop counter. Does that sound right? Kurt
Fenton Posted July 16, 2004 Posted July 16, 2004 Look in the Text functions at the new Values functions. They make working with return-separated lists much easier. As far as removing a known window name, I would use the Substitute function. Substitute ( WindowsNames & "
KurtW Posted July 16, 2004 Author Posted July 16, 2004 Thanks Fenton: I think I follow your examples. Am going to try them out. I'm getting there, but it's been a bit awkward converting what I can do with SQL and VBS to FM scripting. Luckily the basic logic driving it all is the same, it's just the path there that changes. I have a follow up question: You say all calculations must be unstored, but if I am doing some of these text calculations on the WindowNames list AS I place it into a global, isn't the fact that the field is a global a type of storage? Just curious. Kurt
KurtW Posted July 16, 2004 Author Posted July 16, 2004 Hmmm - script seems to break down as loop is started. No windows are closed. I assume it has to do with the fact that I am using globals to store the temp calcs used in the script. (Stored, as you mention not to do.) But I was under the impression that was exactly what globals were for? Kurt
-Queue- Posted July 16, 2004 Posted July 16, 2004 You don't appear to be initializing gAllWindowsCount, which you are using to determine when to exit the loop.
KurtW Posted July 16, 2004 Author Posted July 16, 2004 Queue: You are right on. I didn't initialize the field. However, having done that now, I have debugged and found that there is odd breaking in the window names passed to the Close Window function. I have altered the script that creates the window name so my 'Menu Right' is now 'Menu_Right' in hopes of creating one text value of the name. But that doesn't seem to help. When this script grabs all window names, it returns: 'Menu_Right' and 'Invoices', as it should. But when the DEBUG inside the loop fires, at point of window closing, the Close Window[] is trying to close 'Menu' and 'Right' as the two windows. For some reason it is breaking 'Menu_Right' at the underscore (or the space when I had just space between the.) I have placed a new screen shot below. The function I use to pick the window names from gAllWindowNames looks right to me....
-Queue- Posted July 16, 2004 Posted July 16, 2004 I believe MiddleValues will return a result with a carriage return at the end. Try Substitute( MiddleValues( Trips::gAllWindowNames; Trips::gLoopCounter + 1; 1 ), "
KurtW Posted July 16, 2004 Author Posted July 16, 2004 Hmm - I'll give that a shot. But I'm curious... Even if it adds a return to the end, why would middle values break my window names at all? Even when I added the underscore? Weird. Trying it now.
KurtW Posted July 16, 2004 Author Posted July 16, 2004 Okay, I see.... That worked. But my DEBUGs kept returning the broken window names, until I realized I used MiddleValues for the WindowClose function, but MiddleWords for the DEBUGs. Apparently MiddleWords was part of the issue, at least for debugging, but your Substitute suggestion was what made it all go. I will have to look at both Middle... functions to see how they differ more subtley. Many thanks. Kurt
-Queue- Posted July 16, 2004 Posted July 16, 2004 MiddleWords will break text up by spaces, underscores, and other characters, depending on one's system format. MiddleValues breaks up text by carriage returns only (
Recommended Posts
This topic is 7438 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