5 Replies Latest reply on Aug 9, 2009 1:07 PM by metroart

    Variable File paths

    metroart

      Title

      Variable File paths

      Post

      Output script steps (e.g. Export Records, Export Field Contents, Save Records as PDF) all allow you to set a Variable file path ($Variable), but none of the input script steps (Import Records, Insert Picture, Insert File, etc.) have this ability.
       
      Even though my script can specify the folder from which to import the data, FM won't let me -- FM forces users to navigate the path to the folder manually (at least the first time the script executes) in the "Browse for Folder" dialog -- beginning with the default folder - on my Windows pc, it's My Documents - so you have to click My Computer, click Local disk (C:), click click etc.    
       
      My solution relies heavily on importing data from many different folders. All I can think of to simplify this tedious process is to copy each folder path to the clipboard, so my users at least have the option of pasting it into the Folder field in the dialog and clicking Ok to locate the folder.
       
      Is there a workaround that would allow this instead to be done automatically by a script?

        • 1. Re: Variable File paths
          comment_1
            

          metroart wrote:
          none of the input script steps (Import Records, Insert Picture, Insert File, etc.) have this ability.

          They do.


          • 2. Re: Variable File paths
            metroart
              

            They do?

             

            Can you give me an example, say, for the Import Records script step? How do you get Import Records to automatically open a folder whose path is variable, i.e. based dynamically on input from the user rather than on a stored list of pre-determined paths? 

            • 3. Re: Variable File paths
              comment_1
                 Those are two different things. The Import Records[] step can use a script variable for the source file path - same as Export Records[] can use a variable for the target file. Neither will let you specify a folder from which the user can choose.
              • 4. Re: Variable File paths
                  

                You could use the troi-file-plugin to have the user point to a folder using an initial location:

                 

                To import a file:

                Use TrFile_SelectFileDialog( switches ; prompt ; { initialFolder } ) the user can now select a file starting from an initial position you've entered in the  "initialFolder" space. The result is a full path to a file in the standard OS-format ... you could then simply change the format to the format needed for Filemaker and put that into you variable that selects the file.

                Example: C:\Documents and Settings\metroart\My documents\Importfile.xls must be converted to: file:/C:/Documents and Settings/metroart/My documents/Importfile.xls

                 

                To export a file:

                TrFile_SaveFileDialog( switches ; prompt ; { defaultFilename ; { initialFolder } } ) the user can now select a location starting from the initial position you've entered in the "initialFolder" space. You should also fill the defaultFilename so the user can simply click "OK". The result is similar to the result of the "SelectFileDialog"-function.

                 

                There are other plugins available (some maybe for free) that might do the same trick in a similar matter :smileywink: , but personally I use (and prefer) Troi

                 

                regards, Menno

                • 5. Re: Variable File paths
                  metroart
                    

                  Yes, that's what I want to do. Thanks.