7 Replies Latest reply on Oct 22, 2013 8:48 AM by philmodjunk

    trim function help

    ryandunne_1

      Title

      trim function help

      Post

           hi all im having a little trouble with the trim function and cant work out how to build it i basicly need to trim the design id out of this long string so i need to trim it to 111616 but it isnt always a certain position from the left or right or in the middle so none of the trim functions fit what i need to trim can anyone help me with the exact function this needs to be?

            

           (banner name: hajj mubarak mum and dad, design id: 111616, width: 1828, height: 610, product: Standard PVC Banner, SRV_VER: V4, order id: 38042;)

            

            (banner name: B&Q JOBS, design id: 111662, width: 3657, height: 1067, product: Standard PVC Banner, SRV_VER: V4, order id: 38058;)

            

           cheers

           ryan

        • 1. Re: trim function help
          philmodjunk

               The trim functions remove the space character from text.

               presumably, the value you want to extract is always preceded by the text: "design id:".

               Let ( [ T = YourTextFieldHere ;
                         L = Length ( T ) ;
                         P = Position ( T ; "design id:" ; 1 ; 1 ) ;
                         R = Right ( T ; L - P )
                        ] ;
                        MiddleWords ( R ; 3 ; 1 )
                       ) // Let

               There's also a custom function named "Parse" that Filemaker Advanced users can, I believe, copy from the Brian Dunning site for custom functions that can be used for this.

          • 2. Re: trim function help
            ryandunne_1

                 ok i tried to well copy and paste that into a set variable and made a variable $$image changed yourtextfieldhere to the field import::item name and it returns nothing when i imediatley in the same script do set field with the id $$image

            • 3. Re: trim function help
              philmodjunk

                   The calculation works. I tested it before posting.

                   I suggest posting the script if you can't find the syntax error responsible for your null result.

                   To post a script to the forum:

                     
              1.           You can upload a screen shot of your script by using the Upload an Image controls located just below Post A Answer.
              2.      
              3.           You can print a script to a PDF, open the PDF and then select and copy the script as text from the opened PDF to your clipboard for pasting here. (with this approach, you can get multiple script steps on the same line, please edit the pasted text by inserting some returns to separate those steps.)
              4.      
              5.           If You have FileMaker Advanced, you can generate a database design report and copy the script as text from there.
              6.      
              7.           If you paste a text form of the script, you can use the Script Pretty box in the Known Bugs List database to paste a version that is single spaced and indented for a more professional and easier to read format.
              • 4. Re: trim function help
                ryandunne_1

                     get design id
                     Set Variable [ $$image; Value:Let ( [ T ="import::ItemName" ;L = Length
                     ( T ) ; P = Position ( T ; "design id:" ; 1 ; 1 ) ; R = Right ( T ; L - P ) ] ;
                     MiddleWords ( R ; 3 ; 1 )) // Let ]
                     Set Field [ import::images; $$image ]

                      

                     thats the scipt printed to pdf and copied and pasted here

                • 5. Re: trim function help
                  philmodjunk

                       Please remove the quotes from around import::itemName. Your calculation is parsing the literal text "import::ItemName" instead of the text stored in the field of this name.

                  • 6. Re: trim function help
                    ryandunne_1

                         last question can i grab an image from a url?

                    • 7. Re: trim function help
                      philmodjunk

                           In Filemaker 12, you can use Insert from URL to insert an image into a container field, but you need the URL that points to the image file, not the web page on which the image is placed.