6 Replies Latest reply on Oct 16, 2016 7:47 PM by philmodjunk

    Using variables as a file path in Set Variable command

    embeco

      FM 15 Advanced - I am storing my value lists in a separate file (Value Lists). Problem: I want to allow my user to edit the value lists much as the Value List Custom Values feature does. I can certainly do it with hard coded script and layouts, but I would like one layout and one script that can determine which field is asking for the edit, load the appropriate values from the Value List table, display them, let the user change it and replace the edited entries back into the Value List table.

       

      I get very close (and why doesn't this screen allow a cut and paste of our FM scripts???). I can determine the active field and store the Value List file path in a variable but when I go to store the contents of the Value List field in a variable, the Set Variable command fails

           SET VARIABLE ($$ValueListContents; Value: $$ValueListTableFilePath)

      The Value Lists table contains up to 25 fields each representing value lists from 25 different fields on the data entry screen. $$ValueListFilePath contains "Value Lists::Driveway Type Other" (value list entries for the entry field on the screen).

       

      I'm sure that the script genies can solve this in a flash or I'm going to be coding into the night creating scripts for each of the 25 entries.

        • 1. Re: Using variables as a file path in Set Variable command
          wimdecorte

          It's not clear what you expect here, can you show us what you are setting $$ValueListTableFilePath to?

          • 2. Re: Using variables as a file path in Set Variable command
            philmodjunk

            $$ValueListFilePath contains "Value Lists::Driveway Type Other"

             

            Would seem to be the crux of the matter. If that's the case, then the value of the variable is the quoted text shown, not the values found in that field.

             

            Evaluate ( $$ValueListFilePath ) will return the contents of the Driveway Type Other field

             

            GetField ( $ValueLsitFilePath ) can do so as well.

             

            But even that may not be what you want depending on context and what you want to see in the $$ValueListContents variable. If you want to see all the values in all the recors of Value Lists, then you will need a function and a context that produces that as a list. The List function could do that if executed from the context of a related table occurrence. ExecuteSQL can also produce such a list and not be dependent on a particular context unless you also specify an optional parameter.

            • 3. Re: Using variables as a file path in Set Variable command
              embeco

              That was just what I needed. It worked like a champ. Thank you so much.

              • 4. Re: Using variables as a file path in Set Variable command
                embeco

                Thanks for the reply. I just needed a "GetField($$ValueListFilePath)" to do

                the trick.

                 

                 

                 

                (this was the file path to my Value List table with the correct field name -

                I forgot to mention that my Value List field names match the field names of

                the screen where data is entered).

                • 5. Re: Using variables as a file path in Set Variable command
                  keywords

                  Re: "why doesn't this screen allow a cut and paste of our FM scripts???" I find the easiest way to do this is as follows:

                  1.     With the script open in the Script workspace, choose Print

                  2.     In the Print dialog, open the PDF dropdown at bottom left and choose Open PDF in Preview

                  3.     Select All and copy (you can then close the Preview version without saving if you don't need it again)

                  4.     Paste into your text box here

                   

                  The above is using a Mac. On Windows the process will be different, although there is doubtless some similar option available (or maybe not, as is sometimes the case with Windows).

                  • 6. Re: Using variables as a file path in Set Variable command
                    philmodjunk

                    You can also copy/paste a script from a Database Design Report. I've even got a file somewhere where I can paste that text into it and a custom function "pretty prints" it to put in some indenting similar to what you see in the scripts workspace.

                     

                    For short scripts, an even easier way is to do a screen capture of the scripts workspace and then use the picture tool to add that to your post as a picture.