10 Replies Latest reply on Jan 7, 2013 8:37 AM by philmodjunk

    Script running through finds from a dos dir command needs help

    IainMacgranthin

      Title

      Script running through finds from a dos dir command needs help

      Post

           I have a file which is a dir output from dos containing filenames plus directory structure.

           I am housekeeping a directory with subfolders and converted files from ts to mp4

           I want to find similar name files and action the original based on its extension.

           The problem is twofold:

             
      1.           The directory structure contains "\", and I don't know how to have this treated as a simple char rather than a reserved char
      2.      
      3.           I want to go through each find set, check the filetype (already defined in a separate field), and then return to the next record from the whole set, having marked off any records examined as 'processed', but I do not know how to recover the position. I tried setting a variable ($$recid), but when I try to use this with goto record it comes up in the dialog as zero second time around, even though the variable is being correctly assigned.

           (just to add some files have a conversion extension on the filename, e.g. "filename - converted", so exact matches on filename (minus extension) will not catch all. I am ok with this, but I wanted to mention it in case anyone suggested help that involved it)

           I havent added the action part as yet, I am just trying to egt the loop to work correctly:

           At the moment, these are the 2 blockers to my script - any help?

        • 1. Re: Script running through finds from a dos dir command needs help
          philmodjunk

               1) "\\" will evaluate as \. You may find it useful to do this: Substitute ( FilePathField ; "\\" ; "/" ) to replace the dos/windows directory separator with the / used in FileMaker file path expressions. \ is the "escape" character in FileMaker text expressions so to get the actual \ character, you type it in twice in text expressions, escaping the escape character.

               2) Go to record/request/page specifying a number, specifies the position of a record in your current found set, not it's record ID. If your found set is unchanged by what you are doing use Get ( RecordNumber ) to capture the original position of your record.

               If the found set is modified before you attempt to return to that "next record" you have to either preserve or restore that found set before you can go to that specified record. I've used two different approaches depending on platform and window management preferences:

               Use two windows--one with your original found set to loop through one record at a time and one to manage a different found set of the same records. Your script then flips back and forth between windows--one or both of which may be hidden from the user.

               Use two layouts based on two different occurrences of the same table and switch back and forth between the two layouts while using Freeze Window to keep the layout switches invisible. (A table occurrence is what we call the "boxes" found in Manage | Database | relationships that you use to define relationships. One such occurrence is specified in "show records from" in Layout Setup... for every layout in your database.

               THe second option is what I use if I have a Windows system with Maximized windows as it avoids a windows resize issue created when you open new windows.

          • 2. Re: Script running through finds from a dos dir command needs help
            IainMacgranthin

                 Most thanks for that..

                 I have done the filepath change in my db so the filename field extracted from the original dos string is changed at birth!

                  

                 For the record stroll, I dont know how to reference the new window in the script, so in the meantime I have set a loop where : when I have all records I saet a variable $recid to get the record number.

                 Then  I " do stuff ".

                 Then I go back to the full set, and set a $counter.

                 While the $counter < than the $recid i increment the counter and goto next record. 

                 Ouch!  As I progress through the set the time taken increases, but it'll do until I understand how to work with the new window (I had a look and it seemed a bit involved, asking me to specify it etc)....? ;-)

                  

                 Thanks thus far...

                 Iain

            • 3. Re: Script running through finds from a dos dir command needs help
              philmodjunk

                   If you use Get ( RecordNumber ) to capture the record's position, (I wouldn't call it RecID), you can use Gp To Record's calculation option to go to the specific record in one step instead a loop. Just make sure to select the "no dialog" option when you do so.

              • 4. Re: Script running through finds from a dos dir command needs help
                IainMacgranthin

                     hmmm - I tried Get (RecordNumber) = $$recker as the calculation before, followed by Goto next record and it always showed up the dialog, so I just tried again with nodialog, and I get stuck on record 2...

                • 5. Re: Script running through finds from a dos dir command needs help
                  IainMacgranthin

                       Aaaaah - I tried the window switch, and bingo!! Much Thanks, but still struggling with using get (recordnumber) to get the next sequential record based on previously stored recordnumber.  For that matter, when I used calculation to goto a record using a unique value field, that didnt work either...

                  • 6. Re: Script running through finds from a dos dir command needs help
                    philmodjunk

                         I only have an incomplete picture of your script so I may be working off incorrect assumptions here...

                         Say you are on the 3rd record in your found set, you need to process data off of other records and then return to the 3rd record when done:

                         Set Variable [$RecNumb ; value: Get ( RecordNumber ) ]

                         #Then your steps to do your task go here

                         Go to Record/Request/Page [No dialog ; $RecNumb ]

                         This assumes that the records that are present at the beginning of this are still present with no additions or omissions and in the same sorted order.

                         Note: If your script does alter the found set such that you can't just return to the record number specified, you can also capture the value of a primary key in a global field and use Go To related Records to jump back to that record if you define the correct self join relationship.

                    • 7. Re: Script running through finds from a dos dir command needs help
                      IainMacgranthin

                           Thanks - that completes the picture!

                           I though that as it was a calculation, I would have to give some expression to be evaluated - it wasn't obvious to me to just use the record number.

                           Is this the only way to go to a record for a calculation, or can you work it using other values?

                      • 8. Re: Script running through finds from a dos dir command needs help
                        philmodjunk

                             A single variable IS an expression when entered into the specify calculation dialog. It's just a very simple calculation.

                             If you read my last post again, I mentioned Go To Related Records which can be used to reset the focus on a record with a specific value.

                        • 9. Re: Script running through finds from a dos dir command needs help
                          IainMacgranthin

                               OK - I will for sure also check the Go To Related Records function - it makes sense to do it now, here, while I am getting the idea of FileMaker navigation - maybe also adding it will give someone else a good summary of some options in one place - thanks PhilModJunk - this is really useful!

                          • 10. Re: Script running through finds from a dos dir command needs help
                            philmodjunk

                                 You may find this link on Go To Related Records of use: The Complete Go To Related Record