1. How to run Eu pgm FROM Eu pgm, with PARAMETERS (for 2nd Eu pgm)
- Posted by Dan_M Jul 11, 2009
- 1204 views
How can I run a Euphoria program FROM a Euphoria program,
when the 2nd program (the one to be run from within the initial Eu program),
requires parameters?
I was trying to "wrap" R. M. Forno's file compare program(s) (diff11.ex, etc) with a Windows GUI,
so I could compare versions of apps without having to type the file names,
as is required with his cmd interface.
So I tried shellExecuteEx, as follows:
scode = shellExecuteEx ( "open", "ex.exe", {aCompare, FirstFile, SecondFile }, 0,SW_NORMAL , 0)
where aCompare was one of selected diff11.ex, diff21.ex, etc, file compare programs,
and FirstFile and SecondFile were the results of getOpenFileName,
intended to be the parameters of the specified file compare program:
FirstFile = getOpenFileName(Window1,"",{"Euphoria Windows Programs","*.exw", "Euphoria dos","*.ex"}) setText(EditText8, FirstFile)
and I got the following error: C:\Programming\EUPHORIA\Libraries\Win32Lib_60_5\Include\w32support.e:1228 in function w32acquire_mem() sequence to be poked must only contain atoms
but when I put the (suspect?) "FirstFile" & "SecondFile" into text boxes to see
what they were, they looked like nothing but a sequence of the path/file name.
So, what's wrong with how I'm doing it, and what should I be doing?
Dan
2. Re: How to run Eu pgm FROM Eu pgm, with PARAMETERS (for 2nd Eu pgm)
- Posted by DerekParnell (admin) Jul 11, 2009
- 1183 views
How can I run a Euphoria program FROM a Euphoria program,
Try...
scode = shellExecuteEx ( "open", "ex.exe", sprintf("%s %s %s", {aCompare, FirstFile, SecondFile}), 0,SW_NORMAL , 0)
The third parameter to shellExecuteEx is a string - it's what you would have otherwise typed on a command line.
3. Re: How to run Eu pgm FROM Eu pgm, with PARAMETERS (for 2nd Eu pgm)
- Posted by DerekParnell (admin) Jul 11, 2009
- 1189 views
The third parameter to shellExecuteEx is a string - it's what you would have otherwise typed on a command line.
Looking at the docs now, I can see why you did what you did. The docs are misleading so I'll fix that.
4. Re: How to run Eu pgm FROM Eu pgm, with PARAMETERS (for 2nd Eu pgm)
- Posted by Dan_M Jul 11, 2009
- 1191 views
The third parameter to shellExecuteEx is a string - it's what you would have otherwise typed on a command line.
Looking at the docs now, I can see why you did what you did. The docs are misleading so I'll fix that.
Thanks Derek!
5. Re: How to run Eu pgm FROM Eu pgm, with PARAMETERS (for 2nd Eu pgm)
- Posted by Dan_M Jul 11, 2009
- 1168 views
How can I run a Euphoria program FROM a Euphoria program,
Try...
scode = shellExecuteEx ( "open", "ex.exe", sprintf("%s %s %s", {aCompare, FirstFile, SecondFile}), 0,SW_NORMAL , 0)
The third parameter to shellExecuteEx is a string - it's what you would have otherwise typed on a command line.
Two more questions: What are the error codes, numerically, for shellExecuteEx,or where are they defined?
and, what if the path/file name includes SPACES in the path, how do I specify that so that a DOS program can handle it?
Dan
6. Re: How to run Eu pgm FROM Eu pgm, with PARAMETERS (for 2nd Eu pgm)
- Posted by DerekParnell (admin) Jul 11, 2009
- 1201 views
The third parameter to shellExecuteEx is a string - it's what you would have otherwise typed on a command line.
Looking at the docs now, I can see why you did what you did. The docs are misleading so I'll fix that.
Thanks Derek!
Rev62: uploaded corrected shellExecuteEx() and its docs.
7. Re: How to run Eu pgm FROM Eu pgm, with PARAMETERS (for 2nd Eu pgm)
- Posted by DerekParnell (admin) Jul 11, 2009
- 1210 views
What are the error codes, numerically, for shellExecuteEx,or where are they defined?
and, what if the path/file name includes SPACES in the path, how do I specify that so that a DOS program can handle it?
- The error codes are documented here. However there is a bug in the function. Instead of returning the error code, it returns !0 if it succeeds and 0 if it fails. I'll fix this too.
- You should be able to use spaces in the file string without problems ...
res = shellExecuteEx("open", "c:\\program files\\myapps\\special app.exe", ...)
8. Re: How to run Eu pgm FROM Eu pgm, with PARAMETERS (for 2nd Eu pgm)
- Posted by DerekParnell (admin) Jul 11, 2009
- 1213 views
However there is a bug in the function. Instead of returning the error code, it returns !0 if it succeeds and 0 if it fails. I'll fix this too.
Rev63: uploaded corrected shellExecuteEx() and its docs.
9. Re: How to run Eu pgm FROM Eu pgm, with PARAMETERS (for 2nd Eu pgm)
- Posted by Dan_M Jul 11, 2009
- 1205 views
What are the error codes, numerically, for shellExecuteEx,or where are they defined?
and, what if the path/file name includes SPACES in the path, how do I specify that so that a DOS program can handle it?
- The error codes are documented here. However there is a bug in the function. Instead of returning the error code, it returns !0 if it succeeds and 0 if it fails. I'll fix this too.
- You should be able to use spaces in the file string without problems ...
res = shellExecuteEx("open", "c:\\program files\\myapps\\special app.exe", ...)
On this machine, I'm running Win32Lib 0.60.5, under Eu 2.5, and when I run my "wrap", I get a return code of 5, and NOTHING seems to happen.
When I put a wait_key() at the end of one of the file compares, in case it was displaying in cmd window too quickly to see, I see NOTHING. That's why I was thinking maybe spaces in path made the file compare not run when executed by shellExecuteEx.
And the "diffxx.ex" file compares are in same folder as the GUI "wrap".
Any suggestions on debug?
Dan
10. Re: How to run Eu pgm FROM Eu pgm, with PARAMETERS (for 2nd Eu pgm)
- Posted by DerekParnell (admin) Jul 11, 2009
- 1207 views
On this machine, I'm running Win32Lib 0.60.5, under Eu 2.5, and when I run my "wrap", I get a return code of 5, and NOTHING seems to happen.
When I put a wait_key() at the end of one of the file compares, in case it was displaying in cmd window too quickly to see, I see NOTHING. That's why I was thinking maybe spaces in path made the file compare not run when executed by shellExecuteEx.
And the "diffxx.ex" file compares are in same folder as the GUI "wrap".
Any suggestions on debug?
I've just done some testing here and its all working just fine.
I'm using Euphoria 4 and win32lib 0.70.16, so I can't directly comment on the results you are getting with old version of the programs.
Here is the programs I used ...
-- Main test program include win32lib.ew constant win = create(Window, "Shell", 0, 0, 0, 500, 500, 0) constant btn = create(Button, "Do It", win, 10, 10, 50, 50, 0) constant res = create(EditText, "", win, 10, 100, 250, 30, 0) integer cnt = 0 procedure click_Btn(integer self, integer event, sequence parms) cnt += 1 setText( res, sprintf("%02d RC=%d", {cnt, shellExecuteEx("open", "c:\\program files\\utils\\eui.exe", {"c:\\temp\\tests.ex","Q","W R"}, 0, 0, 0) } ) ) end procedure setHandler( btn, w32HClick,routine_id("click_Btn")) WinMain(win, Normal)
-- Program that is invoked (tests.ex). sequence c = command_line() integer fh fh = open("c:\\temp\\test.res", "w") for i = 1 to length(c) do printf(fh, "%2d '%s'\n", {i, c[i]}) end for close(fh)
Results...
1 'c:\program files\utils\eui.exe' 2 'c:\temp\tests.ex' 3 'Q' 4 'W R'
11. Re: How to run Eu pgm FROM Eu pgm, with PARAMETERS (for 2nd Eu pgm)
- Posted by Dan_M Jul 11, 2009
- 1206 views
ok, I'll try what I was doing on another machine with later version of Win32Lib, 70 something, & see what happens.
Here's what I was doing:
-- code generated by Win32Lib IDE v0.20.1 include Win32Lib.ew without warning -------------------------------------------------------------------------------- -- Window Window1 constant Window1 = createEx( Window, "File Compare Wrap", 0, Default, Default, 587, 356, 0, 0 ) constant StatusBar11 = createEx( StatusBar, "StatusBar11", Window1, 0, 0, 0, 0, 0, 0 ) constant PushButton4 = createEx( PushButton, "Pick First File", Window1, 228, 20, 88, 28, 0, 0 ) constant PushButton5 = createEx( PushButton, "Pick Second File", Window1, 360, 20, 88, 28, 0, 0 ) constant PushButton6 = createEx( PushButton, "Compare", Window1, 480, 20, 88, 28, 0, 0 ) constant LText3 = createEx( CText, "Select a Compare Utility To Use", Window1, 24, 24, 168, 20, 0, 0 ) constant List2 = createEx( List, "List2", Window1, 32, 52, 148, 120, 0, 0 ) constant LText7 = createEx( LText, "Compare:", Window1, 32, 196, 64, 20, 0, 0 ) constant EditText8 = createEx( EditText, "EditText8", Window1, 112, 196, 652, 20, w32or_all({ES_READONLY}), 0 ) constant EditText10 = createEx( EditText, "EditText10", Window1, 112, 228, 656, 20, w32or_all({ES_READONLY}), 0 ) constant LText9 = createEx( LText, "With:", Window1, 32, 232, 64, 20, 0, 0 ) --------------------------------------------------------- -------------------------------------------------------------------------------- sequence FirstFile, SecondFile integer Index -------------------------------------------------------------------------------- procedure Window1_onActivate (integer self, integer event, sequence params)--params is () addItem(List2, "diff11.ex") addItem(List2, "diff21.ex") addItem(List2, "diff30.ex") addItem(List2, "diff40.ex") addItem(List2, "diff50.ex") end procedure setHandler( Window1, w32HActivate, routine_id("Window1_onActivate")) -------------------------------------------------------------------------------- procedure PushButton4_onClick (integer self, integer event, sequence params)--params is () FirstFile = getOpenFileName(Window1,"",{"Euphoria Windows Programs","*.exw", "Euphoria dos","*.ex"}) setText(EditText8, FirstFile) end procedure setHandler( PushButton4, w32HClick, routine_id("PushButton4_onClick")) -------------------------------------------------------------------------------- procedure PushButton5_onClick (integer self, integer event, sequence params)--params is () SecondFile = getOpenFileName(Window1,"",{"Euphoria Windows Programs","*.exw", "Euphoria dos","*.ex"}) setText(EditText10, SecondFile) end procedure setHandler( PushButton5, w32HClick, routine_id("PushButton5_onClick")) -------------------------------------------------------------------------------- procedure PushButton6_onClick (integer self, integer event, sequence params)--params is () integer scode sequence aCompare --For versions 1.1 and 5.0, the syntax is as follows: --ex diffnn <file1> <file2> [<option>] [<time_limit>] --For versions 2.1, 3.0 and 4.0, the syntax is as follows: --ex diffnn <file1> <file2> [<option>] if Index = 1 or Index = 5 then aCompare = "diff11.ex" elsif Index = 2 then aCompare = "diff21.ex" elsif Index = 3 then aCompare = "diff30.ex" elsif Index = 4 then aCompare = "diff40.ex" elsif Index = 5 then aCompare = "diff50.ex" end if scode = shellExecuteEx ( "open", "ex.exe", sprintf("%s %s %s", {aCompare, FirstFile, SecondFile}), 0,SW_NORMAL , 0) setText(StatusBar11, sprint(scode)) end procedure setHandler( PushButton6, w32HClick, routine_id("PushButton6_onClick")) -------------------------------------------------------------------------------- procedure List2_onChange (integer self, integer event, sequence params)--params is () Index = getIndex(List2) end procedure setHandler( List2, w32HChange, routine_id("List2_onChange")) WinMain( Window1,Maximize )
Dan
12. Re: How to run Eu pgm FROM Eu pgm, with PARAMETERS (for 2nd Eu pgm)
- Posted by Dan_M Jul 11, 2009
- 1219 views
On this machine, I'm running Win32Lib 0.60.5, under Eu 2.5, and when I run my "wrap", I get a return code of 5, and NOTHING seems to happen.
When I put a wait_key() at the end of one of the file compares, in case it was displaying in cmd window too quickly to see, I see NOTHING. That's why I was thinking maybe spaces in path made the file compare not run when executed by shellExecuteEx.
And the "diffxx.ex" file compares are in same folder as the GUI "wrap".
Any suggestions on debug?
I've just done some testing here and its all working just fine.
I'm using Euphoria 4 and win32lib 0.70.16, so I can't directly comment on the results you are getting with old version of the programs.
Here is the programs I used ...
-- Main test program include win32lib.ew constant win = create(Window, "Shell", 0, 0, 0, 500, 500, 0) constant btn = create(Button, "Do It", win, 10, 10, 50, 50, 0) constant res = create(EditText, "", win, 10, 100, 250, 30, 0) integer cnt = 0 procedure click_Btn(integer self, integer event, sequence parms) cnt += 1 setText( res, sprintf("%02d RC=%d", {cnt, shellExecuteEx("open", "c:\\program files\\utils\\eui.exe", {"c:\\temp\\tests.ex","Q","W R"}, 0, 0, 0) } ) ) end procedure setHandler( btn, w32HClick,routine_id("click_Btn")) WinMain(win, Normal)
-- Program that is invoked (tests.ex). sequence c = command_line() integer fh fh = open("c:\\temp\\test.res", "w") for i = 1 to length(c) do printf(fh, "%2d '%s'\n", {i, c[i]}) end for close(fh)
Results...
1 'c:\program files\utils\eui.exe' 2 'c:\temp\tests.ex' 3 'Q' 4 'W R'
Derek,
I'm pretty sure my problem IS because of spaces in path name, at least when the path/file name used as a parameter is procured from getOpenFileName.
When I make a small test program to be called by shellExecuteEx, with "test" as the first parameter for the TEST program,
and a path/file name returned by getOpenFileName as the second parameter,
here's what I get output by the test pgm:
C:\PROGRA~2\EUPHORIA\BIN\EX.EXE <-- interpreter test.ex <-- test program test <-- first param for test pgm C:\Programming\EUPHORIA\Programs <-- ALL is SENT as the second parameter! Under <-- but separated and TREATED as THREE param Development\FromIde\CompareFiles\cp1a1b.exwSo I'm sending a sequence variable SecondFile as the second parameter to the test file, not
"C:\\Programming\\EUPHORIA\\Programs Under Development\\FromIde\\CompareFiles\\cp1a1b.exw"even though they should be approx. the same thing.
I know there's a way to make that be taken as "one" item, but I forget what it is.
Looks like it has to do with the DOUBLE slashes,
but like I said, I forget how to "trick" Eu into thinking they're there
if that's what it takes.
Dan
13. Re: How to run Eu pgm FROM Eu pgm, with PARAMETERS (for 2nd Eu pgm)
- Posted by euphoric (admin) Jul 11, 2009
- 1188 views
I know there's a way to make that be taken as "one" item, but I forget what it is.
Put the path in quotes.
So something like
x = "\"" & thePath & "\""
14. Re: How to run Eu pgm FROM Eu pgm, with PARAMETERS (for 2nd Eu pgm)
- Posted by Dan_M Jul 11, 2009
- 1165 views
I know there's a way to make that be taken as "one" item, but I forget what it is.
Put the path in quotes.
So something like
x = "\"" & thePath & "\""
I'm gonna try it, but won't that just put a slash before and after the path?
Dan
15. Re: How to run Eu pgm FROM Eu pgm, with PARAMETERS (for 2nd Eu pgm)
- Posted by Dan_M Jul 11, 2009
- 1173 views
I know there's a way to make that be taken as "one" item, but I forget what it is.
Put the path in quotes.
So something like
x = "\"" & thePath & "\""
I'm gonna try it, but won't that just put a slash before and after the path?
Dan
argh, should have THOUGHT first, you're absolutly right, sigh.
Not SLASHES, QUOTES ESCAPED BY SLASH!
And thanks!
Dan
16. Re: How to run Eu pgm FROM Eu pgm, with PARAMETERS (for 2nd Eu pgm)
- Posted by Dan_M Jul 11, 2009
- 1190 views
sigh, unfortunately, now that my test pgm works fine, my actual "wrap" still doesn't.
My GUI "wrap" of R.Forno's compare doesn't cause the diff11.ex to RUN. my test.ex pgm runs from the wrap, receives and reports the parameters just fine, and is in the same folder as the wrapped compare pgm, but the diff11.ex just won't run at all.
Guess I'll have to give it some more thought later.
dan