1 2 Previous Next 16 Replies Latest reply on Jan 8, 2010 12:49 AM by comment_1

    Save error capture to record

    jla_1

      Title

      Save error capture to record

      Post

      I'm trying to save the field contents from an export image script to a record or list when an error is encountered.  Using the Export Field Contents in a loop, I recurse through the records and export the images to a folder.  When an error is encountered, the script halts.  I used Error Capture on to suppress the error, but I would like to save the the name of the image that created the error (eg; missing) to a list or table/record.  I was trying something like:

       

       Set Error Capture [On]

      --

      --

      --

      loop for image export

      --

      --

      Set Field[IMAGES::errorcapture; Get (LastError)]

      If[IMAGES::errorcapture<>0]

        Set Field[IMAGES::errorimages; GetAsText(IMAGES::Image1)]

      End If

       

      But this appears to be way off mark.  Thanks for any input.

        • 1. Re: Save error capture to record
          philmodjunk
            

          That looks pretty close to what you need. Using your script as written, you'd want to perform a find to locate all records where IMAGES::errorimages is not blank to see a list of all problem containers.

           

          IF this doesn't work for you tell us how it isn't working. Perhaps there's some script detail left out of what you posted that's keeping it from working for you.

           

          • 2. Re: Save error capture to record
            ninja
              

            You may already have it this way, but I would think you'd want a New Record step and your Setfield step within the export loop in case multiple images create an error.  I don't see where you're creating the record to store the image reference with the errors...

             

            Said new records could have an autoenter timestamp so you can separate out which errors happened during a given export batch.

            • 3. Re: Save error capture to record
              jla_1
                

              Thanks for the input.  This is the script as it is now:

               

              • Set Error Capture [ On ]
              • Set Field [ IMAGES::_gSelectedFolder; Moo_DialogFolder(IMAGES::null;True) ]
              • If [ PatternCount ( IMAGES::_gSelectedFolder; "Moo_DialogFolder|Err_2") >0 ]
              •  Halt Script
              • Else
              •  Set Variable [ $path; Value:IMAGES::_gSelectedFolder ]
              •  Go to Record/Request/Page[ First ]
              •  Loop
              •  Set Variable [ $file; Value:"filewin:/" & $path & "/" & GetAsText ( IMAGES::IMAGE1) ]
              •  Export Field Contents [ IMAGES::IMAGEDISPLAYX; “$file” ]
              •  Go to Record/Request/Page[ Next; Exit after last ]
              •  End Loop
              •  Set Field [ IMAGES::errorcapture; Get ( LastError ) ]
              •  If [ IMAGES::errorcapture <> 0 ]
              •    Set Field [ IMAGES::errorimage; GetAsText ( IMAGES::IMAGE1 ) ]
              •  Else
              •  End If
              • End If
               
              I wasn't aware I could create records in a different table at the same time a script is working on set of records from a different table.  Ninja, do you mean I should have the errorimage in whole different table to create the records for the jpg number?  The way I have it set up it, I put the errorimage on the layout to see what was being put there, and it works but only fills the last field with the last record/image not exported and cycling back through the records, it's blank.  I'm not sure I'm wrapping my head around a solution.

               

              • 4. Re: Save error capture to record
                comment_1
                  

                jla wrote:

                it works but only fills the last field with the last record/image not exported


                Well, your error handling is outside the loop. Why don't you try something like:

                 

                Set Error Capture [ On ]
                ...
                Go to Record/Request/Page[ First ]
                Loop
                Set Variable [ $file; Value:"filewin:/" & $path & "/" & GetAsText ( IMAGES::IMAGE1) ]
                Export Field Contents [ IMAGES::IMAGEDISPLAYX; “$file” ]
                #
                If [ Get ( LastError ) ]
                Set Variable [ $error; Value:$error & IMAGES::ImageID & ¶ ]
                End If
                #
                Go to Record/Request/Page[ Next; Exit after last ]
                End Loop
                ...

                Now you have all the ID's of the problematic records in a variable, and you can do whatever you like with them.

                 








                • 5. Re: Save error capture to record
                  jla_1
                     Ok, I added the script steps as you suggested comment and put a setfield[errorimage;$error] to capture the list to a field (I don't any other way to get information).  Should I create a whole new table just to create the record for that?  As it is now, I get how ever many records are in the db and the last one has the information in the errorimage field.  Is there another way to get that variable data into a list or report?  Thanks
                  • 6. Re: Save error capture to record
                    comment_1
                      

                    jla wrote:
                    I get how ever many records are in the db

                    All of them? Wouldn't it be better to address the real issue, instead of documenting it?

                     

                     


                    jla wrote:
                    Is there another way to get that variable data into a list or report? 

                    You can continue the script by going to another table and loop, creating a new record for each item in the $variable.

                     

                    • 7. Re: Save error capture to record
                      ninja
                        

                      A curiosity since I've not used the Get(LastError) function much {read "ever"}.

                       

                      In a loop like this, would the Get(LastError) 'self-clear' when the script goes through the next round?

                      Or would the LastError be set by the first image causing an error and then trap all following records?

                       

                      • 8. Re: Save error capture to record
                        jla_1
                          

                        comment wrote:


                        jla wrote:
                        I get how ever many records are in the db

                        All of them? Wouldn't it be better to address the real issue, instead of documenting it?

                         

                         

                        I'm not sure what you mean by that.  Maybe I didn't explain what I was getting properly.  I had put a field at the bottom of the export layout to capture the $error variable.  For each record that is exported, it puts the $error in there, starting at the first record, it only puts in one item, then increments for each record that is exported so by the final record the field has the final count.  I figured out that I had put the setfield inside the loop instead of after, so that took care of that.  Thanks.


                        jla wrote:
                        Is there another way to get that variable data into a list or report? 

                        You can continue the script by going to another table and loop, creating a new record for each item in the $variable.

                         


                        Does filemaker support a way to do this during the loop of the export concurrently? 

                         

                         


                        • 9. Re: Save error capture to record
                          jla_1
                            

                          Ninja wrote:

                          A curiosity since I've not used the Get(LastError) function much {read "ever"}.

                           

                          In a loop like this, would the Get(LastError) 'self-clear' when the script goes through the next round?

                          Or would the LastError be set by the first image causing an error and then trap all following records?

                           


                          From what I've seen, it grabs the last error it encountered and is overwritten with any new errors, hence comment's suggestion to put it in the loop and keep a running tab in a variable. I was surprised you could use a pilcrow to organize the variable data.

                           


                          • 10. Re: Save error capture to record
                            comment_1
                              

                            Ninja wrote:

                            would the Get(LastError) 'self-clear'


                            It clears (or rather resets to 0) whenever a script step executes without error (except script control steps in version 10).


                            • 11. Re: Save error capture to record
                              comment_1
                                

                              jla wrote:

                              I'm not sure what you mean by that. 


                              I mean why do you get errors?

                               

                               


                              jla wrote: 
                              Does filemaker support a way to do this during the loop of the export concurrently?

                              You mean create a new record in another table as part of the export loop? Sure, you can do that.

                               


                              • 12. Re: Save error capture to record
                                jla_1
                                  

                                comment wrote:

                                jla wrote:

                                I'm not sure what you mean by that. 


                                I mean why do you get errors?

                                 

                                Ahh..I see what you mean.  Yes, that makes sense.  In this instance, the images are imported based on a list and sometimes an image is missing for various reasons.  When the final export is done, since there's so many images, it would have been tedious to try and locate which records had missing images.  Without the error capture, the script stops at each one.  By capturing at the export, I thought a report could be generated and rectified afterward.

                                 

                                 


                                jla wrote: 
                                Does filemaker support a way to do this during the loop of the export concurrently?

                                You mean create a new record in another table as part of the export loop? Sure, you can do that.

                                 


                                Thanks, I'm post what I come up with. 

                                 



                                • 13. Re: Save error capture to record
                                  jla_1
                                    

                                  Ok, I'm at a wall and can't seem to get past it.  I tried the following:

                                   

                                   

                                   

                                • Loop
                                • Set Variable [ $file; Value:"filewin:/" & $path & "/" & GetAsText ( IMAGES::IMAGE1) ]
                                • Export Field Contents [ IMAGES::IMAGEDISPLAYX; “$file” ]
                                • If [ Get ( LastError ) ]
                                • Set Variable [ $error; Value:$error & IMAGES::IMAGESERIAL & "-" & GetAsText (IMAGES::IMAGE1) & ¶ ]
                                • Go to Layout [ “ERRORTRAP” (ERRORTRAP) ]
                                • New Record/Request
                                • Set Field [ ERRORTRAP::errorlist; $error ]
                                • End If
                                • Go to Layout [ “MAIN MENU” (IMAGES) ]
                                • Go to Record/Request/Page[ Next; Exit after last ]
                                • End Loop
                                •  
                                   
                                  This is doing what is expected, putting the missing images id plus the name in a field in the errortrap table.  The problem is say there are 6 missing images, it creates Record one, then puts imageid1-001.jpg, then creates Record two and puts imageid1-001.jpg & imageid2-002.jpg, and so one until record six has all 6 missing images listed in the errorlist field correctly.  How can I get it to put one image per record?  Am I missing something obvious?
                                   
                                  Also, the export is called from a button in a tabbed menu.  Is there a way to return to that tab when it's done creating the error records instead of just the main tab? Right now it returns to the correct layout, but not the tab that has the button the script is called from.

                                   

                                  • 14. Re: Save error capture to record
                                    comment_1
                                      

                                    jla wrote:
                                    it creates Record one, then puts imageid1-001.jpg, then creates Record two and puts imageid1-001.jpg & imageid2-002.jpg, and so one until record six has all 6 missing images listed in the errorlist field correctly.

                                    Well yes, because you're appending them to the variable. This made sense in my version (that would create the records at the end), but not when you do it within the loop. Try:

                                     

                                    Set Variable [ $error; Value:IMAGES::IMAGESERIAL & "-" & GetAsText (IMAGES::IMAGE1) ]

                                     

                                     

                                     


                                    jla wrote:

                                    Is there a way to return to that tab


                                    Give the tab a name, then use Go to Object[].

                                     



                                    1 2 Previous Next