how to call other exe file in Eprime?

558 views
Skip to first unread message

chen

unread,
Nov 3, 2007, 11:28:22 PM11/3/07
to e-p...@googlegroups.com
 
Hi, I used to write Visual Basic scripts and now I want to use Eprime. But i don't know how to call executive function in Eprime.
 
Here is want I wrote in VB
(1) declare function
Public Declare Function ShellExecute Lib "shell32.dll" Alias _
"ShellExecuteA" _
(ByVal hWnd As Long, ByVal lpOperation As String, _
ByVal lpFile As String, _
ByVal lpParameters As String, _
ByVal lpDirectory As String, _
ByVal nShowCmd As Long) As Long
(2) call executive file
ShellExecute(NULL,"open","calc.exe",NULL,NULL,SW_SHOWNORMAL);
 
Now I want to call an executive file in Eprime, How to do that?
 
Besides, I have a USB device which can not only send a response signal but also generate a special number. It can be used as serial port device in VB, i can not only get the response but also get the number, How can i use it in Eprime? How can I control a serial port in Eprime?
 
Thank you very much!
 
 

--
Chunhui Chen
______________
 
Beijing Normal University
&
University of California, Irvine



网 易 Yeah.net 免 费 邮 箱 全 新 改 版,珍 藏 帐 号 开 放,快 来 抢 注 >>

David McFarlane

unread,
Nov 5, 2007, 2:20:06 PM11/5/07
to e-p...@googlegroups.com
At 11/3/2007 11:28 PM Saturday, Chunhui Chen wrote:

>Hi, I used to write Visual Basic scripts and now I want to use
>Eprime. But i don't know how to call executive function in Eprime.
>
>Here is want I wrote in VB
>(1) declare function
>Public Declare Function ShellExecute Lib "shell32.dll" Alias _
>"ShellExecuteA" _
>(ByVal hWnd As Long, ByVal lpOperation As String, _
>ByVal lpFile As String, _
>ByVal lpParameters As String, _
>ByVal lpDirectory As String, _
>ByVal nShowCmd As Long) As Long
>(2) call executive file
>ShellExecute(NULL,"open","calc.exe",NULL,NULL,SW_SHOWNORMAL);

Have you just tried this in E-Prime? This looks very much like what
I did several years ago to get direct access to the Windows API in
order to use some extra keyboard functions (that was before I learned
that I could do the same thing by testing for key offsets <g>).

The whole "Public Declare ..." stuff works just like in VB, of course
you have to put your .dll file in the right place, etc. But I don't
know anything about ShellExecute, perhaps that is where you're getting stuck.

Is there some compelling reason that you need to call external
executables instead of just making your whole experiment work in "the
E-Prime" way?


---
David McFarlane, Systems Designer
Dept. Psychology, Michigan State University
mcfa...@msu.edu www.msu.edu/~mcfarla9
Voice: (517) 353-0799 Fax: (517) 353-1652

chen

unread,
Nov 5, 2007, 10:12:26 PM11/5/07
to e-p...@googlegroups.com
Thank you!
 
I copyed the declare syntax to user script window (without "public" before "declare") and in an inline object used the ShellExecute function. But it seem Eprime just skiped this function. No error, but just ignore this function. The same script works well in VB.
 
Why I have to use external function is I have a special device, it not only used as response switch, but also used as a signal generator, I used VB script not only detact a key press but also receive a signal from the device. VB script fulfill this by calling an executive function. Since eprime is very good at timing, I want to write script using Eprime, but also need to use my old device. So I hope I can call that executive function in Eprime.
"ShellExecute" is a dll file I used to call that executive function in VB, If you can help me to find some way to call an executive function, i do not need to use ShellExecute. Or can you give me an Eprime example of use external function?
 
Thank you very much!

--
Chunhui Chen
______________
 
Beijing Normal University
&
University of California, Irvine


网 易 股 吧, 每 天 有 500 万 股 民 在 此 讨 论 >>

Matt Lenhart

unread,
Nov 6, 2007, 9:11:14 AM11/6/07
to E-Prime
Hello,

Please take a look at the new sample I added, ModalShellExecute.es.
This method will work for some applications. The file suspends E-
Prime, opens Notepad, and then resumes the experiment once Notepad is
closed. You will simply need to replace Notepad with the application
you desire.

In general, many of our users have been able to use this sample to run
various applications, but specific testing by PST for applications
other than Notepad has not been performed. Keep in mind that
additional programming may be required to allow the following sample
to work with the external application you want to use.


- Matt
PST Technical Consultant
http://pstnet.com

David McFarlane

unread,
Nov 6, 2007, 10:46:23 AM11/6/07
to e-p...@googlegroups.com
Matt's response should help you to call an external .exe (thanks,
Matt), however...

At 11/5/2007 10:12 PM Monday, Chunhui Chen wrote:
>I have a special device, it not only used as response switch, but
>also used as a signal generator, I used VB script not only detact a
>key press but also receive a signal from the device. VB script
>fulfill this by calling an executive function.

If you only need to read a digital signal from the device, why not
just use E-Prime's built-in "ReadPort()" function? You had to use an
external .exe in VB because VB does not provide any functions to read
from or write to arbitrary I/O ports, but one of the virtues of
E-Prime is that this ability is already built in with the added
ReadPort() and WritePort methods. You might want to give that a try.

Matt Lenhart

unread,
Nov 6, 2007, 12:35:09 PM11/6/07
to E-Prime
As for using a USB device, E-Prime does not directly support
communications with the USB bus. However, E-Prime can call into DLL
functions and can use the CreateObject API to attach to some COM
objects. The best advice we can give you, if you choose to use the
DLL- faciliated USB connection, is to refer to the Declare statement
in E-Basic Help. Before attempting to do this, however, we stress that
even if communication can be obtained, we worry about the accuracy of
the timing for what you will receive. This would, however, at least
allow you to communicate with the device without using an external
application.

If the device is recognized as a serial device in Windows, you can use
E-Prime's built-in serial port communication functions.


- Matt

chen

unread,
Nov 6, 2007, 1:33:34 PM11/6/07
to e-p...@googlegroups.com
Matt and David,
 
Thank you!
 

--
Chunhui Chen
______________
 
Beijing Normal University
&
University of California, Irvine

在2007-11-06,"David McFarlane" <mcfa...@msu.edu> 写道:

Dimitri Paisios

unread,
Jul 20, 2021, 3:51:57 PM7/20/21
to E-Prime
Hi,

I was wondering if this sample is still available somewhere. I tried to find it but no luck so far.

Thanks!
Dimitri

David McFarlane

unread,
Aug 9, 2021, 3:52:08 PM8/9/21
to e-p...@googlegroups.com
Dimitri,

Sadly, Google Groups ended its file libraries many years ago, so you
will not find ModalShellExecute.es or any other example files here
anymore. But you may still find useful examples at the PST Support
website (as well as at STEP). I think that the "Suspend/Resume
experiment" at the PST Support site may show what you are looking for.

-- David McFarlane
>> https://urldefense.com/v3/__http://pstnet.com__;!!HXCxUKc!ltmMfwsn8p_GX8iQQZIXza46UOO9rXHnBZdpwWTHQw3-IHyK0X0sUayem6WZxyOI$
>>
>>
>
Reply all
Reply to author
Forward
0 new messages