1 2 3 4 Previous Next 45 Replies Latest reply on Feb 15, 2016 5:17 PM by user19752

    Testing whether a file is open or not

    mgostovich

      I cannot remember how to have FileMaker test whether a file is already open or not within a script. I am opening a file to run a script on it but I don't want it to open a bunch of occurances. I want it to test if the file is open and if so, run the script. If not, Open the file and then run the script.

        • 1. Re: Testing whether a file is open or not
          RalphLearmont

          The function:   "DatabaseNames" gives you a list of all open FM files.

          1 of 1 people found this helpful
          • 2. Re: Testing whether a file is open or not
            Fahri Akar

            No need to check "Opened Files".

             

            If a file is already opened, FM does not open a second window for it unless your opening script includes an open new window script step.

             

            Whether you use Open File ["FileName"] script step or Perform Script ["FileName" from file: "script"] script step.

             

            Fahri

            • 3. Re: Testing whether a file is open or not

              Just to be clear, when you say "Open a File" as with the suggestion above to "Open File["FileName"]", you mean a FileMaker solution file, correct?

               

              AFAIK, beyond importing a text file into a table and then processing it somehow, FileMaker doesn't (natively) support "low level file" functions to open, say, text, or more structured files and then read them line by line (or record by record with more structured files).

               

              However, in other environments like .NET, there are many indirect techniques of trying to infer that a disk file is "open" but none is full proof in all circumstances.  To wit, no languages that I know if have a direct way to test if a disk file is open (as with something like .. (file.isOpen()...).

               

              ----

               

              However, you probably just meant Open a FileMaker "File" so it looks like that question was already answered. 

               

              - m

              • 4. Re: Testing whether a file is open or not
                nicolai

                We are obviously talking about FileMaker files, but to answer morkus post:

                 

                You can import scv and tab files which turns lines into the records. The only difference with MYSQL LOAD DATA is that there you can ignore file extension and use other separators apart from comma, tab and CR. Same for BULK INSERT in SQL Server. It does not read one line at the time, though. Correct me if I m wrong, I did not use them much.

                 

                True, you can't open text file for reading one line at a time, but IMHO this is a Database dev tool and not Visual Studio. Could you give me a case scenario where you would need a low level file access?

                 

                Nicolai

                • 5. Re: Testing whether a file is open or not

                  Sure, check out MS Visual FoxPro (VFP), a very powerful database program and only recently killed by MS (naturally). VFP is an object oriented database tool. Create an EXE and distribute it (for free) with the database container, forms, menus, etc.. Perfect for medium to large work-groups.

                   

                  OK to your question...

                   

                  VFP has low-level file commands like FOPEN(), corresponding FGETS(), FWRITE(), and other low-level file functions.

                   

                  (No plug-ins necessary.)

                   

                  Here's the FOPEN documentation:

                  FOPEN( ) Function

                   

                  While you don't need these functions that often, they are super handy to have them in your toolkit when you do. I like that VFP had these more general purpose programming features too.

                   

                  There were lots of instances I needed to mess around with a file and only use parts of it in a database, etc.

                   

                  Or where I had instances where I needed to create a text file with a particular format as a database output, not necessarily CSV, TAB delimited or whatever.

                   

                  I do lots of stuff with files, so LLFFs might not apply to a lot of people, or even most people, but even with FileMaker, I'll never need or use every single feature it has.

                   

                  HTH

                   

                  - m

                  • 6. Re: Testing whether a file is open or not
                    nicolai

                    Cool. I just think that we all want different features in FMP and if they implement everything it will become unusable. You were saying that some of your requirements are quite rare, I have quite a few of those myself. IMHO, these are better served by plugins, or in your case, you can probably write something custom in Java. I use Apple and VB script to hook up with the OS and get extra functionality there. Anyway, thanks for your post, it was as always very educational.

                    • 7. Re: Testing whether a file is open or not

                      Totally agree with you here.

                       

                      Yes all the stuff in VFP was overwhelming at times. Plus, if you're doing VFP, you're a coder, period.

                       

                      For example, in VFP there are four multi-user buffering modes (five if you include "no buffering", which is an option):

                       

                      1. Pessimistic row

                      2. Optimistic row

                      3. Pessimistic table

                      4. Optimistic table

                       

                      And, all the extra functions add complexity to deal with - especially in the optimistic row/table cases.

                       

                      --------------

                       

                      I like FileMaker (a lot) better, actually. And, you're right too, if something is really tough to do in FMP, then we all have our go-to tools for those (hopefully rare) cases.

                       

                      FileMaker, in my view, hits a sweet spot that VFP missed. In FMP you can create beautiful stuff with sometimes no coding at all. It took me a while to warm up to QBE, for example, but now I like it (aka Find). I think it's all a function, pardon the pun, of our backgrounds when we start using FMP as to what we like or don't quite get.

                       

                      And, if it weren't for this forum and the other FileMaker forum that merged with this one, I would never have really gotten productive with FMP.

                       

                      Thanks, N....Appreciate your reply.

                       

                      -- m

                      • 8. Re: Testing whether a file is open or not
                        nicolai

                        No, thank you, morkus. Sorry, I managed to misspell your name in the previous post, corrected now.

                         

                        Nicolai

                        • 9. Re: Testing whether a file is open or not

                          No worries. I didn't notice.

                           

                          -----------

                           

                          BTW, on plug-ins, if I were to use the Troi plugin (as an example, since we were talking about files and plug-ins), am I interpreting these costs correctly?

                           

                           

                          1. A developer license so I can develop file stuff: $749

                          2. 25-User pack (oops, my app has more users...) $749 (initially, for first 25 users)

                          ---------------------------------------------------------------------------------------------------------------

                          Roughly $1,500?

                           

                          Maybe I don't understand how plug-ins are priced, but most I've looked at, anyway, seem super expensive.

                           

                          If $1,500 is correct, that's more than four times more than I paid for FMPA itself. And I have to spend another $99, plus or minus, for every frick'n user? This seems like the typical FMP plug-in model, but I ain't buying.

                           

                          While I'm sure these plug-ins are great, so far, due to these costs, I've remained plug-in free.

                           

                          - m

                          • 10. Re: Testing whether a file is open or not
                            nicolai

                            I do not use the plugins myself, but they are easier to maintain nowadays and there are some good free ones -BaseElements comes to mind. This one has some file features as well, although not as many as Troi.

                             

                            I think, the dev licence for Troi plugins covers the runtimes, you can get away with Server Licence. Good thing about plugin developers, they are easily contactable and quite helpful. They are all small companies developing for a small segment of a market, so prices do tend to be high.

                            • 11. Re: Testing whether a file is open or not
                              beverly

                              verify with the authors, but typically a "developer" license allows you to use to create for your clients.

                               

                              Edit: oops! nicolai may be correct on "runtimes". Then again, verify with the plug-in authors. I've saved clients 1000's of hours of my work by using a plug-in instead. They get estimates before work is begun and usually opt for the plug-in.

                              • 12. Re: Testing whether a file is open or not

                                I guess I'm used to the MS/Oracle models --> Development tools, databases, etc., are totally free for development. Install them, use them, etc.. Encourages use. Then, pay when you put on a production server.

                                 

                                Not to harp on Java stuff, but the Apache commons libs, as one example, are also free and have tons of libraries. iText PDF lib (v. 2 with the Mozilla License, not v. 5) is free and open source as well. IDE plug-ins, hundreds of them, free.

                                 

                                Therefore, the FMP plugin cost model is a shock to the system!

                                 

                                ---

                                 

                                Which plug-ins do you use regularly and which include the run-time license when you pay for the development license?

                                 

                                Just wonderin'

                                 

                                -- m

                                • 13. Re: Testing whether a file is open or not

                                  I agree with you there about how nice the plug-in developers are.

                                   

                                  When I had asked a question about one of the plug-ins a while back, I got an incredibly honest and insightful email from the plug-in developer. I almost bought the plug-in based on his cool email reply itself.

                                   

                                  I would probably buy many of the plug-ins if they were, say, $99, and not $395 or more.

                                   

                                  Thanks N.

                                   

                                  - m

                                  • 14. Re: Testing whether a file is open or not

                                    WOW!

                                     

                                    Thanks for the heads up about the free base elements plugin! Great tip!!!

                                     

                                    I just downloaded the latest version. Very nice! Lots of cool stuff there.

                                     

                                    Thanks, N.

                                     

                                    -- m

                                    1 2 3 4 Previous Next