RunQQ Function

RunQQ Function

Hello People

RunQQ is a Run-Time Function for execution of another program
Its syntax is:

result = RUNQQ (filename, commandline)

Is there any way to use commandline as input/output? Or, in other words, how can I send information back to the calling program?
Do I have to use a COM Server/Client?

Thanks in advance

OPiedrahita

12 Beiträge / 0 neu
Letzter Beitrag
Nähere Informationen zur Compiler-Optimierung finden Sie in unserem Optimierungshinweis.

You can send information back on the command line arguments If the callee is designed to accept it. Otherwise it will ignore it.

A Com client is no different, if the other program does not want to talk to your client then it's not gonna happen.

So it all depends on the interface to the callee.
It would be the User interface for the case of RUNQQ
and Programming interface (API) in the case of the com-client.

You can for example run a typical DOS command like delete and use the argument to tell it which file:
CALL RUNQQ('DEL','SOMEFILE.TXT /V')

Lest to confuse you more, the third choice is CREATEPROCESS which is a generalized form of RUNQQ.

TimH

[pre]Thank you TimH[/pre]
I like RunQQ because it is simple to debug, but it is read only.
I have not begun to work with com-client yet.
Where could I find information about CreateProcess?
OPiedra

No, the commandline argument is readonly. There are any number of IPC mechanisms available depending upon what sort of data you would like to provide back to the original program.

James

[pre]Thanks[/pre]
[pre]Sorry I did not answer sooner[/pre]
[pre]Commandline argument is read only, therefore it is necessary to use another method to send back information.[/pre]
[pre]I can make a text string with my information using some rule to separate the variables, for example separating them with brackets, therefore let us think about transferring back a string[/pre]. How can I do it?
OPiedra

Mailslots provide an easy solution. Here is a simple example (no error handling):

mbx.def

use kernel32
character(*), parameter :: IPCname = ".mailslotmymbx"
integer, parameter :: IPCsize = 128
character(IPCsize) IPCdata
integer(HANDLE) hMail
integer(DWORD) size

parent.f90

program parent
use dflib
include 'mbx.def'
hMail = CreateMailslot(IPCname,IPCsize,0,NULL)
call RUNQQ('child',' ')
if (ReadFile(hMail,LOC(IPCdata),IPCsize,LOC(size),NULL) /= 0) type *, IPCdata(:size)
end

child.f90

program child
include 'mbx.def'
hMail = CreateFile(IPCname,GENERIC_WRITE,FILE_SHARE_READ,NULL,OPEN_EXISTING,NULL,NULL)
call time(IPCdata)
call WriteFile(hMail,LOC(IPCdata),LEN_TRIM(IPCdata),LOC(size),NULL)
end

Save the three files and build the two programs as console apps, then run the parent program which will return a time string from the child.

James

Bild des Benutzers Steve Lionel (Intel)

A tip. Don't add the .def file to the project's "Source Files", otherwise the linker will try to read it because .DEF is a kind of file the linker uses. If you just save the file in the same folder as the other sources, Developer Studio will find it. Or, rename the .def file to be .inc or .fi or something like that (and change the INCLUDE)

Steve

Steve

Thank you James
Ohh! Is this the pipe?
As I understand it, the section defined as mbx.def is something like a module defining global variables for both programs, Parent and Child.
Parent Program creates a file with the parameters of this module and the Child program writes on it the information that it is wanted to be transferred. Then, the Parent program reads the file.
Then, it would be better to send the information about the common file directly in the parameter of the RunQQ and to make your own protocol, isn?t it?
As I understand it, the pipe then would be a shared file where you write the information you want to be transfered between the programs.
It seems good to me, although f90SQL considers it obsolete.Is there any other way?
OPiedra

This isn't a pipe but a mailslot. Take a look at http://msdn.microsoft.com/library/en-us/ipc/mailslot_7gj7.asp for more details.

The .DEF file in just included by both the parent and child program, just insert its contents into those two files and eliminate it if you like. As Steve points out, that file extension also has other meanings if used in Developer studio. However it is just code that in included for compilation.

There is no file involved, despite the name of the routine, rather a mailslot is an in memory structure that allows the one way communication from the slave to the parent that you were looking for.

James

Hello James
This is exactly the information I needed.
I appreciate very much your kindness.
Best Regards
OPiedra

Bild des Benutzers Steve Lionel (Intel)

You could start with my CVF Newsletter Article on CreateProcess.

You'd probably need to use a pipe to get data back from the subprocess - my article doesn't cover that.

Steve

Steve

Is it secured to use mailslot? I mean if my data contains huge info, does it transfer safely?

Kong

 

Melden Sie sich an, um einen Kommentar zu hinterlassen.