Page 1 of 1

ExecProg and ExecAndWait?

PostPosted: Fri Sep 21, 2007 7:16 am
by jmshehane
Could somebody give me an example of how to use both of these? I run the following code:

MyInt2 := ExecProg('C:\datacad\test.bat','test.bat','',myint);

and it returns 1, and nothing happens. But from what i've read, 1 is a good thing. I would expect the batch file to pop open and run (I expect the same from .exe files)

I've also tried the ExecAndWait, and it returns a -1, and again does nothing. Also what is the "Visibility" variable in the ExecAndWait, I can't find any documentation on what integer means what.

Thanks in advance!

Oh yeah, I'm programming form DCAD 9. So no Delphi.

Re: ExecProg and ExecAndWait?

PostPosted: Fri Sep 21, 2007 7:55 am
by David A. Giesselman
jmshehane wrote:Could somebody give me an example of how to use both of these? I run the following code:

MyInt2 := ExecProg('C:\datacad\test.bat','test.bat','',myint);


You've got your parameters a little mixed up there. Try:

Code: Select allMyInt2 := ExecProg('C:\datacad\','test.bat','',myint);

you then wrote:I've also tried the ExecAndWait, and it returns a -1, and again does nothing. Also what is the "Visibility" variable in the ExecAndWait, I can't find any documentation on what integer means what.


That specifies the visibility of the spawned command window.
  • Hidden (SW_HIDE) = 0;
  • Normal (SW_SHOWNORMAL ) = 1;
  • Minimized (SW_SHOWMINIMIZED ) = 2;
  • Maximized (SW_SHOWMAXIMIZED ) = 3;

Dave

PostPosted: Fri Sep 21, 2007 3:14 pm
by jmshehane
Still no go. Ive tried:

MyInt2 := ExecProg('C:\datacad','\test.bat','',myint);
and
MyInt2 := ExecProg('C:\datacad','test.bat','',myint);
and
MyInt2 := ExecProg('C:\datacad\\','test.bat','',myint);

The batch file just has a pause statement so I can see that it actually opened up. And the function returns 1 (which mean's it was supposedly successful). Is there anything else I could be missing? Thanks,

Again, I'm using legacy DCAL compiler 5.0 for DCAD 9 on Windows XP SP2.

PostPosted: Fri Sep 21, 2007 3:25 pm
by jmshehane
Nevermind, all is well. I've been a Java and C# programmer for years so the Pascal stuff gets me everytime (not to mention i don't have a developing env, just notepad). Apparently the backslash (as in Java and C#) is an escape character. So this actually works:

MyInt2 := ExecProg('C:\\datacad\\','test.bat','',myint);

the "d" was getting escaped instead of my backslash. thanks for the help.

PostPosted: Fri Sep 21, 2007 3:34 pm
by David A. Giesselman
Ah yes, I completely forgot about that aspect of DCAL as well.

Re: ExecProg and ExecAndWait?

PostPosted: Sat Nov 11, 2017 8:11 pm
by dhs
I only recently realised that I could pass parameters to the ExecAndWait procedure by adding the parameter to the prog parameter (separated from the program name by a space) as in the following example:

Code: Select all         getpath (tempstr, pathsup);
         strcat (tempstr, 'dhsoftware\\ShadHelp.exe v1.1.08');   !v.1.1.08 is a parameter
         ExecAndWait (tempstr, 1, res);


But, I have never used the ExecProg function because it in not documented (other than a passing mention in the ExecAndWait documentation), and I did not know what the parameters were (or even if it needed to be declared as a builtin function).
So having found this old post I have been able to get ExecProg working by following the example code that Dave G provided in one of his responses. but it is still not fully documented. Is anybody able to advise what the last 2 parameters are. I have passed a blank string and an integer variable as per the example, but I would really like to know what they are actually used for ...

Re: ExecProg and ExecAndWait?

PostPosted: Mon Nov 13, 2017 5:16 pm
by David A. Giesselman
The 2nd parameter indicates the window state to use:

  • 1 = Normal window
  • 2 = Minimized window
  • 3 = Maximized window
The 3rd parameter returns the result; 1=Success, 0=Failed

Dave

Re: ExecProg and ExecAndWait?

PostPosted: Mon Nov 13, 2017 8:28 pm
by dhs
Thanks Dave,

But I think you have answered regarding ExecAndWait, but I was asking about the parameters for ExecProg.

I have now realised that I can probably work out the parameters by looking at the UInterfaces file supplied with DCAL for Delphi, so expect that they are as follows:
FUNCTION ExecProg (path, prog, parameters : str255; ret : OUT integer) : integer;

As I noted, the above is what I expect, but could be wrong so would be grateful if you could correct me if required. Also, it is not clear to me what the last parameter (ret) is ... if it is a return code then what is the integer result of the function (which I would have assumed to be the return code)?

Thanks,
David H

p.s. thanks for the information on the WindowState values. I have had trouble finding these values in the past (and just settled on using 1 as it produced the desired result), and had only recently found them in one of your previous responses within this thread.