<?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>Revcoders</title>
	<atom:link href="http://revcoders.org/feed/" rel="self" type="application/rss+xml" />
	<link>http://revcoders.org</link>
	<description>for Rev coders</description>
	<lastBuildDate>Mon, 17 May 2010 05:08:57 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0-beta2</generator>
		<item>
		<title>filterWSearch</title>
		<link>http://revcoders.org/filterwsearch/</link>
		<comments>http://revcoders.org/filterwsearch/#comments</comments>
		<pubDate>Tue, 29 Apr 2008 17:54:49 +0000</pubDate>
		<dc:creator>chip</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Mac OS X]]></category>
		<category><![CDATA[Vista]]></category>
		<category><![CDATA[Windows XP]]></category>
		<category><![CDATA[filter]]></category>
		<category><![CDATA[search]]></category>

		<guid isPermaLink="false">http://revcoders.org/?p=28</guid>
		<description><![CDATA[First, the search field script: ON keyUp tKey FilterWSearch me END keyUp ON backspaceKey delete char -1 of me FilterWSearch me END backspaceKey Obviously we&#8217;re not accounting for arrows, selected text, but it works fine, no one misses those things, for a simple search people just type a few characters&#8230;) Then, the table field (&#8220;theData&#8221;) [...]]]></description>
			<content:encoded><![CDATA[<p>First, the search field script:<br />
<code><br />
ON keyUp tKey<br />
FilterWSearch me<br />
END keyUp</code></p>
<p><code>ON backspaceKey<br />
delete char -1 of me<br />
FilterWSearch me<br />
END backspaceKey</code></p>
<p>Obviously we&#8217;re not accounting for arrows, selected text, but it works fine, no one misses those things, for a simple search people just type a few characters&#8230;)</p>
<p>Then, the table field (&#8220;theData&#8221;) contains the records, and also, a custom property (&#8220;uData&#8221;) with the data.</p>
<p>Then, somewhere in the message path:</p>
<p><code>ON FilterWSearch pSearch<br />
lock screen<br />
put the uData of fld "theData" into tList</code></p>
<p><code><br />
IF pSearch is not empty THEN<br />
filter tList WITH "*" &amp; pSearch &amp; "*"<br />
END IF</code></p>
<p><code><br />
put tList into fld "theData"<br />
END FilterWSearch</code></p>
<p>This way, if there is nothing in the search box, the table field shows all records, otherwise, it shows only records with a string matching the string typed into the search box.</p>
]]></content:encoded>
			<wfw:commentRss>http://revcoders.org/filterwsearch/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>killAllPendingMessages</title>
		<link>http://revcoders.org/killallpendingmessages/</link>
		<comments>http://revcoders.org/killallpendingmessages/#comments</comments>
		<pubDate>Thu, 24 Apr 2008 23:12:08 +0000</pubDate>
		<dc:creator>chip</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Mac OS X]]></category>
		<category><![CDATA[Vista]]></category>
		<category><![CDATA[Windows XP]]></category>
		<category><![CDATA[cancel]]></category>
		<category><![CDATA[pendingmessages]]></category>

		<guid isPermaLink="false">http://revcoders.org/?p=23</guid>
		<description><![CDATA[ON killAllPendingMessages     put the pendingmessages into tMessages     REPEAT for each line tLine in tMessages         cancel (item 1 of tLine)     END REPEAT END killAllPendingMessages]]></description>
			<content:encoded><![CDATA[<pre>ON killAllPendingMessages
    put the pendingmessages into tMessages
    REPEAT for each line tLine in tMessages
        cancel (item 1 of tLine)
    END REPEAT
END killAllPendingMessages</pre>
]]></content:encoded>
			<wfw:commentRss>http://revcoders.org/killallpendingmessages/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>findUniqueFileName</title>
		<link>http://revcoders.org/finduniquefilename/</link>
		<comments>http://revcoders.org/finduniquefilename/#comments</comments>
		<pubDate>Thu, 24 Apr 2008 23:06:06 +0000</pubDate>
		<dc:creator>chip</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Mac OS X]]></category>
		<category><![CDATA[Vista]]></category>
		<category><![CDATA[Windows XP]]></category>
		<category><![CDATA[file]]></category>
		<category><![CDATA[unique]]></category>

		<guid isPermaLink="false">http://revcoders.org/?p=22</guid>
		<description><![CDATA[FUNCTION findUniqueFileName pPathAndFile     set the itemdel to "."     put item -1 of pPathAndFile into tExtension     delete item -1 of pPathAndFile     put empty into x     REPEAT         IF x is not empty THEN             put pPathAndFile &#38; "-" &#38; x &#38; "." &#38; tExtension into [...]]]></description>
			<content:encoded><![CDATA[<p><code>FUNCTION findUniqueFileName pPathAndFile<br />
    set the itemdel to "."<br />
    put item -1 of pPathAndFile into tExtension<br />
    delete item -1 of pPathAndFile<br />
    put empty into x<br />
    REPEAT<br />
        IF x is not empty THEN<br />
            put pPathAndFile &amp; "-" &amp; x &amp; "." &amp; tExtension into tryThisFileName<br />
        ELSE <br />
            put pPathAndFile &amp; x &amp; "." &amp; tExtension into tryThisFileName<br />
        END IF<br />
        IF there is a file tryThisFileName THEN  -- find a unique filename<br />
            add 1 to x<br />
        ELSE<br />
            return tryThisFileName<br />
        END IF<br />
    END REPEAT<br />
END findUniqueFileName</code></p>
]]></content:encoded>
			<wfw:commentRss>http://revcoders.org/finduniquefilename/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>HMSfromSec</title>
		<link>http://revcoders.org/hmsfromsec/</link>
		<comments>http://revcoders.org/hmsfromsec/#comments</comments>
		<pubDate>Thu, 24 Apr 2008 22:38:40 +0000</pubDate>
		<dc:creator>chip</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Mac OS X]]></category>
		<category><![CDATA[Vista]]></category>
		<category><![CDATA[Windows XP]]></category>
		<category><![CDATA[hours]]></category>
		<category><![CDATA[human]]></category>
		<category><![CDATA[minutes]]></category>
		<category><![CDATA[seconds]]></category>
		<category><![CDATA[time]]></category>

		<guid isPermaLink="false">http://revcoders.org/?p=21</guid>
		<description><![CDATA[FUNCTION HMSfromSec totalSeconds, tDisplay put totalSeconds div 3600 into tHours put (totalSeconds - (tHours * 3600)) div 60 into tMinutes put (totalSeconds - (tMinutes * 60) - (tHours * 3600)) div 1 into tSeconds IF tDisplay = "hhmmss" THEN set the numberformat to "##" return tHours &#38; ":" &#38; tMinutes &#38; ":" &#38; tSeconds ELSE [...]]]></description>
			<content:encoded><![CDATA[<pre><span style="color: #000000;"><strong>FUNCTION</strong> HMSfromSec totalSeconds, tDisplay</span>
<span style="color: #000000;">  </span><span style="color: #7f7f00;"><strong>put</strong></span><span style="color: #000000;"> totalSeconds </span><span style="color: #7f007f;">div</span><span style="color: #000000;"> </span><span style="color: #00007f;">3600</span><span style="color: #000000;"> </span><span style="color: #7f007f;">into</span><span style="color: #000000;"> tHours</span>
<span style="color: #000000;">  </span><span style="color: #7f7f00;"><strong>put</strong></span><span style="color: #000000;"> (totalSeconds - (tHours * </span><span style="color: #00007f;">3600</span><span style="color: #000000;">)) </span><span style="color: #7f007f;">div</span><span style="color: #000000;"> </span><span style="color: #00007f;">60</span><span style="color: #000000;"> </span><span style="color: #7f007f;">into</span><span style="color: #000000;"> tMinutes</span>
<span style="color: #000000;">  </span><span style="color: #7f7f00;"><strong>put</strong></span><span style="color: #000000;"> (totalSeconds - (tMinutes * </span><span style="color: #00007f;">60</span><span style="color: #000000;">) - (tHours * </span><span style="color: #00007f;">3600</span><span style="color: #000000;">)) </span><span style="color: #7f007f;">div</span><span style="color: #000000;"> </span><span style="color: #00007f;">1</span><span style="color: #000000;"> </span><span style="color: #7f007f;">into</span><span style="color: #000000;"> tSeconds</span>
<span style="color: #000000;">  <strong>IF</strong> tDisplay = </span><span style="color: #00007f;">"hhmmss"</span><span style="color: #000000;"> <strong>THEN</strong></span>
<span style="color: #000000;">   </span><span style="color: #7f7f00;"><strong>set</strong></span><span style="color: #000000;"> </span><span style="color: #7f007f;">the</span><span style="color: #000000;"> </span><span style="color: #007f7f;">numberformat</span><span style="color: #000000;"> </span><span style="color: #7f007f;">to</span><span style="color: #000000;"> </span><span style="color: #00007f;">"##"</span>
<span style="color: #000000;"> </span><span style="color: #7f7f00;"><strong>  return</strong></span><span style="color: #000000;"> tHours &amp; </span><span style="color: #00007f;">":"</span><span style="color: #000000;"> &amp; tMinutes &amp; </span><span style="color: #00007f;">":"</span><span style="color: #000000;"> &amp; tSeconds</span>
<span style="color: #000000;"> <strong> ELSE</strong></span>
<span style="color: #000000;">   </span><span style="color: #7f7f00;"><strong>set</strong></span><span style="color: #000000;"> </span><span style="color: #7f007f;">the</span><span style="color: #000000;"> </span><span style="color: #007f7f;">numberformat</span><span style="color: #000000;"> </span><span style="color: #7f007f;">to</span><span style="color: #000000;"> </span><span style="color: #00007f;">"#"</span>
<span style="color: #000000;">  <strong>IF</strong> tHours = </span><span style="color: #00007f;">1</span><span style="color: #000000;"> <strong>THEN</strong></span>
<span style="color: #000000;">   </span><span style="color: #7f7f00;"><strong>put</strong></span><span style="color: #000000;"> tHours &amp;&amp; </span><span style="color: #00007f;">"hour, "</span><span style="color: #000000;"> </span><span style="color: #7f007f;">into</span><span style="color: #000000;"> tDuration</span>
<span style="color: #000000;">  <strong>ELSE</strong> <strong>IF</strong> tHours &gt; </span><span style="color: #00007f;">1</span><span style="color: #000000;"> <strong>THEN</strong></span>
<span style="color: #000000;">   </span><span style="color: #7f7f00;"><strong>put</strong></span><span style="color: #000000;"> tHours &amp;&amp; </span><span style="color: #00007f;">"hours, "</span><span style="color: #000000;"> </span><span style="color: #7f007f;">into</span><span style="color: #000000;"> tDuration</span>
<span style="color: #000000;"> <strong> END</strong> <strong>IF</strong></span>
<span style="color: #000000;">  <strong>IF</strong> tMinutes = </span><span style="color: #00007f;">1</span><span style="color: #000000;"> <strong>THEN</strong></span>
<span style="color: #000000;"> </span><span style="color: #7f7f00;"><strong>  put</strong></span><span style="color: #000000;"> tMinutes &amp;&amp; </span><span style="color: #00007f;">"minute, "</span><span style="color: #000000;"> </span><span style="color: #7f007f;">after</span><span style="color: #000000;"> tDuration</span>
<span style="color: #000000;">  <strong>ELSE</strong> <strong>IF</strong> tMinutes &gt; </span><span style="color: #00007f;">1</span><span style="color: #000000;"> <strong>THEN</strong></span>
<span style="color: #000000;"> </span><span style="color: #7f7f00;"><strong>  put</strong></span><span style="color: #000000;"> tMinutes &amp;&amp; </span><span style="color: #00007f;">"minutes, "</span><span style="color: #000000;"> </span><span style="color: #7f007f;">after</span><span style="color: #000000;"> tDuration</span>
<span style="color: #000000;">  <strong>END</strong> <strong>IF</strong></span>
<span style="color: #000000;"> </span><span style="color: #7f7f00;"><strong>  put</strong></span><span style="color: #000000;"> tSeconds &amp;&amp; </span><span style="color: #00007f;">"seconds"</span><span style="color: #000000;"> </span><span style="color: #7f007f;">after</span><span style="color: #000000;"> tDuration</span>
<span style="color: #000000;"> </span><span style="color: #7f7f00;"><strong>  return</strong></span><span style="color: #000000;"> tDuration</span>
<span style="color: #000000;"> <strong>END</strong> <strong>IF</strong></span>
<span style="color: #000000;"><strong>END</strong> HMSfromSec </span></pre>
]]></content:encoded>
			<wfw:commentRss>http://revcoders.org/hmsfromsec/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>humanSize</title>
		<link>http://revcoders.org/humansize/</link>
		<comments>http://revcoders.org/humansize/#comments</comments>
		<pubDate>Thu, 24 Apr 2008 22:36:27 +0000</pubDate>
		<dc:creator>chip</dc:creator>
				<category><![CDATA[Mac OS X]]></category>
		<category><![CDATA[file size]]></category>
		<category><![CDATA[human]]></category>

		<guid isPermaLink="false">http://revcoders.org/?p=20</guid>
		<description><![CDATA[FUNCTION humanSize theCurrentFileDetail   put item 2 of theCurrentFileDetail + item 3 of theCurrentFileDetail into tSize   IF tSize &#62; 1000000 THEN     set the numberformat to "#.##"     return tSize/1000000 &#38; " MB"   ELSE     set the numberformat to "#"     return tSize/1000 &#38; " KB"   END IF END humanSize]]></description>
			<content:encoded><![CDATA[<pre>FUNCTION humanSize theCurrentFileDetail

  put item 2 of theCurrentFileDetail + item 3 of theCurrentFileDetail into tSize

  IF tSize &gt; 1000000 THEN

    set the numberformat to "#.##"

    return tSize/1000000 &amp; " MB"

  ELSE

    set the numberformat to "#"

    return tSize/1000 &amp; " KB"

  END IF

END humanSize</pre>
]]></content:encoded>
			<wfw:commentRss>http://revcoders.org/humansize/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>cancelThisMsg</title>
		<link>http://revcoders.org/cancelthismsg/</link>
		<comments>http://revcoders.org/cancelthismsg/#comments</comments>
		<pubDate>Thu, 24 Apr 2008 22:23:13 +0000</pubDate>
		<dc:creator>chip</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Mac OS X]]></category>
		<category><![CDATA[Vista]]></category>
		<category><![CDATA[Windows XP]]></category>
		<category><![CDATA[cancel]]></category>
		<category><![CDATA[pendingmessages]]></category>

		<guid isPermaLink="false">http://revcoders.org/?p=19</guid>
		<description><![CDATA[ON cancelThisMsg tMsg     put the pendingmessages into tPendingMsgs     IF tMsg is in tPendingMsgs THEN           repeat FOR each line x in tPendingMsgs                 if tMsg is in x THEN cancel item 1 of x           end REPEAT     END IF END cancelThisMsg]]></description>
			<content:encoded><![CDATA[<pre>ON cancelThisMsg tMsg</pre>
<pre>    put the pendingmessages into tPendingMsgs</pre>
<pre>    IF tMsg is in tPendingMsgs THEN</pre>
<pre>          repeat FOR each line x in tPendingMsgs</pre>
<pre>                if tMsg is in x THEN cancel item 1 of x</pre>
<pre>          end REPEAT</pre>
<pre>    END IF</pre>
<pre>END cancelThisMsg</pre>
]]></content:encoded>
			<wfw:commentRss>http://revcoders.org/cancelthismsg/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>jjEnsureAssets</title>
		<link>http://revcoders.org/jjensureassets/</link>
		<comments>http://revcoders.org/jjensureassets/#comments</comments>
		<pubDate>Wed, 23 Apr 2008 22:32:31 +0000</pubDate>
		<dc:creator>chip</dc:creator>
				<category><![CDATA[Mac OS X]]></category>
		<category><![CDATA[custom properties]]></category>
		<category><![CDATA[installer]]></category>

		<guid isPermaLink="false">http://revcoders.org/?p=17</guid>
		<description><![CDATA[PROBLEM: What if your application depends on a bunch of auxiliary files in various places around the user&#8217;s hard drive- maybe these are pictures, movies, text files, settings, spreadsheets, who knows? You know you can make an installer that initially, will put all these files in all the right places. But what if the user [...]]]></description>
			<content:encoded><![CDATA[<p><span style="color: #000000;"><strong>PROBLEM: </strong>What if your application depends on a bunch of auxiliary files in various places around the user&#8217;s hard drive- maybe these are pictures, movies, text files, settings, spreadsheets, who knows? You know you can make an installer that initially, will put all these files in all the right places. But what if the user accidentally deletes or moves some of them?</span></p>
<p><span style="color: #000000;">Instead of an installer, here is a function you can run when starting up that will replace any missing asset files, &#8220;repairing&#8221; an installation if necessary on each launch.</span></p>
<h3>STEP ONE:</h3>
<p>Put all the asset files where they need to be. Then use this loop (during development) to locate each all the important files and import them into custom properties:</p>
<pre><span style="color: #980517;">ON</span> importAssetsIntoCustomProps</pre>
<pre>    <span style="color: #0000ff;">set</span> the <span style="color: #ff0000;">custompropertyset</span> of <span style="color: #df4700;">me</span> to "myAssetFiles"</pre>
<pre>    <span style="color: #980517;">REPEAT</span></pre>
<pre>        <span style="color: #0000ff;">answer</span> file "choose file to import (cancel when done)"</pre>
<pre>        <span style="color: #980517;">IF</span> it is empty <span style="color: #980517;">THEN</span> <span style="color: #0000ff;">exit</span> to top</pre>
<pre>        <span style="color: #0000ff;">set</span> the myAssetFiles[it] of <span style="color: #df4700;">me</span> to URL ("binfile:" &amp; it)</pre>
<pre>    <span style="color: #980517;">END</span> repeat</pre>
<pre><span style="color: #980517;">END</span> importAssetsIntoCustomProp</pre>
<p>(You can do this repeatedly, as much as you want, it will update the binary data if you import the same filename that has been updated)</p>
<p>The key of the custom property is the path, and the value is the binary data of the file.</p>
<h3>STEP TWO:</h3>
<p>To call the function, use something like</p>
<pre><span style="color: #980517;">ON</span> openStack</pre>
<pre>   <strong><em><a href="http://revcoders.org/wp-admin/%3Ca+href%3D%22ON%2BjjEnsureAssets%2509stack%2B%2522Untitled%2B1%2522%22%3EjjEnsureAssets%3C%2Fa%3E">jjEnsureAssets</a></em></strong></pre>
<pre><span style="color: #980517;">END</span> openStack</pre>
<h3>STEP THREE:</h3>
<p>Include this handler in your stack script:</p>
<pre><span style="color: #980517;">ON</span> jjEnsureAssets</pre>
<pre>    <span style="color: #0000ff;">set</span> the <span style="color: #ff0000;">custompropertyset</span> of <span style="color: #df4700;">me</span> to "myAssetFiles"</pre>
<pre>    <span style="color: #0000ff;">put</span> the <span style="color: #ff0000;">customproperties</span> of <span style="color: #df4700;">me</span> into tAssets</pre>
<pre>    <span style="color: #980517;">REPEAT</span> <span style="color: #980517;">FOR</span> each line pFile in the <span style="color: #df4700;">keys</span> of tAssets</pre>
<pre>        <span style="color: #980517;">IF</span> there is no file pFile <span style="color: #980517;">THEN</span></pre>
<pre>            <strong><em><a href="http://revcoders.org/wp-admin/%3Ca+href%3D%22ON%2BmakeFoldersIfNecessary%2BpLocalFilePath%2509stack%2B%2522Untitled%2B1%2522%22%3EmakeFoldersIfNecessary%3C%2Fa%3E">makeFoldersIfNecessary</a></em></strong> <strong><em><a href="http://revcoders.org/platforms/mac-os-x/pathfrompathandfile/">pathFromPathAndFile</a></em></strong>(pFile)</pre>
<pre>            <span style="color: #0000ff;">put</span> the myAssetFiles[pFile] of <span style="color: #df4700;">me</span> into URL ("binfile:" &amp; pFile)</pre>
<pre>        <span style="color: #980517;">END</span> <span style="color: #980517;">IF</span></pre>
<pre>    <span style="color: #980517;">END</span> repeat</pre>
<pre><span style="color: #980517;">END</span> jjEnsureAssets</pre>
<p>You will also need these handlers:</p>
<p><strong><em><a href="http://revcoders.org/makefoldersifnecessary/">makeFoldersIfNecessary</a></em></strong> <strong><em><a href="http://revcoders.org/pathfrompathandfile/">pathFromPathAndFile</a></em></strong></p>
<p>TO DO: Put in a merge or something to accommodate files in the user&#8217;s folder.</p>
]]></content:encoded>
			<wfw:commentRss>http://revcoders.org/jjensureassets/feed/</wfw:commentRss>
		<slash:comments>164</slash:comments>
		</item>
		<item>
		<title>humanDuration</title>
		<link>http://revcoders.org/humanduration/</link>
		<comments>http://revcoders.org/humanduration/#comments</comments>
		<pubDate>Wed, 23 Apr 2008 06:54:30 +0000</pubDate>
		<dc:creator>chip</dc:creator>
				<category><![CDATA[Mac OS X]]></category>
		<category><![CDATA[Vista]]></category>
		<category><![CDATA[Windows XP]]></category>
		<category><![CDATA[duration]]></category>
		<category><![CDATA[human]]></category>
		<category><![CDATA[player]]></category>
		<category><![CDATA[quicktime]]></category>
		<category><![CDATA[time]]></category>

		<guid isPermaLink="false">http://revcoders.org/?p=14</guid>
		<description><![CDATA[FUNCTION humanDuration -- assumes movie loaded into player 1 set the numberformat to "##" put the duration of player 1 into tTotalTicks put the timescale of player 1 into tMovieScale IF tTotalTicks = 0 OR tMovieScale = 0 THEN return "duration unknown" ELSE put tTotalTicks div tMovieScale into totalSeconds put (tTotalTicks mod tMovieScale) into partialSeconds [...]]]></description>
			<content:encoded><![CDATA[<pre><span style="color: #980517;">FUNCTION</span> humanDuration <span style="color: #8000ff;">-- assumes movie loaded into player 1</span></pre>
<pre>    <span style="color: #0000ff;">set</span> the <span style="color: #ff0000;">numberformat</span> to "##"</pre>
<pre>    <span style="color: #0000ff;">put</span> the <span style="color: #ff0000;">duration</span> of player 1 into tTotalTicks</pre>
<pre>    <span style="color: #0000ff;">put</span> the <span style="color: #ff0000;">timescale</span> of player 1 into tMovieScale</pre>
<pre>    <span style="color: #980517;">IF</span> tTotalTicks = 0 <span style="color: #980517;">OR</span> tMovieScale = 0 <span style="color: #980517;">THEN</span></pre>
<pre>        <span style="color: #0000ff;">return</span> "duration unknown"</pre>
<pre>    <span style="color: #980517;">ELSE</span></pre>
<pre>        <span style="color: #0000ff;">put</span> tTotalTicks div tMovieScale into totalSeconds</pre>
<pre>        <span style="color: #0000ff;">put</span> (tTotalTicks mod tMovieScale) into partialSeconds</pre>
<pre>        <span style="color: #0000ff;">put</span> "." &amp; partialSeconds into f</pre>
<pre>        <span style="color: #0000ff;">put</span> f * (tMovieScale/100) into frames</pre>
<pre>        <span style="color: #0000ff;">put</span> totalSeconds div 3600 into tHours</pre>
<pre>        <span style="color: #0000ff;">put</span> (totalSeconds - (tHours * 3600)) div 60 into tMinutes</pre>
<pre>        <span style="color: #0000ff;">put</span> (totalSeconds - (tMinutes * 60) - (tHours * 3600)) div 1 into tSeconds</pre>
<pre>        <span style="color: #0000ff;">return</span> tHours &amp; ":" &amp; tMinutes &amp; ":" &amp; tSeconds &amp; ":" &amp; frames</pre>
<pre>    <span style="color: #980517;">END</span> <span style="color: #980517;">IF</span></pre>
<pre><span style="color: #980517;">END</span> humanDuration</pre>
]]></content:encoded>
			<wfw:commentRss>http://revcoders.org/humanduration/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>tryFileTypeFromHeader</title>
		<link>http://revcoders.org/tryfiletypefromheader/</link>
		<comments>http://revcoders.org/tryfiletypefromheader/#comments</comments>
		<pubDate>Wed, 23 Apr 2008 06:52:47 +0000</pubDate>
		<dc:creator>chip</dc:creator>
				<category><![CDATA[Mac OS X]]></category>
		<category><![CDATA[filetype]]></category>

		<guid isPermaLink="false">http://revcoders.org/?p=13</guid>
		<description><![CDATA[This is a fallback if all other methods fail (e.g., extension, filetype, etc.) function tryFileTypeFromHeader tPathAndFile open file tPathAndFile for binary read read from file tPathAndFile for 256 put it into tHeader close file tPathAndFile put empty into tType if "H.264" is in tHeader then put "H.264 movie" into tType if char 1 to 3 [...]]]></description>
			<content:encoded><![CDATA[<p><span>This is a fallback if all other methods fail (e.g., extension, filetype, etc.)<br />
</span></p>
<pre><span>
function</span> tryFileTypeFromHeader tPathAndFile</pre>
<pre>    <span>open</span> file tPathAndFile <span>for</span> binary <span>read</span></pre>
<pre>    <span>read</span> from file tPathAndFile <span>for</span> 256</pre>
<pre>    <span>put</span> it into tHeader</pre>
<pre>    <span>close</span> file tPathAndFile</pre>
<pre>    <span>put</span> empty into tType</pre>
<pre>    <span>if</span> "H.264" is in tHeader <span>then</span> <span>put</span> "H.264 movie" into tType</pre>
<pre>    <span>if</span> char 1 to 3 of tHeader = "GIF" <span>then</span> <span>put</span> "GIF image" into tType</pre>
<pre>    <span>if</span> char 1 to 3 of tHeader = "FLV" <span>then</span> <span>put</span> "FLV movie" into tType</pre>
<pre>    <span>if</span> char 1 to 3 of tHeader = "MP3" <span>then</span> <span>put</span> "MP3 audio" into tType</pre>
<pre>    <span>if</span> char 1 to 3 of tHeader = "ID3" <span>then</span> <span>put</span> "MP3 audio" into tType</pre>
<pre>    <span>if</span> "JFIF" is in tHeader <span>then</span> <span>put</span> "JPEG/JFIF image" into tType</pre>
<pre>    <span>if</span> "IMG" is in tHeader <span>and</span> "JPEG" is in tHeader <span>then</span> <span>put</span> "JPEG image" into tType</pre>
<pre>    <span>if</span> "wide" is in tHeader  <span>and</span> "mdat" is in tHeader <span>then</span> <span>put</span> "QT movie" into tType</pre>
<pre>    <span>if</span> "mp4" is in tHeader  <span>and</span> "mdat" is in tHeader <span>then</span> <span>put</span> "mp4" into tType</pre>
<pre>    <span>if</span> "mjpg" is in tHeader <span>and</span> "JPEG" is in tHeader <span>then</span> <span>put</span> "mjpg movie" into tType</pre>
<pre>    <span>if</span> "ftypmp4" is in tHeader <span>then</span> <span>put</span> "mp4 movie" into tType</pre>
<pre>    <span>if</span> "HDV" is in tHeader <span>then</span> <span>put</span> "HDV movie" into tType</pre>
<pre>    <span>if</span> "ftypqt" is in tHeader <span>then</span> <span>put</span> "QT movie" into tType</pre>
<pre>    <span>if</span> "M4V" is in tHeader <span>then</span> <span>put</span> "m4v movie" into tType</pre>
<pre>    <span>if</span> "AIFF" is in tHeader <span>then</span> <span>put</span> "AIFF audio" into tType</pre>
<pre>    <span>if</span> "AIFC" is in tHeader <span>and</span> "sowt" is in tHeader <span>then</span> <span>put</span> "AIFC audio" into tType</pre>
<pre>    <span>if</span> "WAVE" is in tHeader <span>then</span> <span>put</span> "WAVE audio" into tType</pre>
<pre>    <span>return</span> tType</pre>
<pre><span>end</span> tryFileTypeFromHeader</pre>
]]></content:encoded>
			<wfw:commentRss>http://revcoders.org/tryfiletypefromheader/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>calcTimeRemaining</title>
		<link>http://revcoders.org/calctimeremaining/</link>
		<comments>http://revcoders.org/calctimeremaining/#comments</comments>
		<pubDate>Wed, 23 Apr 2008 06:49:34 +0000</pubDate>
		<dc:creator>chip</dc:creator>
				<category><![CDATA[Mac OS X]]></category>
		<category><![CDATA[ftp]]></category>
		<category><![CDATA[progress]]></category>
		<category><![CDATA[scrollbar]]></category>

		<guid isPermaLink="false">http://revcoders.org/?p=12</guid>
		<description><![CDATA[STEP ONE: You need a progress scrollbar called &#8220;ftpProgress&#8221; and a text field called &#8220;updateFTPstatus&#8221;. STEP TWO: Here&#8217;s the code for your libURL callback that stores the start time as a custom property: ON libURLProgress tURL, theStatus SWITCH item 1 of theStatus CASE "uploading" -- let's see if we need to initialize the scrollbar IF [...]]]></description>
			<content:encoded><![CDATA[<h3>STEP ONE:</h3>
<p>You need a progress scrollbar called &#8220;ftpProgress&#8221; and a text field called &#8220;updateFTPstatus&#8221;.</p>
<h3>STEP TWO:</h3>
<p>Here&#8217;s the code for your libURL callback that stores the start time as a custom property:</p>
<pre><span style="color: #980517;">ON</span> libURLProgress tURL, theStatus</pre>
<pre>    <span style="color: #980517;">SWITCH</span> item 1 of theStatus</pre>
<pre>        <span style="color: #980517;">CASE</span> "uploading"</pre>
<pre>            <span style="color: #8000ff;">-- let's see if we need to initialize the scrollbar</span></pre>
<pre>            <span style="color: #980517;">IF</span> the endValueSet of scrollbar "ftpProgress" is not "true" <span style="color: #980517;">THEN</span></pre>
<pre>                <span style="color: #8000ff;">--yes, upload just started, we need to initialize</span></pre>
<pre>                <span style="color: #0000ff;">lock</span> <span style="color: #ff0000;">screen</span></pre>
<pre>                <span style="color: #0000ff;">show</span> scrollbar "ftpProgress"</pre>
<pre>                <span style="color: #0000ff;">set</span> the <span style="color: #ff0000;">endvalue</span> of scrollbar "ftpProgress" to item 3 of theStatus</pre>
<pre>                <span style="color: #8000ff;">-- set a flag so we don't do this again</span></pre>
<pre>                <span style="color: #0000ff;">set</span> the endValueSet of scrollbar "ftpProgress" to true</pre>
<pre>                <span style="color: #0000ff;">set</span> the startDLTime of scrollbar "ftpProgress" to the <span style="color: #ff0000;">long</span> <span style="color: #df4700;">seconds</span></pre>
<pre>            <span style="color: #980517;">END</span> <span style="color: #980517;">IF
</span></pre>
<pre>            <span style="color: #0000ff;">set</span> the <span style="color: #ff0000;">thumbpos</span> of scrollbar "ulProgress" to item 2 of theStatus <span style="color: #8000ff;">-- update scrollbar</span></pre>
<pre>            <a><strong>updateFTPstatus</strong></a> <span style="color: #8b0000;"><strong><em><a href="http://revcoders.org/wp-admin/%3Ca+href%3D%22FUNCTION%2BcalcTimeRemaining%2BtheStatus%252C%2BtURL%2509stack%2B%2522Untitled%2B1%2522%22%3EcalcTimeRemaining%3C%2Fa%3E">calcTimeRemaining</a></em></strong></span>(theStatus, tURL)</pre>
<pre>            <span style="color: #0000ff;">break</span></pre>
<pre>        <span style="color: #980517;">CASE</span> "uploaded"</pre>
<pre>            <strong><em><a href="http://revcoders.org/wp-admin/%3Ca+href%3D%22ON%2BresetULscrollbar%2509stack%2B%2522Untitled%2B1%2522%22%3EresetULscrollbar%3C%2Fa%3E">resetULscrollbar</a></em></strong></pre>
<pre>            <a><strong>updateFTPstatus</strong></a> "ready"</pre>
<pre>            <span style="color: #0000ff;">break</span></pre>
<pre>        <span style="color: #980517;">CASE</span> "error"</pre>
<pre>            <a><strong>updateFTPstatus</strong></a> "uploading error:" &amp;&amp; theStatus</pre>
<pre>            <span style="color: #0000ff;">answer</span> "Woops! There has been an error! PANIC!!!!"</pre>
<pre>            <span style="color: #0000ff;">exit</span> to top</pre>
<pre>            <span style="color: #0000ff;">break</span></pre>
<pre>        <span style="color: #980517;">DEFAULT</span></pre>
<pre>            <span style="color: #980517;">IF</span> char -1 of tURL = "/" <span style="color: #980517;">THEN</span></pre>
<pre>                <a><strong>updateFTPstatus</strong></a> theStatus</pre>
<pre>            <span style="color: #980517;">END</span> <span style="color: #980517;">IF</span></pre>
<pre>    <span style="color: #980517;">END</span> SWITCH</pre>
<pre><span style="color: #980517;">END</span> libURLProgress</pre>
<h3>STEP THREE:</h3>
<p><strong></strong>Here&#8217;s the handler that places the text into the status text field:</p>
<pre><span style="color: #980517;">ON</span> updateFTPstatus tString</pre>
<pre>    <span style="color: #0000ff;">put</span> tString into fld "updateFTPstatus"</pre>
<pre><span style="color: #980517;">END</span> updateFTPstatus</pre>
<h3>STEP FOUR:</h3>
<p><strong></strong>And here&#8217;s the one that calculates throughput and formats the string:</p>
<pre><span style="color: #980517;">FUNCTION</span> calcTimeRemaining theStatus, tURL</pre>
<pre>    <span style="color: #0000ff;">put</span> the <span style="color: #ff0000;">long</span> <span style="color: #df4700;">seconds</span> - the startDLTime of scrollbar "myProgressScrollbar" into tElapsed</pre>
<pre>    <span style="color: #0000ff;">put</span> item 2 of theStatus/1000 into tKdownloaded</pre>
<pre>    <span style="color: #0000ff;">set</span> the <span style="color: #ff0000;">numberformat</span> to "#"</pre>
<pre>    <span style="color: #0000ff;">put</span> tKdownloaded / tElapsed into tKBperSec</pre>
<pre>    <span style="color: #0000ff;">put</span> (item 3 of theStatus - item 2 of theStatus)/1000 into tKBRemaining</pre>
<pre>    <span style="color: #980517;">IF</span> tKBperSec &gt; 0 <span style="color: #980517;">THEN</span></pre>
<pre>        <span style="color: #0000ff;">put</span> tKBRemaining/tKBperSec into tTimeRemaining</pre>
<pre>        <span style="color: #980517;">IF</span> tTimeRemaining &gt; 60 <span style="color: #980517;">THEN</span></pre>
<pre>            <span style="color: #0000ff;">put</span> tTimeRemaining div 60 into tMinutes</pre>
<pre>            <span style="color: #0000ff;">put</span> tTimeRemaining mod 60 + 1 into tSeconds</pre>
<pre>            <span style="color: #0000ff;">put</span> tMinutes &amp;&amp; "minutes" &amp;&amp; tSeconds &amp;&amp; "seconds" into tTimeLeft</pre>
<pre>        <span style="color: #980517;">ELSE</span></pre>
<pre>            <span style="color: #0000ff;">put</span> tTimeRemaining &amp;&amp; "seconds" into tTimeLeft</pre>
<pre>        <span style="color: #980517;">END</span> <span style="color: #980517;">IF</span></pre>
<pre>        <span style="color: #980517;">ELSE</span></pre>
<pre>        <span style="color: #0000ff;">put</span> "unknown" into tTimeLeft</pre>
<pre>    <span style="color: #980517;">END</span> <span style="color: #980517;">IF</span></pre>
<pre>    <span style="color: #0000ff;">put</span> " remaining @" after tTimeLeft</pre>
<pre>    <span style="color: #0000ff;">return</span> "uploading" &amp;&amp; <a><strong>fileNameFromPathAndFile</strong></a>(tURL) &amp; cr &amp; tTimeLeft &amp;&amp; tKBperSec &amp; " KB/sec"</pre>
<pre><span style="color: #980517;">END</span> calcTimeRemaining</pre>
<h3>STEP FIVE:</h3>
<p><strong></strong> And here&#8217;s the one that is called when the operation is over to reset the scrollbar:</p>
<pre>ON resetScrollbar</pre>
<pre>    lock screen</pre>
<pre>    set the endValueSet of scrollbar ftpProgress to false</pre>
<pre>    set the thumbpos of scrollbar "ftpProgress" to 0</pre>
<pre>    hide scrollbar "ftpProgress"</pre>
<pre>    hide fld "updateFTPstatus</pre>
<pre>END resetScrollbar</pre>
<h3>DEPENDENCIES:</h3>
<p><a href="http://revcoders.org/filenamefrompathandfile/">fileNameFromPathAndFile</a></p>
]]></content:encoded>
			<wfw:commentRss>http://revcoders.org/calctimeremaining/feed/</wfw:commentRss>
		<slash:comments>99</slash:comments>
		</item>
	</channel>
</rss>

