<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Clarion Edge &#187; Templates</title>
	<atom:link href="http://www.clarionedge.com/category/clarion/templates/feed" rel="self" type="application/rss+xml" />
	<link>http://www.clarionedge.com</link>
	<description>Get an Edge with Clarion!</description>
	<lastBuildDate>Thu, 29 Jul 2010 21:13:55 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>#RUN parameter limits and hiding command windows</title>
		<link>http://www.clarionedge.com/windows/tools/run-and-command-windows.html</link>
		<comments>http://www.clarionedge.com/windows/tools/run-and-command-windows.html#comments</comments>
		<pubDate>Sun, 08 Feb 2009 20:23:23 +0000</pubDate>
		<dc:creator>brahn</dc:creator>
				<category><![CDATA[Examples]]></category>
		<category><![CDATA[Templates]]></category>
		<category><![CDATA[Tools]]></category>

		<guid isPermaLink="false">http://www.clarionedge.com/?p=192</guid>
		<description><![CDATA[Recently I have been doing a fair amount of work trying to automate parts of the development process, in particular the version control aspects. I ran into what appeared to be limitations in the length [...]]]></description>
			<content:encoded><![CDATA[<p>Recently I have been doing a fair amount of work trying to automate parts of the development process, in particular the version control aspects. I ran into what appeared to be limitations in the length of parameters accepted by the Clarion templates #RUN statement. Searching the newsgroups there were a few comments from people having similar issues and the symptoms were seemed a little sporadic. I decided that the safest way was to write the commands out to a temporary batch file and use #RUN to just call that.<br />
<span id="more-192"></span><br />
This works great and has the added advantage of being able to execute, obviously, batches of commands in one go.  The thing that is annoying about this is that you <em>will</em> get the command window popping up when the command is run. Often this is fine, especially for long tasks where it is nice to see the progress but sometimes it is annoying and it would to be nice to be able to hide the window.</p>
<p>There are a few ways to do this but essentially they all seem to revolve around the <a href="http://msdn.microsoft.com/en-us/library/ms682425.aspx" target="_blank">CreateProcess</a> api Function.</p>
<ol>
<li>Write a helper DLL that wraps the CreateProcess function and can be easily called by the templates.</li>
<li>Find something that already does this so I don&#8217;t have to.</li>
</ol>
<p>If you want to go for option 1 in clarion you might like to look into <a href="http://www.berthume.com/powerrun.htm" target="_blank">PowerRun</a> from Berthume Software which is available for free download. And of course you can dig right in and make the function call directly.  However, if there is something suitable around I much prefer to use that.</p>
<p>After a quick search I found these two options:</p>
<ul>
<li>CHP.EXE (Create Hidden Process) &#8211; <a href="http://www.commandline.co.uk/chp/" target="_blank">http://www.commandline.co.uk/chp/</a></li>
<li>hidden Start (hstart.exe) &#8211; <a href="http://www.ntwind.com/software/utilities/hstart.html" target="_blank">http://www.ntwind.com/software/utilities/hstart.html</a></li>
</ul>
<p>I tried CHP first and it certainly does what it says it will but I found I wanted the option to wait until the spawned task was finished. In comes hstart. Hstart is pretty awesome. Lots of options and it also, funnily enough, does what it says it will&#8230;</p>
<p style="text-align: center;"><a href="http://www.clarionedge.com/wp-content/uploads/hstart_help21.png"><img class="size-medium wp-image-196 aligncenter" title="hstart_help21" src="http://www.clarionedge.com/wp-content/uploads/hstart_help21-242x246.png" alt="hstart_help21" width="242" height="246" /></a></p>
<p>For anyone interested, this is the template code I ended up with for calling hidden commands in a clarion template:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
</pre></td><td class="code"><pre class="clarion" style="font-family:monospace;">#GROUP(%RunCommandHidden, %<span style="color: #000080;">Command</span>, %TestMode=%FALSE),<span style="color: #000080;">AUTO</span>
<span style="">#!</span>
<span style="color: #800080;">#DECLARE</span>(%BatchFileName)
<span style="">#! We need to write the command out to a batch file for execution because</span>
<span style="">#! the #RUN command seems to have issues with the length of the command!</span>
<span style="color: #800080;">#SET</span>(%BatchFileName, <span style="color: #008000;">'run.bat')
</span><span style="color: #800080;">#SET</span>(%BatchFileName, FullName(%BatchFileName, 2))
#CREATE(%BatchFileName)
%<span style="color: #000080;">Command</span>
#CLOSE(%BatchFileName)
<span style="">#! Now we call the batch file for execution</span>
<span style="">#! using cph.exe for &quot;Create Hidden Process&quot;</span>
<span style="color: #800080;">#IF</span>(%TestMode=%FALSE)
  #RUN(<span style="color: #008000;">'hstart.exe /NOCONSOLE /WAIT ' &amp; %BatchFileName),WAIT
</span><span style="color: #800080;">#ELSE</span>
  #RUN(<span style="color: #008000;">'hstart.exe /WAIT ' &amp; %BatchFileName),WAIT
</span><span style="color: #800080;">#ENDIF</span>
#REMOVE(%BatchFileName)
#RETURN</pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.clarionedge.com/windows/tools/run-and-command-windows.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
