>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
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
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.
If the device is recognized as a serial device in Windows, you can use
E-Prime's built-in serial port communication functions.
- Matt