Question
· Aug 4, 2016

Call/execute *.exe on windows from objectscript

Hello,

we build a COS-application which includes classmethods for running a simulation calculation (differential equations by Runge Kutta procedure) which runs well but needs too much time.  This is embeded in Cache Server Pages and we tried already to start the simulation as a JOB to avoid the CSP-timeout. However the Job needs of course also too much time. May be this could be solved by a different strategy to run the simulation calculation by an external Windows -Programm (developed with Delphi). Original the application for simulation was developed in Delphi, where it needs a significant shorter time than in the COS-application.

Our question is how can we start and execute the windows-programm from a Cache Server Page?

Any hint is welcome?

Lutz.

Discussion (8)1
Log in or sign up to continue

Simpliest way: Cache executes an operating system command via $zf(-1) function.

Alternatively, you can load a dll with $zf(-4) (also 3, 5) functions.

There is also CNA project - it provides an interface for using native C-compatible shared libraries without anything but Caché ObjectScript code. CNA is a wrapper for libffi. CNA consists of native library (libcna) and Caché class (CNA.CNA). It is a wrapper around $zf functions.

That said, the most effective would be some kind of a library load with library written in either C or generated from some computational language. For example Mathlab can generate C code, which can be then compiled into a library.

Dmitry thank you very much for your prompt answer.  Sorry I was on time pressure yesterday. However some more details to that what we plan. We developed a model systems representing the insulin-glucose metabolism in humans in form of a coupled differential equation. The model needs to be setup to the individual situation of each patient which we call identification. For this purpose we developed in Delphi a program which performs this identification automatically. Data needed for this, the program gets from a Caché instance by ODBC and the results which are model parameters will be stored to this Caché instance. This part works well if we start the program by $ZF(-2,"program.exe") from the Caché terminal. Further on we want to integrate this automatically identification into a CSP application where a patient enters or uploads e.g. their glucose measurements. If all data are completed the CSP application should start the identification program again by $ZF(-2...). This does not work at the moment since no results will be stored. However if I check the status it returns "0" means the child process was created succesfully, but thats all. If I test this with

w $ZF(-2,"notepad.exe") its the same . From Caché terminal returns status 0 and opens Notepad, from CSP-page its returns status 0 and not opens Notepad or not execute our identification program. Finaly this program does not need any interaction, parameters (e.g. which patient data) will be handed over with the program start. Hope this gives you more insight to our problem.

I'm very grateful for any help. Best regards Lutz.

I've used Delphi so long ago, and could be mistaken. But to be sure that application is not interactive, it should not have any visual components. And as I remember you should start developing from Console Application. To check that actually it does work correctly, you may try with real console tool, something like: dir, md, etc.. You may try this $zf(-2,"dir > testdir.txt"), if after executing this code testdir.txt file will appaer with content for some folder, you'll see that it's work. And it means that in your application should be changed something to be as console application.

OK Dmitry, this could be the solution. Start the identification program from the windows console (cmd) works well (results of the identification were stored to the Caché instance. However the identification program outputs some messages to the windows console and this could be the reason for not working from CSP-page as you describe. I will forward this to the Delphi developer and will return with the result, hopefully succesful. Thank you very, very much for the moment.

Lutz Vogt.

Finally our experiences with $ZF(-2): It works perfect, also in our case (status information was "0" for a successful created child process). Our application works also well. The only lack was the configuration of the ODBC DSN which was set to USER correct but the SYSTEM DSN was missing. Therefore the results of the application run were not stored to Caché. Thanks again to all contributions. - Lutz.