6 Replies Latest reply on May 10, 2010 10:47 AM by icecreamboy

    Word bank?



      Word bank?




      I'm using FM11 Pro Advanced, on Windows XP.


      I was wondering, is there any way to create a kind of word bank? I'm doing a project for doctors and sometimes words can get difficult to remember or spelling may be difficult, but the point is, I would like to create something to the effect of this description:


      There could be a button somewhere, that upon clicking, maybe a small window pops up with a list of pre-defined words. Clicking on any of the words will insert that word as text into the last field that was active. For example, I'm typing up some notes in a "Notes" field and I come to a part where I need to insert SomeComplicatedWord. I'll click on the button, the list of words will come up, and when I click on SomeComplicatedWord, it'll be inserted into the "Notes" field where I was working on.


      This is an example, but the button/list of words could be a drop-down list or something. Does anyone have a solution for this? (I don't know but I feel the tricky part might be the last-active-field part. If this isn't possible, is it at least possible to have the rest, but the field that the text is inserted into is pre-defined?)


      Thanks for any help, I appreciate it :)

        • 1. Re: Word bank?

          Something along these lines:


          Set Variable [ $field ; Get( ActiveLayoutObjectName ) ]
          Set Variable [ $cursor ; Get( ActiveSelectionStart ) ]


          Pop up your window here and Pause

          When user clicks, set a $word variable

          Go to Object [ $field ]
          Set Selection [ Start: $cursor ]

          Insert Calculated Result[ $word ]

          • 2. Re: Word bank?



            Thanks for your suggestion, it looks great. I could really use some help for the middle part though. This is what I have so far, I know it's not much different from what you already gave:


            Set Variable [$field; Value:Get( ActiveLayoutObjectName )]

            Set Variable [$cursor; Value:Get( Active SelectionStart )]

            New Window [Name: "Word Bank"; Height: 300; Width: 300; Top: 100; Left: 100]

            Go to Layout ["Word Bank" (Patients)]


            --this is where I get stuck--


            I'm not sure how to go about getting the script to pause until a word in the "Word Bank" layout gets clicked. I imagine that I would set each word in the "Word Bank" layout to have a button-function of Set Variable to $word, but how do I get it to know to go back to close the "Word Bank" window, go back to the original window, and set the variable $word?


            I'm guessing that the Pause/Resume Script come into play here, but I'm not sure how to resume the script after the user chooses a word, either.



            • 3. Re: Word bank?

              There are a couple of patterns I like to use for pop-up windows.


              One is to keep the script paused until the user makes a selection. A Loop works well:




              ### here is where the user clicked a button (see below) ###

                Set Variable[ $word ; Get( ScriptResult ) ]

                Exit Loop If[ not IsEmpty( $word ) ]

              End Loop


              Now, to get out of the loop, the user must click a button.

              You should have two buttons on your Word Bank layout:

              - a Cancel button (in the header or footer)

              - a button on the word list to select the word


              These buttons each run a script we'll call Parameter Passer, which has a single step:

              Exit Script[ Get( ScriptParameter ) ]


              That's the other key piece of this. The Cancel button should call the script with the parameter "cancel," and the word button's parameter is the word from the field. Both buttons should RESUME the current script.


              Now you can close the window.


              Next you would see if Cancel was clicked:

              If[ $word = "cancel" ]

                Exit Script

              End If


              And now you can finish off as in my original reply.

              • 4. Re: Word bank?

                Thanks Fitch, this is really working well, but there are a couple small kinks I can't seem to work out:


                When I click the Word Bank button, the original window becomes un-maximized. I tried to do a Freeze Window and it still un-maximizes. How do I keep the original window maximized while the new window appears? Or if this isn't possible, how do I re-maximize the window when the new window closes?


                When I click on a word in the new window, the new window doesn't close by itself. I have to close it manually.


                Upon closing the new window manually, the original script is paused and it has a button at the top right "Script paused [Continue] [Cancel]", and only when I click the "Continue" button does the word now appear in the last active field.


                Here are the scripts so far:


                *Word Bank*


                Freeze Window

                Set Variable [$field; Value:Get( ActiveLayoutObjectName )]

                Set Variable [$cursor; Value:Get( ActiveSelectionStart )]

                New Window [Name: "Word Bank"; Height: 300; Width: 300; Top: 100; Left: 100]

                Go to Layout ["Word Bank" (Patients)]


                   Pause/Resume Script [Indefinitely]

                   Set Variable [$word; Value:Get( ScriptResult )]

                   Exit Loop If [not IsEmpty( $word )]

                   Pause/Resume Script [Indefinitely]

                End Loop

                If [$word = "cancel"]

                   Exit Script []


                   Go to Object [Object Name: $field]

                   Set Selection [Start Position: $cursor]

                   Insert Calculated Result [$word]

                End If


                *Parameter Passer*


                Exit Script [Result: Get( ScriptParameter )]



                Thanks again!

                • 5. Re: Word bank?

                  You have an extra Pause before the End Loop.

                  You should close the Word Bank window after the End Loop (and re-maximize, see below).


                  Make sure your word selection and Cancel buttons (that call the Parameter Passer script) are set to Resume the current script.


                  As far as the window behavior, that is a lameness of Windows that you just have to deal with. You can use Move/Resize Window on your main window before you open the new window, to make the un-maximize less jarring. (Hint: check out the Get(WindowHeight) and Get(WindowWidth) functions.) After closing the Word Bank window, use Adjust Window to re-maximize.

                  • 6. Re: Word bank?

                    Thank you very much Fitch :)