2 Replies Latest reply on May 18, 2012 2:35 PM by kayakjunkie

    Use Variable to create path for Insert File

    kayakjunkie

      Title

      Use Variable to create path for Insert File

      Post

      I'm having trouble using a variable to indicate the file to be inserted into a container field.  If I type the text into the script directly, no problem.  If I use a variable which holds the exact same string, it pops up a dialog and asks me to choose a file.

       

      Detail

      I have several thousand files with source data that has been read into my database.  These files need to be archived in case they might be needed again at some point in the future.

      I had been planning to simply keep them in a folder in Dropbox & Crashplan.  However, it appears that FMP's Container field could be very useful.  By inserting the files into a container field but using external, open storage, I have the ability to search for files from a specific day (or range of dates).

      I've generated a list of all the files (e.g. /Users/Jesse/Dropbox/Databases/Portfolio Center/Source Files/Archive/20081028.EXE) into a table.  My script will go down the list, when it finds an .EXE or .ZIP file, it takes the date portion of the file name and performs a find in the Path Field of the Table.

      This returns all the files that were available on that date, typically 3 - 6 files that were in the compressed .exe or .zip file.

      I'm then looping through the found set, picking up the file extension.  Depending on the extension, the script goes to a different field in the Source Files table and executes an Insert File script step.

      Using text functions the insert file path has been shortened to File:Source Files/Archive/20081028.EXE.

      I'm having trouble with the Insert File script step.  If I go into the Insert File script step and type in File:Source Files/Archive/20081028.EXE in the dialog for Specify source file the file is inserted into the container field.

      However if I define a variable $InsertFile = File:Source Files/Archive/20081028.EXE and type $InsertFile into the Specify source file section, I'm presented with a dialog to select a file.

      The highlighted line fails, the line below it works.  However, that isn't very useful with over 4,000 files to process.  Sigh.

       

      Insert_File_Script.png

        • 1. Re: Use Variable to create path for Insert File
          GuyStevens

          Here's an example of my filename variable:

          "imagewin:/C:/Users/Guy/Desktop/Jules Documenten/Export Foto's/" & TblSchadeFotos::SchadeFotoId & ".jpg"

          This is the variable I created.

          But better would be to create a filename and to use:

          filewin:$filename
          OR
          filemac:$filename
          as your export location. And keep the "filewin" out of the variable.

          Try it out and see if it works.

          I have made many mass exports of loads of images only to import them again "en masse."

          Do it's definately do-able.

          • 2. Re: Use Variable to create path for Insert File
            kayakjunkie

            That's the trick.  I'm not sure why there is a difference between these two expressions, however, one works and the other doesn't.

             

            Concatenating "File:" within a variable assignment doesn't work.

            • Set Variable [ $lnsertFile ; Value:File:Source Files/Archive/20081028.EXE ]
            • Specify source file dialog  $InsertFile
            • Insert File [ Table::field ; $InsertFile ]BAD!

            However, putting them together in the Specify source file dialog this way makes it go!

            • Set Variable [ $InsertFile ; Value:Source Files/Archive/20081028.EXE ]
            • Specify source file dialog File:&$InsertFile
            • Insert File [  Table::field ; &$InsertFile ]Good!
            Thank you!  DaSaint make it go!