10 Replies Latest reply on Aug 21, 2011 9:08 PM by LaurenceHarrould

    Send Event doesn't work if there is a space in the file name or path

    LaurenceHarrould

      Summary

      Send Event doesn't work if there is a space in the file name or path

      Version

      FM Pro 11

      Operating system version

      Win XP / 7

      Description of the issue

      I've set up a container field and have the file stored as a reference. There are 2 issues:
      1. If the file name or path contains a space it doesn't open the file
      2. Opens jpg files but not tiff or png formats even though these are registered in Windows

      Double clicking the container field works correctly for all above but not if I set up a button using the Send Event.

      Steps to reproduce the problem

      Tried with different files & paths
      Tried on different machines

        • 1. Re: Send Event doesn't work if there is a space in the file name or path
          TSGal

          Laurence Harrould:

          Thank you for your post.

          I am unable to replicate the problem with FileMaker Pro 11.0v3 on my Windows XP (SP3) machine.  I created a new script with the script step:

          Send Event [ "aevt" ; "odbc" ; "FMP Acknowledgements.pdf" ]

          (with the specific file:   file:../../../Program Files/FileMaker/FileMaker Pro 11 Advanced/FMP Acknowledgements.pdf )

          When I execute the script, Adobe Reader launches and opens the file.  I have a space in the path AND file name.

          Let me know what I'm doing differently than you, and I'll try to replicate the problem here.

          TSGal
          FileMaker, Inc.

          • 2. Re: Send Event doesn't work if there is a space in the file name or path
            LaurenceHarrould

            The following image shows the code and error messages. The code is probably a bit convoluted (I'm fairly new at FM and I was trying to find the issue)

            The first file is "Invoice details.doc"

            The second one is in the path "D:/My Docs/..."

            Other files I've used which have no spaces work OK (except for the question of file types - txt or png don't work)

            I also tried to pass the details directly from the container (Image) - see the last line of code - but that did nothing at all.

            Send Event code

            • 3. Re: Send Event doesn't work if there is a space in the file name or path
              TSGal

              Laurence Harrould:

              You should not remove the slash after the colon as you need to signify the root directory.  Otherwise, it will try to find the path in the current directory.  Therefore, change the seventh line to:

              Set Variable [ $FileName4 ; Value: Right ( $FileName2 ; $FileName3 - 8) ]

              In addition, you do not not need to remove the filewin: nor filemac: component.  You could easily use:

              Send Event ["aevt" ; "odbc" ; $FileName3 ]

              Let me know if you need additional clarification.

              TSGal
              FileMaker, Inc.

              • 4. Re: Send Event doesn't work if there is a space in the file name or path
                LaurenceHarrould

                Thanks for your suggestion. Unfortunately, this made no difference. I tried both options but no good.

                With the $FileName3 - 8 the error message was the same as before except it had "/G:" at the beginning instead of "G:"

                When I tried Send Event ["aevt" ; "odbc" ; $FileName2 ] nothing happens - no error message or anything. I assumed you meant Send...[ .., $FileName2 ] because $FileName3 is the length of the string containing the full file name.

                Interestingly, using the first option ie Send Event ["aevt" ; "odbc" ; $FileName4 ] (having stripped the "filewin:/") does work for files with no spaces in the path or name, but using Send Event ["aevt" ; "odbc" ; $FileName2 ] ie the path string which includes the "filewin:/" at the beginning does nothing at all.

                Regards

                Laurence

                • 5. Re: Send Event doesn't work if there is a space in the file name or path
                  TSGal

                  Laurence Harrould:

                  Here are the exact steps I have performed on my Windows XP SP3 machine with FileMaker Pro 11.0v3:

                  1. I created a new table:  Test1

                  2. I created two new fields:

                  PDF (Container)
                  Temp (Text)

                  3. I inserted the "FMP Acknoledgements.pdf" into the container field "PDF"

                  4. I created a script as follows:

                  Set Variable [ $FileName ; Value: Test1::PDF ]
                  Set Field [ Temp ; $FileName ]
                  Pause/Resume Script [ Indefinitely ]
                  Set Variable [ $FileName1 ; Value: GetValue (Test1::PDF ; 2 ) ]
                  Set Field [ Temp ; $FileName1 ]
                  Pause/Resume Script [ Indefinitely ]

                  Send Event [ "aevt" ; "odbc" ; "$FileName1" ]

                  Pause/Resume Script [ Indefinitely ]
                  Set Variable [ $FileName2 ; Value: Right ( $FileName1 ; Length ( $FileName1 ) - 8 ) ]
                  Set Field [ Temp ; $FileName2 ]
                  Pause/Resume Script [ Indefinitely ]

                  Send Event [ "aevt" ; "odbc" ; "$FileName2" ]

                  -----

                  I inserted the "Pause/Resume Script" steps so I could view the contents of Temp and make sure the correct information was being stored.  After the first Pause/Resume Script step, the value for Temp was:

                  filewin:/C:/Program Files/FileMaker/FileMaker Pro 11 Advanced/FMP Acknowledgements.pdf

                  After the third Pause/Resume Script step, the value for Temp was:

                  /C:/Program Files/FileMaker/FileMaker Pro 11 Advanced/FMP Acknowledgements.pdf

                  Each time, Adobe Reader launches and displays the "FMP Acknowledgements.pdf" file.

                  Make sure PDF files are set to launch Adobe Reader when double-clicked.  Otherwise, it may appear nothing has occurred since the other application may not be able to open the file.

                  TSGal
                  FileMaker, Inc.

                  • 6. Re: Send Event doesn't work if there is a space in the file name or path
                    LaurenceHarrould

                    Where did you put this script?

                    I have it associated with a button alongside the field in a portal. Double clicking the Image field itself opens the file so there's no problem with the Windows file association (that's what I'm assuming anyway). It's only when I try to use the button that I have these issues.

                    Regards 
                    Laurence 

                    • 7. Re: Send Event doesn't work if there is a space in the file name or path
                      philmodjunk

                      Hmmm, any chance the image was inserted as an object instead of as a "by reference" picture?

                      You could then still open the image by double clicking it, but your script, which doesn't check for a valid file path, BTW, would fail.

                      • 8. Re: Send Event doesn't work if there is a space in the file name or path
                        LaurenceHarrould

                        Thanks Phil. No - I'm pretty sure it's by reference. There is a shortcut/link arrow on the file image which I assume indicates that it's a reference (I tried to upload an screenshot here but it didn't work).

                        • 9. Re: Send Event doesn't work if there is a space in the file name or path
                          TSGal

                          Laurence Harrould:

                          To answer your first question, I didn't put the script anywhere.  I just executed it from the Scripts menu.

                          I put the Set Field steps in the script to make sure the information being captured was the same being executed.  They are purely for debugging purposes only.

                          TSGal
                          FileMaker, Inc.

                          • 10. Re: Send Event doesn't work if there is a space in the file name or path
                            LaurenceHarrould

                            Thanks for your responses and sorry it's taken so long to get back. I still couldn't get the Send Event to work.

                            However, the following does work using Open URL

                            OpenFileCode

                            where GetImageFileName ( $FileName ) is a custom function as follows (with parameter FieldName):

                            Right (FieldName ; Length ( GetValue ( FieldName ; 2 ) ) - 9 )

                             

                            This was given to me by Andrew McCallum from NicheIT