gephry Posted October 30, 2006 Posted October 30, 2006 I would like to write a script that returns active databases only. Meaning, I want a list of only the databases that are viewable on the main screen not ones that are currently hidden or just referenced to (i.e. in parenthesis under Window > Show Window >. I know DatabaseNames will return a list of all the databases that are open (regardless of if they are active or not)...I want something a little more specific---just the active ones. Is that possible? Thanks!
comment Posted October 30, 2006 Posted October 30, 2006 Do you mean you want only those DatabaseNames that will return true when used in not IsEmpty ( WindowNames ( fileName ) ) ?
gephry Posted October 30, 2006 Author Posted October 30, 2006 Ahha! That function description sounds about right. Yes, I only want the visible window names returned; I don't care about the minimized or hidden windows. Will it return minimized and hidden window names in parenthesis, or is there another way to determine which returned names are visible? Thank you, comment!
comment Posted October 30, 2006 Posted October 30, 2006 This may be more difficult than it seemed at first. WindowNames() does return the names of windows that have been opened AND hidden. Minimized windows are returned as well. You may be able to determine if a window has been hidden using Get(WindowVisible), but I don't know of a way to tell if a window is minimized.
gephry Posted November 1, 2006 Author Posted November 1, 2006 Perfect, that's exactly what I need. I wrote a script using that and it worked for roughly 15 minutes. Then it stopped working entirely---and I didn't change a thing. If( Get( WindowVisible ) = 1 ) { SetField [ Layout; Get( LayoutName ) & Contacts::SERIAL_Number & "¶" ]; } If the window is visible (currently in use), it's supposed to return 1 and store the current layout & record serial number to recall later when the user logs back in. I've tried 1, I've tried "1".....nothing is getting it to work again. I'm totally stumped and irked. This occurance of "The script is working! Wait now it's not working..." thing has happened to me a lot recently with FM8. All due to If() statements returning a False when it should be returning True. Why is this happening? Does it have to do with me developing for a server database on a client machine? If so, that shouldn't make a script be inconsistant....would it?
Tim W Posted November 1, 2006 Posted November 1, 2006 (edited) Globals in a single user environment retain their value from session to session, but in a multi-user environment they are cleared after each session (technically reset to the value last used in single user mode). Stored values are not user specific, any user can change them. To hold a value specific to each user in a multi-user environment requires a user table holding that user's stored value in that user's record. If so, that shouldn't make a script be inconsistant....would it?Using global from single user to multi-user can do that for you & catches us all from time-to-time. HTH, Tim Edited November 1, 2006 by Guest
mr_vodka Posted November 1, 2006 Posted November 1, 2006 Just to elaborate on what Tim said, Globals in a single user environment retain their value from session to session, but in a multi-user environment they are cleared after each session Global fields in a multi-user environment will retain the value of the value that has been set in that field when it starts hosting the files. In other words, if gFieldA's value is set to 2 when the file starts hosting, even if one of the end users that are sharing it changes the value, of that field during the course of his/her use, when they close the shared file and reopen it, it will default back to 2. To change the default value of 2, you must stop hosting the file, make your changes, and start hosting it again. A good whitepaper to read is here.
gephry Posted November 1, 2006 Author Posted November 1, 2006 Yes, I understand that. And that would of course apply to client/server machine inconsistancies; but in this case, I'm not using globals. I'm talking about what the IF() statements are returning. They are returning False when it should be True. For example: On the window named "Contacts" (which is visible) I run a script that asks: If( Get( WindowVisible ) = 1 ) { SET[ FIELD; "VISIBLE" ]; } The problem is, the window IS visible, but it's returning False, as if the window weren't visible. So it's not putting the value I want in FIELD. Make sense? (FYI I'm running 8.0v3 on G4 running Mac OS 10.4.8)
comment Posted November 2, 2006 Posted November 2, 2006 Assuming your syntax is correct (it doesn't seem to be), you could take this further by testing WHICH window is being interrogated, e.g. Set Field [ gTest ; Get(WindowVisible) & " " & Get(WindowName) ]
Tim W Posted November 2, 2006 Posted November 2, 2006 How does this script get triggered? According to the description of this function, the current window is the window upon which the script is acting, not necessarily the foreground window? Is there any possiblity this could be a path to the answer for the wrong result being returned? The result is numeric, so no need for quote marks. Let me know, Tim
gephry Posted November 4, 2006 Author Posted November 4, 2006 My syntax should be correct, I just shortened it (C++ style) because I think it's easier to post/read. My apologies if it was confusing. (Thanks for all your help thus far, guys, I appreciate it.) Tim W wrote: According to the description of this function, the current window is the window upon which the script is acting, not necessarily the foreground window? True. The Get( WindowVisible) returns 1 if the window is visible and 0 if the window is hidden (via Filemaker "Hide Window" function). So it doesn't matter which window is in the foreground---in whichever window the script is running, if it is visible, it should return true. Comment---I did your testing and it is returning the desired database. It returned "1 StaffList" meaning "True StaffList" --- so that's what I want. The script (in StaffList) is triggered via a script in another database (MainMenu). The person logs out of the MainMenu and the On Close script triggers the "Store Last Record" script in StaffList database. That script then stores the last place that person was in StaffList. The "Store Last Record" script in StaffList is: IF[ Get( WindowVisible ) = 1 ] Set Field[ StaffList_Username::StoredDatabaseRecordLocation & Get( WindowName ) & "$$" & Get( LayoutName ) & "%%" & StaffList::RECORDSERIAL_Number; ] ELSE #Do Nothing END IF Humm....now it's working and I have changed nothing...maybe my syntax IS incorrect. Before I had stuck a "Show Custom Dialog" inside the If[ Get( WindowVisible ) = 1 ] but it wasn't showing the dialog message. So I was certain it was returning false. And now, strangely enough, it's working with quotations: IF[ Get( WindowVisible ) = "1" ].....
comment Posted November 4, 2006 Posted November 4, 2006 Get(WindowVisible) returns a number result, so the quotes are redundant, though harmless. In fact, since the result is either 0 or 1, the test can be simply: If [ Get(WindowVisible) ]
Recommended Posts
This topic is 6596 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