{{tag>category:"OpenInsight Specific"}} [[https://www.revelation.com/|Sign up on the Revelation Software website to have access to the most current content, and to be able to ask questions and get answers from the Revelation community]] ==== Gotfocus Event (OpenInsight Specific) ==== === At 22 FEB 1998 06:58:33PM Richard Richter wrote: === I know I asked this question before, but I'm still having the problem and would really appreciate some help. I am having a problem when running a GOTFOCUS script. This is the code from the event: Declare Subroutine Get_Property,Set_Property,Forward_Event,Send_Event Declare Function Repository,Send_Event,Forward_Event,IndexLookup AG=Get_Property(CtrlEntID1,'F.':".ACCT_GUAR","TEXT") If AG=" Then RB=Repository("EXECUTE","DENT*MSG**ACCT_GUAR",@WINDOW,"") Begin Case Case RB=1" ; * Self Selected v=Set_Property(CtrlEntID1,'F.':".ACCT_GUAR","TEXT",@ID) AG=@ID Case RB=2" ; * Other Selected Retval=IndexLookup(CtrlEntID1,'F.','PATIENT','FIRST_NAME_XREF':@VM:'LAST_NAME_XREF','FIRST_NAME':@VM:'LAST_NAME','SINGLE','') v=Set_Property(CtrlEntID1,'F.':".ACCT_GUAR","TEXT",Retval) AG=Retval Case RB=3" ; * Cancel Button Send_Event(CtrlEntID,"GotFocus") End Case End If Num(AG) Then Pat=Xlate("PATIENT",AG,"","X") Set_Property(CtrlEntID1,'F.':".ACCT_GUAR_TEXT","TEXT",Pat:", ":Pat) End Else Set_Property(CtrlEntID1,'F.':".ACCT_GUAR_TEXT","TEXT","") End RETURN 0 It is designed to find if the record is a new entry and if it is a new entry to then determine who is responsible. A message is executed called "ACCT_GUAR" that returns the result RB. RB can be either 1, 2 or 3. If RB is 1 then the current editline is set to the key of the current record. If RB is 3 then the event is repeated. My problems arise when RB=2. The IndexLookup works fine until the Selection List popup appears. The data in the selection list is correct but at the same time, and before I can make a selection, the ACCT_GUAR message popups again and has the focus. I have to select the button that returns RB=1 and then I can select the row from the Selection List. What am I doing wrong that makes this window continually reappear. When I posted this question before, Aaron Kaplan suggested that I open the System Monitor and enter SETDEBUGGER'SPY'0. When I try this I get the following error message: SYS1244: The script contains an invalid character. I would appreciate any and all help I can get. This is driving me crazy! Richard ---- === At 23 FEB 1998 08:53AM Aaron Kaplan wrote: === It seems like part of what's happening is that the control is getting focus again and running through the script. What you should do is check for a flag in the gotfocus. If that's set, then you've already gotten focus, so don't run through the script again. Clear the flag during a lost focus. Be carefull though, since you might end up with a lost-focus event when the message or index lookup box appears. You might have to block events or qualify the lost focus while this is processing. apk@sprezzatura.com [url=http://www.sprezzatura.com]Sprezzatura, Inc.[/url] [img]http://www.sprezzatura.com/zz.jpg[/img] ---- === At 23 FEB 1998 06:51PM Richard Richter wrote: === Aaron, Thanks for your advice. The problem is you're advising an idiot. How do I check for a flag? When I find a flag, how do I clear it? I told you I was an idiot. Thanks again for your help. Richard Richter ---- === At 23 FEB 1998 11:01PM Aaron Kaplan wrote: === A flag is variable that holds a status. Generally, it's a true/false sorta thing. Is it visible, yes or no? Is it enabled? Is it read-only? Is it locked? The list goes on. These are system type flags though. You can set up a flag for anything. One thing would be have I done the gotfocus for this control yet. The answer would be true or false. So, on the start of your GOTFOCUS you would set a flag saying that you've already gotten focus this time out. UnUsed=Set_Property( CtrlEntId, '@BEEN_THERE_DONE_THAT', True$) You now have a flag that says you've been in the GotFocus event. What you need to do now is check it when the event starts and not continue if it's set. AlreadyGotFocus=Get_Property( CtrlEntId, '@BEEN_THERE_DONE_THAT') If AlreadyGotFocus then     RetVal=False$ End Else     *process what you were before, but be sure     *to have a RetVal=True$ in the tt     *and set the flag from above! End Return RetVal After all this is done, you need to clear the flag in the LostFocus event. You can probably see where this is going, but you'd clear the flag by UnUsed=Set_Property( CtrlEntId, '@BEEN_THERE_DONE_THAT', False$) What's happening is that after the GotFocus is run, you're loading up a dialog and a message and a few other things. These other things are all getting focus. So, when you finally make your way back to the control, it's gotten focus. This means it needs to run the gotfocus event and so on and so on and so on. The flag jumps in and tells your code not to execute and not really do anything at all. On the gotfocus you clear the flag since you want to run the code the next time you actually go to the control. Theoretically, this should work fine. I've done this with pre-prompt events in ARev more times than I care to count. What I'm a little concerned with is whether it will work this cleanly in OI. When these other little things pop up, it might fire off a lost focus to the control. If that happens, then we'll have to work on blocking that event from happening in the short run. We'll cross that bridge when we come to it though. apk@sprezzatura.com [url=http://www.sprezzatura.com]Sprezzatura, Inc.[/url] [img]http://www.sprezzatura.com/zz.jpg[/img] ---- === At 26 FEB 1998 06:55PM Richard Richter wrote: === I want you to know how much I appreciate your help. The next time I'm in England, I'll by you all the pints you want! Unfortunately, adding the flag made no difference. I'm still getting that uncalled for message. Are there any other ideas out there? Richard Richter ---- === At 27 FEB 1998 09:04AM Aaron Kaplan wrote: === Only thing I can suggest is that, if you want, and I'm not saying you should, but if you want, you could maybe send to me a copy of the window and code and I'll look through it. I don't want you to put yourself out, so don't go to any trouble, it's not like I don't have enough to do, but, for you, tzachkela, I'll find the time. Seriously, I'm kinda curious as to what the deal is, so if you want to whip something up that will duplicate this, and it small enough to e-mail, go for it. Don't forget dictionaries, indexes and whatever else might be needed to get it to run. Small enough is about 1 meg, zipped. apk@sprezzatura.com [url=http://www.sprezzatura.com]Sprezzatura, Inc.[/url] [img]http://www.sprezzatura.com/zz.jpg[/img] [[https://www.revelation.com/revweb/oecgi4p.php/O4W_HANDOFF?DESTN=O4W_RUN_FORM&INQID=NONWORKS_READ&SUMMARY=1&KEY=07FD5D35E66C8107852565B30083B40E|View this thread on the forum...]]