[Ttssh2-commit] [3413] マクロコマンド exec に、第3引数 ( オプション ) を追加。

Back to archive index

svnno****@sourc***** svnno****@sourc*****
2009年 5月 19日 (火) 22:28:06 JST


Revision: 3413
          http://svn.sourceforge.jp/view?root=ttssh2&view=rev&rev=3413
Author:   maya
Date:     2009-05-19 22:28:06 +0900 (Tue, 19 May 2009)

Log Message:
-----------
マクロコマンド exec に、第3引数(オプション)を追加。
  CreateProcess で起動して終了を待ち、返り値を result に格納する。

Modified Paths:
--------------
    trunk/doc/en/html/about/history.html
    trunk/doc/en/html/macro/command/exec.html
    trunk/doc/ja/html/about/history.html
    trunk/doc/ja/html/macro/command/exec.html
    trunk/teraterm/ttpmacro/ttl.c


-------------- next part --------------
Modified: trunk/doc/en/html/about/history.html
===================================================================
--- trunk/doc/en/html/about/history.html	2009-05-19 11:26:12 UTC (rev 3412)
+++ trunk/doc/en/html/about/history.html	2009-05-19 13:28:06 UTC (rev 3413)
@@ -74,6 +74,7 @@
         </ul></li-->
       <li>added the `|' character into the clickable URL as a part of composition characters.</li>
       <!--li>ƒRƒ}ƒ“ƒhƒ‰ƒCƒ“ƒIƒvƒVƒ‡ƒ“‚ŁA <a href="../commandline/teraterm.html#f">/F</a> ƒIƒvƒVƒ‡ƒ“‚Í‘¼‚̃IƒvƒVƒ‡ƒ“‚æ‚èæ‚ɏˆ—‚·‚é(ã‘‚«‚³‚ê‚é)‚悤‚ɕύX‚µ‚½B</li-->
+      <!--li>ƒ}ƒNƒƒRƒ}ƒ“ƒh "<a href="../macro/command/exec.html">exec</a>" ‚ɁA‹N“®‚µ‚½ƒAƒvƒŠƒP[ƒVƒ‡ƒ“‚̏I—¹ƒR[ƒh‚ð result ‚ÉŠi”[‚·‚邽‚߂̃IƒvƒVƒ‡ƒ“‚ð’ljÁ‚µ‚½B</li-->
     </ul></li>
 
   <li>Bug fixes

Modified: trunk/doc/en/html/macro/command/exec.html
===================================================================
--- trunk/doc/en/html/macro/command/exec.html	2009-05-19 11:26:12 UTC (rev 3412)
+++ trunk/doc/en/html/macro/command/exec.html	2009-05-19 13:28:06 UTC (rev 3413)
@@ -18,7 +18,7 @@
 </p>
 
 <pre class="macro-syntax">
-exec &lt;command line&gt; [&lt;show&gt;]
+exec &lt;command line&gt; [&lt;show&gt; [&lt;wait&gt;]]
 </pre>
 
 <h2>Remarks</h2>
@@ -35,6 +35,8 @@
 show ;default parameters when no show command specified. 
 </pre>
 
+<!--&lt;wait&gt; ƒpƒ‰ƒ[ƒ^‚É 1 ‚ðŽw’è‚·‚é‚ƁA‹N“®‚µ‚½ƒAƒvƒŠƒP[ƒVƒ‡ƒ“‚ªI—¹‚·‚é‚܂ő҂BƒAƒvƒŠƒP[ƒVƒ‡ƒ“‚̏I—¹ƒR[ƒh‚ª result ƒVƒXƒeƒ€•Ï”‚ÉŠi”[‚³‚ê‚éB<em>(version 4.63 or later)</em>-->
+
 <h2>Example</h2>
 
 <pre class="macro-example">

Modified: trunk/doc/ja/html/about/history.html
===================================================================
--- trunk/doc/ja/html/about/history.html	2009-05-19 11:26:12 UTC (rev 3412)
+++ trunk/doc/ja/html/about/history.html	2009-05-19 13:28:06 UTC (rev 3413)
@@ -74,6 +74,7 @@
         </ul></li>
       <li>ƒNƒŠƒbƒJƒuƒ‹URL‚É‚¨‚¢‚āAƒo[ƒeƒBƒJƒ‹ƒo[(|)‚ðURL\¬•¶Žš‚Æ‚µ‚ÄŽ¯•Ê‚·‚é‚悤‚É‚µ‚½B</li>
       <li>ƒRƒ}ƒ“ƒhƒ‰ƒCƒ“ƒIƒvƒVƒ‡ƒ“‚ŁA <a href="../commandline/teraterm.html#f">/F</a> ƒIƒvƒVƒ‡ƒ“‚Í‘¼‚̃IƒvƒVƒ‡ƒ“‚æ‚èæ‚ɏˆ—‚·‚é(ã‘‚«‚³‚ê‚é)‚悤‚ɕύX‚µ‚½B</li>
+      <li>ƒ}ƒNƒƒRƒ}ƒ“ƒh "<a href="../macro/command/exec.html">exec</a>" ‚ɁA‹N“®‚µ‚½ƒAƒvƒŠƒP[ƒVƒ‡ƒ“‚̏I—¹ƒR[ƒh‚ð result ‚ÉŠi”[‚·‚邽‚߂̃IƒvƒVƒ‡ƒ“‚ð’ljÁ‚µ‚½B</li>
     </ul></li>
 
   <li>ƒoƒOC³

Modified: trunk/doc/ja/html/macro/command/exec.html
===================================================================
--- trunk/doc/ja/html/macro/command/exec.html	2009-05-19 11:26:12 UTC (rev 3412)
+++ trunk/doc/ja/html/macro/command/exec.html	2009-05-19 13:28:06 UTC (rev 3413)
@@ -18,7 +18,7 @@
 </p>
 
 <pre class="macro-syntax">
-exec &lt;command line&gt; [&lt;show&gt;]
+exec &lt;command line&gt; [&lt;show&gt; [&lt;wait&gt;]]
 </pre>
 
 <h2>‰ðà</h2>
@@ -27,7 +27,7 @@
 ƒRƒ}ƒ“ƒhƒ‰ƒCƒ“•¶Žš—ñ &lt;command line&gt; ‚ɏ]‚¢AƒAƒvƒŠƒP[ƒVƒ‡ƒ“‚ð‹N“®‚·‚éB
 </p>
 
-showƒpƒ‰ƒ[ƒ^‚ɂ͈ȉº‚Ì•¶Žš—ñ‚ðŽw’è‚·‚邱‚Æ‚ª‚Å‚«‚éB
+&lt;show&gt; ƒpƒ‰ƒ[ƒ^‚ɂ͈ȉº‚Ì•¶Žš—ñ‚ðŽw’è‚·‚邱‚Æ‚ª‚Å‚«‚éB
 <pre>
 hide
 minimize
@@ -35,6 +35,8 @@
 show ;default parameters when no show command specified. 
 </pre>
 
+&lt;wait&gt; ƒpƒ‰ƒ[ƒ^‚É 1 ‚ðŽw’è‚·‚é‚ƁA‹N“®‚µ‚½ƒAƒvƒŠƒP[ƒVƒ‡ƒ“‚ªI—¹‚·‚é‚܂ő҂BƒAƒvƒŠƒP[ƒVƒ‡ƒ“‚̏I—¹ƒR[ƒh‚ª result ƒVƒXƒeƒ€•Ï”‚ÉŠi”[‚³‚ê‚éB<em>(ƒo[ƒWƒ‡ƒ“ 4.63ˆÈ~)</em>
+
 <h2>—á</h2>
 
 <pre class="macro-example">

Modified: trunk/teraterm/ttpmacro/ttl.c
===================================================================
--- trunk/teraterm/ttpmacro/ttl.c	2009-05-19 11:26:12 UTC (rev 3412)
+++ trunk/teraterm/ttpmacro/ttl.c	2009-05-19 13:28:06 UTC (rev 3413)
@@ -18,6 +18,7 @@
 #include "ttlib.h"
 #include "ttmenc.h"
 #include "tttypes.h"
+#include <shellapi.h>
 
 // Oniguruma: Regular expression library
 #define ONIG_EXTERN extern
@@ -787,6 +788,7 @@
 {
 	TStrVal Str,Str2;
 	int mode = SW_SHOW;
+	int wait = 0, ret;
 	WORD Err;
 
 	Err = 0;
@@ -806,6 +808,12 @@
 			mode = SW_SHOW;
 		else
 			Err = ErrSyntax;
+
+		// get 3nd arg(optional) if given
+		if (CheckParameterGiven()) {
+			GetIntVal(&wait, &Err);
+			if (Err!=0) return Err;
+		}
 	}
 
 	if ((Err==0) &&
@@ -814,7 +822,20 @@
 
 	if (Err!=0) return Err;
 
-	WinExec(Str, mode);
+	if (!wait) {
+		WinExec(Str, mode);
+	}
+	else {
+		STARTUPINFO sui;
+		PROCESS_INFORMATION pi;
+		memset(&sui, 0, sizeof(STARTUPINFO));
+		sui.cb = sizeof(STARTUPINFO);
+		sui.wShowWindow = mode;
+		CreateProcess(NULL, Str, NULL, NULL, FALSE, NORMAL_PRIORITY_CLASS, NULL, NULL, &sui, &pi);
+		WaitForSingleObject(pi.hProcess, INFINITE);
+		GetExitCodeProcess(pi.hProcess, &ret);
+		SetResult(ret);
+	}
 	return Err;
 }
 



Ttssh2-commit メーリングリストの案内
Back to archive index