10 Replies Latest reply on Feb 5, 2017 5:43 AM by beverly

    Custom function from C program

    juegofono

      Hello everybody,

       

      I'm new in creating custom functions. So my question is:

       

      Can I translate the source code of a C-program to a filemaker custom function and - if yes- how can I do this?

       

      Anybody tried this?

        • 1. Re: Custom function from C program
          beverly

          You should be asking questions in the Discussions space. Perhaps TSPigeon or TSGal can help you move the post there?

           

          my answer: it depends. I've been able to take JavaScript and "translate" for FileMaker functions and turn into Custom Functions and/or scripting. If you understand the logic of custom functions and what the C-program is doing then perhaps.

           

          if the code is short, you may wish to post it here. remember that the functions have limited connection to outside-FileMaker actions. Plug-in development, OTOH, may be more what you wish to study (start on this page):

          FileMaker Pro and other Computer Software Technology | FileMaker

          (specifically the "FileMaker Plug-in Support" section - follow all the links!)

          beverly

          • 2. Re: Custom function from C program
            TSPigeon

            juegofono:

             

            Thank you for your post!

             

            You can always move a post via the "Move" action in the top right of a Thread you create. I will go ahead and move this one to Discussions (as beverly suggested) so that you might receive more views and further feedback.

             

            TSPigeon

            FileMaker, Inc.

            • 3. Re: Custom function from C program
              jbante

              As Beverly already said, it depends. Certainly, the logic from a C function (or any other programming language, for that matter) can be translated to FileMaker. FileMaker is Turing-complete, so it's theoretically capable of any computation any other language is capable of.

               

              There's more to code than the logic, though. If your C function is using a library that does something FileMaker doesn't, that makes it harder (not necessarily impossible). I/O operations are a big sticking point here. Some features of the C language don't exist in FileMaker, and have to be achieved some other way, e.g., pointers, structs, macros, memory management, bit-wise data manipulation, etc. Some functions take advantage of the particular features of C to work well, but a different approach to achieve the same result might work better for FileMaker.

               

              I don't know of any transpilers that will convert C code to FileMaker calculations or scripts automatically. Someone who knows a bit of both needs to do it by hand. If that seems like too much work, you might look for a similar function in Java, JavaScript, or Python. FileMaker plugins exist that can execute code in one of these languages on FileMaker's behalf.

              • 4. Re: Custom function from C program
                vincedubeau

                It is possible to translate it to Filemaker. It depends on your level of comfort with C (or other languages). A few years ago I used a Javascript routine for doing complex interest calculations as the basis for a Filemaker script (FM 10). It took some trial and error but I eventually got it working. Biggest issue was that I really didn't know Javascript.

                • 5. Re: Custom function from C program
                  fmpdude

                  Logic maybe, but C is so pointer and memory-management heavy, there wouldn't be a statement for statement translation. Plus, FMP doesn't support structs and other data structures, libraries, and such.

                   

                  If you have lots of C code, you might be better off creating a micro service and calling that code from FMP's INSERT FROM URL or a CURL command. A micro service just listens on a port on your computer and can accept HTTP command verbs from any program that can create them: a browser, FMP -- you can even call it from the command line. (I write my services in Java, but I would bet there are C capabilities out there.)

                   

                  Finally, the micro service doesn't "depend" on FMP so multiple users can access your function library without these compatibility concerns.

                   

                  ---

                   

                   

                  In Java, you might be able to use its Native interface to execute C code and then call that Java code from FMP, but that approach is fraught with security risks.

                   

                  Java Native Interface - Wikipedia

                   

                  ---

                   

                  Or, just convert the logic to FMP.

                  • 6. Re: Custom function from C program
                    juegofono

                    Hi everybody,

                     

                    many thanx for all your answers and proposals. although i don't know yet how i will manage my problem, you gave me good inspirations to continue with my solution.

                    • 7. Re: Custom function from C program
                      BruceHerbach

                      I think the others have covered most of the C to FileMaker programming questions and issue.  Here are few sources for useful custom functions that may be helpful:

                       

                      Brian Dunning: FileMaker Pro Custom Functions

                      FileMaker Standards.org: fmpstandards/Functions at master · petrowsky/fmpstandards · GitHub

                       

                      The people that have put these together and made them available to the developer community have done a great job and been incredibly generous in doing so.

                      • 8. Re: Custom function from C program
                        schamblee

                        Plug-ins are created using C.  Creating custom plug-ins

                        • 10. Re: Custom function from C program
                          beverly

                          this link to FM12 is valuable! the link in the first reply may have updated information.