Jump to content
capsprojectos

Call a script from an executable file (EXE)

Recommended Posts

Hello,

I have more than 10k executable files, each EXE export data to a single table, inside of an unique MySQL.

I created a FM database to manage all data (ODBC), but I didn’t solve how to trigger a script from an external EXE, without looping for new data each minute.

 

Questions:

#01: There is way to trigger a script in an open database, without looping ?

#02: Runtime solutions can be used with parameters?

My best idea, at this time, is to create a runtime solution and a relationship, and call it from the EXE.  I do think is a "stupid idea" and there must be clever solutions out there.

 

Thanks for all

 

INFO: I am using windows 10 | FM Pro 15

Share this post


Link to post
Share on other sites

The MBS Plugin can receive notifications from OS.

And with MBS Plugin comes an example in C++ to send them with a little exe for windows.
So you could use the .exe there to send notification to your FileMaker solution and trigger a script via our plugin.

see

http://www.mbsplugins.eu/component_Notification.shtml

Share this post


Link to post
Share on other sites

Hello,

First thanks for your comment, and suggestion.

Is an excellent tool! I do have some questions about it:

1. Is possible to use a script parameter - MBS( "Notification.Listen"; NotificationName; FileName; ScriptName ) ?

2. What is the limit of "Notification.Listen", how many notification per run? In my tests the maximum was ~ 5750, and have some errors ("Failed to get ID for this notification name", example: #5984; FM crash after = Net framework exception )

3. There is a function to release all "Notification", or we need to do it "one by one"?

4. The Notification.List return a text without array (not a list), correct ?

5. How Notification Send work? There is any example (EXE)

 

Thanks for all,

 

 

 

 

Notifications.fmp12

Share this post


Link to post
Share on other sites

FM on Windows has an ActiveX interface that you can use to run a script.  AppleEvents on Mac does the same.  Do search in the FM help for ActiveX and you'll get a list of methods and properties you can use.  The help has some VBA examples that you can easily adapt to whatever code your EXE is written in.  That does assume that you can modify the code for the EXE to add the relevant parts to talk to FM.

Share this post


Link to post
Share on other sites

A script Parameter would be a nice idea. Like passing a number or so around.

What would you want to listen for 5700 different notifications? Normally people just use one or two.

The list function should return a list of all registered names.
The example exe is there, it sends notifications on Windows using SendMessageTimeout and HWND_BROADCAST.

Share this post


Link to post
Share on other sites

Hello Wim, thanks for your response and help.

I read this, from a previous post from you: “Oh, keep in mind that there is a bug in FM (has been ever since FM8) that if you call a script through the ActiveX interface a few times in relative quick succession (as you will do I'm sure in testing), the ActiveX interface will go deaf. At some point the script will not fire. When you see that, you have restart FM.” - http://fmforums.com/topic/85877-activex-and-c-sharp/#comment-394772

 

#1. This still occur in the current FM version (15)?

2. I have this code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using FMPRO70Lib;


namespace ConsoleApplication1

{

    class Program

    {

        static void Main(string[] args)

        {

            FMPRO70Lib.Application FMProApp;
            FMPRO70Lib.Documents FMProDocs;
            FMPRO70Lib.Document FMProDoc;

            try

            {

                FMProApp = new FMPRO70Lib.Application();
                FMProDocs = new FMPRO70Lib.Documents();
                FMProDoc = new FMPRO70Lib.Document();
                FMProApp.Visible = 1;
                FMProDocs.Open("C:\\Users\\oscar\\Desktop\\helloworld.fmp12", "Admin", "");
                Console.WriteLine(FMProDoc.Parent);
                FMProDoc.Activate();
                FMProDoc.DoFMScript("myscript");
                FMProDoc = null;
                FMProApp = null;
                FMProDocs = null;
                
            }

            catch (Exception ex)

            {

                Console.WriteLine(ex);

            }

        }

    }

}

Source and credits to:

JHaughey - http://fmforums.com/topic/85877-activex-and-c-sharp/#comment-394772

#2.1 - I am facing the same problem as he, myscript doesn't run. I tried you suggestion replacing "FMProDoc = new FMPRO70Lib.Document();" to "FMProDoc = FMProDocs.Open("C:FilemakerJob2.fp7", "Admin", "");"

But the problem remains, and doesn't open FM at all;

How to solve this? Thanks

#2.2 - I read this, if the file (helloworld.fmp12) is already open i need to use GetObject instead of CreateObject; My Visual Studio and C# knowledge is -1, i need to change anything in the previous script (a if clause) ?

Source: http://www.filemaker.com/help/13/fmp/en/html/create_script.13.11.html

 

#3.1 - After running the c# script, and close FM manually (by window or exit) i still have two process in windows 10 task manager (Filemaker Pro 5.1~8.2 MB and Filemaker Listener 101.3 MB), why? Seems like the file and FM are in memory, because if i run the script again is faster and if i end the task, the next run takes more time.

How to end up these two process (dump all).

 

Thanks for all

 

 

 

Hello MBS,

"What would you want to listen for 5700 different notifications? Normally people just use one or two." Yes, you are right! I just need less than 20.

But i was trying to understand how MBS plugin works in this case.

 

I need to do more test on it (i didn't get Notification Send command...), but so far is an amazing plugin. Very helpful 

 

 

Share this post


Link to post
Share on other sites

Something in your code is calling on FMP 5 which is why you have it in your task manager.  Probably a reference to the old activeX library or to an .fp7 file.

Does your code fall through to the catch block?  And if so: what is the exception?

As to the bug: not sure; I do most of my integrations directly against FMS these days or write a small ASP.NET web service to act as the intermediary.

 

Share this post


Link to post
Share on other sites

Hello Wim, thanks for your comments again.

In the previous post, I pasted the entire code. I don’t have any lines calling FMP 5 or .fp7. And I am using the last FMPRO70Lib from FMP 15.

After your comment, I tested with and without plugins, and the problem remain. I don’t understand why Exit doesn’t work, Filemaker maintains in memory.

 

I read this “FileMaker may not exit until all reference counts are released. In Visual Basic, you can release the reference count by setting the object variable to "Nothing", for example:” – source: http://www.filemaker.com/help/12/fmp/html/create_script.13.11.html#1028245

Then I replace the null to FMProDoc = Nothing; - But didn’t work.

 

But my biggest concern is why I can’t call a script?

 

Does your code fall through to the catch block?  And if so: what is the exception? NO.

helloworld.fmp12

Share this post


Link to post
Share on other sites

the DoFMScript is called on object FMProDoc, but it was never set to anything.

Try this instead of the line where you just open the file: 

FMProDoc = FMProDocs.Open("C:\\Users\\oscar\\Desktop\\helloworld.fmp12", "Admin", "");

Share this post


Link to post
Share on other sites

You have to work with what the 'catch' block gives back, my guess is that the 'FMProDoc' variable remains 'null'.  Try another approach: after opening the file (does it open at all and just the script does not run?)  then do a foreach loop through the documents, check the FullName against the file you want to target and when you find it then do the DoScript.

Share this post


Link to post
Share on other sites

Hello Wim and thanks again...

I spent the last days, testing and without success. FM open the file but doesn't run the script, the scriptname is correct and i don't have any error in Visual Studio.

The problem must be related with DoScript, does work on Windows 10?

 

Thanks

Share this post


Link to post
Share on other sites

For MBS Plugin 7.2 I already added passing parameters.

So you can include two numbers in the notification.

e.g. a command code and a number as parameter.

 

Share this post


Link to post
Share on other sites
5 minutes ago, MonkeybreadSoftware said:

For MBS Plugin 7.2 I already added passing parameters.

So you can include two numbers in the notification.

e.g. a command code and a number as parameter.

 

Thanks,


From a new MBS client

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


  • Similar Content

    • By JC007
      Runtime Solution.
      Hi all
      I haver created a FileMaker 16 pro advanced database and now need to distribute it.  I have successfully created the runtime solution and all is well on my iMac.  I have tried to send this to my friend (who doesn't have FileMaker) and when he tries to open the .app file, he gets an error message :-
      "The Primary File cannot be found and is required for this application".
      The structure of the files I have sent him look like this :-
      Runtime Folder
      .app
      .fmpur
      Extension Folder 
      FMP acknowledgements
      He can then goto the folder and click the .fmpur file and it opens sucessfully.  This has to be completed every time.
      Any help would be greatly appreciated.
      JC007
    • By JMart
      Hi gurus,
      I am sure I’m missing something simple, but for the life of me I can’t figure this out. I have a database with tickets. What I want is when a new ticket is created I want to see a popover (see attached) then I want the user to type in the top box and as they type I want to filter the list below (a portal) and once they client is shown they would select it and a ticker is created for the client. I sound a script and modified to fit my needs but can’t get it to work. Can someone stretch a helping hand?
      BTW the filtering is working but its not reflecting in the popover its reflecting on the layout.


    • By Hoytopher
      Hi all,
      I'm an FM novice who has a functioning database, and I'm trying to add layers of functionality to it. One feature I'm trying to design is a script to search through a Gmail outbox with certain keywords.
      In URLs, "%" translates to "%25". Filemaker appears to do this automatically - In Gmail syntax, you need to write "in%3Asent" to have the Gmail search bar contain "in:sent" which searches my outbox. Here's my current code for Go to URL:
      This "%" bit translates to "%25". I've tried "\%", I've tried creating a string, x, then having it open x, but no matter what I cannot get "%" to show up as-is, it always translates to "%25". Is there any way around this? I've tried subtracting text, but I just can't seem to get it to work. Any bright ideas? I can't find an answer to this specific question of disabling URL string substitution.
    • By Agentshevy
      Hello everyone..
      Guess I have been away for a while. Not fully back though because I am not really engaged with computer tech stuff at the moment. However, I really stumbled across a problem earlier today while going through my email logs. I observed that a server script I had set up has not been attaching the Pdf file report as supposed to. It only delivers the message while leaving out the file attachment. I did test the script when I added it but what I did not test was the result when run by the server.
       
      Allow user Abort [Off]
      Commit Records/Requests [No dialog]
      Set Variable [$FileName;Value:"Summary"&".pdf"]
      Set Variable [$PDFPath;Value:Get(TemporaryPath) &".pdf"]
      Go to Layout ["Summary_Layout]
      Perform Script ["Print_Page_Setup"]
      Save Records as PDF [Restore;No dialog;"$PDFPath";Current record]
      Send Mail [Send via SMTP Server;No dialog]
       
      As at the time of my writing the script, I was not observant about server-side scripts. I did go back just recently to observe that the "Save Records as PDF" script step is not server compatible.
      Please, is there any work around on this? Much help is appreciated.
    • By pomilpetan
      Good morning everyone I created a database runtime solution with FileMaker Pro 15 advanced. The program must export the contents of a form in PDF format. In a solution that runs under FileMaker I could use the command "Save as PDF" but this command does not work in a runtime solution. Could someone tell me how I could make this function? thank you so much.
×

Important Information

By using this site, you agree to our Terms of Use.