<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: Pop: Goes the…um…Variable</title>
	<atom:link href="http://sixfriedrice.com/wp/pop-goes-the%e2%80%a6um%e2%80%a6variable/feed/" rel="self" type="application/rss+xml" />
	<link>http://sixfriedrice.com/wp/pop-goes-the%e2%80%a6um%e2%80%a6variable/</link>
	<description>smart business solutions</description>
	<lastBuildDate>Fri, 18 May 2012 01:30:19 -0500</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: stephen</title>
		<link>http://sixfriedrice.com/wp/pop-goes-the%e2%80%a6um%e2%80%a6variable/comment-page-1/#comment-1980</link>
		<dc:creator>stephen</dc:creator>
		<pubDate>Sun, 19 Sep 2010 22:49:45 +0000</pubDate>
		<guid isPermaLink="false">http://sixfriedrice.com/wp/?p=478#comment-1980</guid>
		<description>Great article. 
I notice you explicitly set the target field to the $variable

&lt;pre&gt;&lt;code&gt;Set Variable [$name, GetValue($names, 1)]
New Record/Request
Set Field [The Name Field; $name]&lt;/code&gt;&lt;/pre&gt;

However if you add $name as an auto entry calc in the target fields define fields options - 

For setting a single field a script set is fine sometimes however when I am setting several fields after the New Record each field that gets data past to it during a script  will have an auto enter calc with a script variable with a variable named similar to the field.

Declare variables by setting a $someVar to=
&lt;pre&gt;&lt;code&gt;Let ( [ $name = Name Field; $uid ; UID Field ] ; &quot;&quot; )&lt;/code&gt;&lt;/pre&gt;
Go to target layout.
Create new record

All fields are filled in, and creating fields outside a this script no data is auto entered in since the $name or $uid is not currently scoped.

Cheers
Stephen</description>
		<content:encoded><![CDATA[<p>Great article.<br />
I notice you explicitly set the target field to the $variable</p>
<pre><code>Set Variable [$name, GetValue($names, 1)]
New Record/Request
Set Field [The Name Field; $name]</code></pre>
<p>However if you add $name as an auto entry calc in the target fields define fields options &#8211; </p>
<p>For setting a single field a script set is fine sometimes however when I am setting several fields after the New Record each field that gets data past to it during a script  will have an auto enter calc with a script variable with a variable named similar to the field.</p>
<p>Declare variables by setting a $someVar to=</p>
<pre><code>Let ( [ $name = Name Field; $uid ; UID Field ] ; "" )</code></pre>
<p>Go to target layout.<br />
Create new record</p>
<p>All fields are filled in, and creating fields outside a this script no data is auto entered in since the $name or $uid is not currently scoped.</p>
<p>Cheers<br />
Stephen</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Edward Souza</title>
		<link>http://sixfriedrice.com/wp/pop-goes-the%e2%80%a6um%e2%80%a6variable/comment-page-1/#comment-1970</link>
		<dc:creator>Edward Souza</dc:creator>
		<pubDate>Mon, 13 Sep 2010 15:34:49 +0000</pubDate>
		<guid isPermaLink="false">http://sixfriedrice.com/wp/?p=478#comment-1970</guid>
		<description>Hello, Geoff,

I just found out you were back with your insightful (and rather amusing at times, I should add) posts, and that made my day! Welcome back.
Hello, almighty all, may this message find you productive and at peace.

Geoff, I used to declare local and global variables in Custom Functions as the result of a calculation, such as this,

&lt;pre&gt;&lt;code&gt;$$_thePath = 
	IF ( 
		Left ( htmlPath ; 6 ) = &quot;file:/&quot;; 
		htmlPath; 

		Eval ( Let ( [ FolderPath = Left ( Get ( FilePath ) ; Position ( Get ( FilePath ) ; &quot;/&quot; ; Length ( Get ( FilePath ) ) ; -1 ) ) ]; Let ( [ curDir = FolderPath ]; If ( Abs ( Get ( SystemPlatform ) ) = 2; curDir ; Substitute ( curDir ; &quot;file:/&quot; ; &quot;file:///Volumes/&quot; ) &amp; htmlPath ) ) ) )
	); 
&lt;/code&gt;&lt;/pre&gt;

Not long ago, I received a remark from a forum user stating that (sic) &quot;Declaring persisting variables during the run of a custom function is extremely problematic: if you have two calculation fields using the same CF, they will overwrite each other&#039;s variables.&quot;
I took his advice, and decided to add an extra line of code to the calculations. Using the example above, it would then be,

&lt;pre&gt;&lt;code&gt;thePath = 
IF ( 
	Left ( htmlPath ; 6 ) = &quot;file:/&quot;; 
	htmlPath; 

	Eval ( Let ( [ FolderPath = Left ( Get ( FilePath ) ; Position ( Get ( FilePath ) ; &quot;/&quot; ; Length ( Get ( FilePath ) ) ; -1 ) ) ]; Let ( [ curDir = FolderPath ]; If ( Abs ( Get ( SystemPlatform ) ) = 2; curDir ; Substitute ( curDir ; &quot;file:/&quot; ; &quot;file:///Volumes/&quot; ) &amp; htmlPath ) ) ) )
	); 

$$_thePath = thePath; 
&lt;/code&gt;&lt;/pre&gt;

I believed this change would solve the problem; nevertheless, another user kept insisting this is &quot;bad practice.&quot; 
I rely on local and global variables inside custom functions for two reasons:
1. to pass the results into fields or as scripts parameters;
2. to check, using calculation fields, for errors.

I know the over-usage of variables might add to memory heap; but, besides that, why their usage inside Custom Functions could be considered &quot;bad practice?&quot;

@ Micah and Geoff: 
Atypical situations do exist; no doubt about that.
As I write this message, my copy of FileMaker is performing a Script that compiles data from 5565 cities -- one related to the other 5564. The data compiled is:
• Geographical (city&#039;s name, state, region, coordinates, altitude, etc); 
• Distance between main and tested cities in Mi and Km (from coordinates); 
• Boolean if tested city falls into main city&#039;s range of 500 Mi.
After a five-day period, FileMaker is about 55% done.
This is despairing. :-)

God Bless and all the best,

Edward</description>
		<content:encoded><![CDATA[<p>Hello, Geoff,</p>
<p>I just found out you were back with your insightful (and rather amusing at times, I should add) posts, and that made my day! Welcome back.<br />
Hello, almighty all, may this message find you productive and at peace.</p>
<p>Geoff, I used to declare local and global variables in Custom Functions as the result of a calculation, such as this,</p>
<pre><code>$$_thePath =
	IF (
		Left ( htmlPath ; 6 ) = "file:/";
		htmlPath; 

		Eval ( Let ( [ FolderPath = Left ( Get ( FilePath ) ; Position ( Get ( FilePath ) ; "/" ; Length ( Get ( FilePath ) ) ; -1 ) ) ]; Let ( [ curDir = FolderPath ]; If ( Abs ( Get ( SystemPlatform ) ) = 2; curDir ; Substitute ( curDir ; "file:/" ; "file:///Volumes/" ) &amp; htmlPath ) ) ) )
	);
</code></pre>
<p>Not long ago, I received a remark from a forum user stating that (sic) &#8220;Declaring persisting variables during the run of a custom function is extremely problematic: if you have two calculation fields using the same CF, they will overwrite each other&#8217;s variables.&#8221;<br />
I took his advice, and decided to add an extra line of code to the calculations. Using the example above, it would then be,</p>
<pre><code>thePath =
IF (
	Left ( htmlPath ; 6 ) = "file:/";
	htmlPath; 

	Eval ( Let ( [ FolderPath = Left ( Get ( FilePath ) ; Position ( Get ( FilePath ) ; "/" ; Length ( Get ( FilePath ) ) ; -1 ) ) ]; Let ( [ curDir = FolderPath ]; If ( Abs ( Get ( SystemPlatform ) ) = 2; curDir ; Substitute ( curDir ; "file:/" ; "file:///Volumes/" ) &amp; htmlPath ) ) ) )
	); 

$$_thePath = thePath;
</code></pre>
<p>I believed this change would solve the problem; nevertheless, another user kept insisting this is &#8220;bad practice.&#8221;<br />
I rely on local and global variables inside custom functions for two reasons:<br />
1. to pass the results into fields or as scripts parameters;<br />
2. to check, using calculation fields, for errors.</p>
<p>I know the over-usage of variables might add to memory heap; but, besides that, why their usage inside Custom Functions could be considered &#8220;bad practice?&#8221;</p>
<p>@ Micah and Geoff:<br />
Atypical situations do exist; no doubt about that.<br />
As I write this message, my copy of FileMaker is performing a Script that compiles data from 5565 cities &#8212; one related to the other 5564. The data compiled is:<br />
• Geographical (city&#8217;s name, state, region, coordinates, altitude, etc);<br />
• Distance between main and tested cities in Mi and Km (from coordinates);<br />
• Boolean if tested city falls into main city&#8217;s range of 500 Mi.<br />
After a five-day period, FileMaker is about 55% done.<br />
This is despairing. <img src='http://sixfriedrice.com/wp/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>God Bless and all the best,</p>
<p>Edward</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chris</title>
		<link>http://sixfriedrice.com/wp/pop-goes-the%e2%80%a6um%e2%80%a6variable/comment-page-1/#comment-1967</link>
		<dc:creator>Chris</dc:creator>
		<pubDate>Fri, 10 Sep 2010 15:15:59 +0000</pubDate>
		<guid isPermaLink="false">http://sixfriedrice.com/wp/?p=478#comment-1967</guid>
		<description>man, I never thought of setting the $variable in a let() function. I could have saved a few steps that way.</description>
		<content:encoded><![CDATA[<p>man, I never thought of setting the $variable in a let() function. I could have saved a few steps that way.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Brian Schick</title>
		<link>http://sixfriedrice.com/wp/pop-goes-the%e2%80%a6um%e2%80%a6variable/comment-page-1/#comment-1965</link>
		<dc:creator>Brian Schick</dc:creator>
		<pubDate>Thu, 09 Sep 2010 01:38:17 +0000</pubDate>
		<guid isPermaLink="false">http://sixfriedrice.com/wp/?p=478#comment-1965</guid>
		<description>Geoff:

Thanks for the excellent follow-up - that&#039;s by far the clearest explanation of variable scoping in FM that I&#039;ve heard. 

I&#039;ll join you in steering clear of #2. The idea of seemingly &quot;local&quot; variables nebulously lurking around in my databases hurts my brane : )

Best,
Brian</description>
		<content:encoded><![CDATA[<p>Geoff:</p>
<p>Thanks for the excellent follow-up &#8211; that&#8217;s by far the clearest explanation of variable scoping in FM that I&#8217;ve heard. </p>
<p>I&#8217;ll join you in steering clear of #2. The idea of seemingly &#8220;local&#8221; variables nebulously lurking around in my databases hurts my brane : )</p>
<p>Best,<br />
Brian</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Geoff Coffey</title>
		<link>http://sixfriedrice.com/wp/pop-goes-the%e2%80%a6um%e2%80%a6variable/comment-page-1/#comment-1956</link>
		<dc:creator>Geoff Coffey</dc:creator>
		<pubDate>Fri, 03 Sep 2010 23:29:32 +0000</pubDate>
		<guid isPermaLink="false">http://sixfriedrice.com/wp/?p=478#comment-1956</guid>
		<description>Tom: 

Understood. I think it is a matter of style and the particulars of the application at hand. I use your method too sometimes.

Brian:

Right there with you. I was surprised too when I first discovered this. I thought &lt;code&gt;$variables&lt;/code&gt; were &quot;local&quot; and &lt;code&gt;$$variables&lt;/code&gt; were &quot;global.&quot; But the better terms are &quot;script variables&quot; and &quot;global variables.&quot; &lt;code&gt;$variables&lt;/code&gt; are scoped to the currently running script, and anything you do to modify them impacts the variable in that script. When the script ends, the variable goes out of scope, and a subscript will start a new scope, and restore the old one when done. 

This has two interesting implications:

1: You should generally avoid usine &lt;code&gt;$variables&lt;/code&gt; in your custom functions unless you really intend to modify script-scoped variables. Use this:

&lt;pre&gt;&lt;code&gt;Let(variable=&quot;foo&quot;, ...)&lt;/code&gt;&lt;/pre&gt;

Instead of this (which I see now and again):

&lt;pre&gt;&lt;code&gt;Let($variable=&quot;foo&quot;, ...)&lt;/code&gt;&lt;/pre&gt;

2: Calculations that run outside a script can define script &lt;code&gt;$variables&lt;/code&gt; that live at the top of heap, so to speak, and are in existence when no script is running. Some people use this fact sometimes, although I find it so strange I avoid it from sheer terror. :)

Geoff</description>
		<content:encoded><![CDATA[<p>Tom: </p>
<p>Understood. I think it is a matter of style and the particulars of the application at hand. I use your method too sometimes.</p>
<p>Brian:</p>
<p>Right there with you. I was surprised too when I first discovered this. I thought <code>$variables</code> were &#8220;local&#8221; and <code>$$variables</code> were &#8220;global.&#8221; But the better terms are &#8220;script variables&#8221; and &#8220;global variables.&#8221; <code>$variables</code> are scoped to the currently running script, and anything you do to modify them impacts the variable in that script. When the script ends, the variable goes out of scope, and a subscript will start a new scope, and restore the old one when done. </p>
<p>This has two interesting implications:</p>
<p>1: You should generally avoid usine <code>$variables</code> in your custom functions unless you really intend to modify script-scoped variables. Use this:</p>
<pre><code>Let(variable="foo", ...)</code></pre>
<p>Instead of this (which I see now and again):</p>
<pre><code>Let($variable="foo", ...)</code></pre>
<p>2: Calculations that run outside a script can define script <code>$variables</code> that live at the top of heap, so to speak, and are in existence when no script is running. Some people use this fact sometimes, although I find it so strange I avoid it from sheer terror. <img src='http://sixfriedrice.com/wp/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Geoff</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Brian Schick</title>
		<link>http://sixfriedrice.com/wp/pop-goes-the%e2%80%a6um%e2%80%a6variable/comment-page-1/#comment-1955</link>
		<dc:creator>Brian Schick</dc:creator>
		<pubDate>Fri, 03 Sep 2010 21:03:39 +0000</pubDate>
		<guid isPermaLink="false">http://sixfriedrice.com/wp/?p=478#comment-1955</guid>
		<description>Hi Geoff,

Great post - and fantastic function.

I&#039;ve (embarrassingly) missed something obvious along the way, because the scoping of $names is a real eye opener for me. 

I&#039;ve always assumed that anything a function did to a local variable passed to it would be confined to the function&#039;s space, and not have any effect on the original variable itself once the function was finished. The ability to have a function operate directly on a local variable passed to it opens up a lot of new (to me : ) possibilities.

Thanks!

Brian</description>
		<content:encoded><![CDATA[<p>Hi Geoff,</p>
<p>Great post &#8211; and fantastic function.</p>
<p>I&#8217;ve (embarrassingly) missed something obvious along the way, because the scoping of $names is a real eye opener for me. </p>
<p>I&#8217;ve always assumed that anything a function did to a local variable passed to it would be confined to the function&#8217;s space, and not have any effect on the original variable itself once the function was finished. The ability to have a function operate directly on a local variable passed to it opens up a lot of new (to me : ) possibilities.</p>
<p>Thanks!</p>
<p>Brian</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tom Fitch</title>
		<link>http://sixfriedrice.com/wp/pop-goes-the%e2%80%a6um%e2%80%a6variable/comment-page-1/#comment-1954</link>
		<dc:creator>Tom Fitch</dc:creator>
		<pubDate>Tue, 31 Aug 2010 19:16:20 +0000</pubDate>
		<guid isPermaLink="false">http://sixfriedrice.com/wp/?p=478#comment-1954</guid>
		<description>Excellent article, Geoff. I&#039;m with you in favoring easy to read and write (i.e. easy to maintain) solutions. I suppose it&#039;s somewhat in the eye of the beholder, since after reading this I will probably still use something like: 

Set Variable[ $i ; $i+1 ]
GetValue( $names ; $i )

... unless of course I need to dwindle the list for some reason. Then I&#039;ll head straight back here!</description>
		<content:encoded><![CDATA[<p>Excellent article, Geoff. I&#8217;m with you in favoring easy to read and write (i.e. easy to maintain) solutions. I suppose it&#8217;s somewhat in the eye of the beholder, since after reading this I will probably still use something like: </p>
<p>Set Variable[ $i ; $i+1 ]<br />
GetValue( $names ; $i )</p>
<p>&#8230; unless of course I need to dwindle the list for some reason. Then I&#8217;ll head straight back here!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Geoff Coffey</title>
		<link>http://sixfriedrice.com/wp/pop-goes-the%e2%80%a6um%e2%80%a6variable/comment-page-1/#comment-1953</link>
		<dc:creator>Geoff Coffey</dc:creator>
		<pubDate>Sun, 29 Aug 2010 01:51:33 +0000</pubDate>
		<guid isPermaLink="false">http://sixfriedrice.com/wp/?p=478#comment-1953</guid>
		<description>Micah:

Thanks for the update. Interesting results. As you say, though, 25,000 is atypical. One of my favorite quotes is &quot;Premature optimization is the root of all evil.&quot; :) I tend to favor easy to write and/or easy to read over faster in most cases until I find a performance problem. And I don&#039;t think we&#039;ve ever had a pop-related performance problem in practice.

I fully get that &quot;easy&quot; is subjective though, and your point is valid. Something to keep in mind. 

Thanks!

Geoff</description>
		<content:encoded><![CDATA[<p>Micah:</p>
<p>Thanks for the update. Interesting results. As you say, though, 25,000 is atypical. One of my favorite quotes is &#8220;Premature optimization is the root of all evil.&#8221; <img src='http://sixfriedrice.com/wp/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  I tend to favor easy to write and/or easy to read over faster in most cases until I find a performance problem. And I don&#8217;t think we&#8217;ve ever had a pop-related performance problem in practice.</p>
<p>I fully get that &#8220;easy&#8221; is subjective though, and your point is valid. Something to keep in mind. </p>
<p>Thanks!</p>
<p>Geoff</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Geoff Coffey</title>
		<link>http://sixfriedrice.com/wp/pop-goes-the%e2%80%a6um%e2%80%a6variable/comment-page-1/#comment-1952</link>
		<dc:creator>Geoff Coffey</dc:creator>
		<pubDate>Sun, 29 Aug 2010 01:45:37 +0000</pubDate>
		<guid isPermaLink="false">http://sixfriedrice.com/wp/?p=478#comment-1952</guid>
		<description>Tatai:

Absolutely correct. Thanks! Fixed.

Geoff</description>
		<content:encoded><![CDATA[<p>Tatai:</p>
<p>Absolutely correct. Thanks! Fixed.</p>
<p>Geoff</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Micah Woods</title>
		<link>http://sixfriedrice.com/wp/pop-goes-the%e2%80%a6um%e2%80%a6variable/comment-page-1/#comment-1951</link>
		<dc:creator>Micah Woods</dc:creator>
		<pubDate>Sun, 29 Aug 2010 01:30:41 +0000</pubDate>
		<guid isPermaLink="false">http://sixfriedrice.com/wp/?p=478#comment-1951</guid>
		<description>Hello Geoff,

I&#039;ve always been a counter guy for loops so I never thought to use a pop method like this (in FileMaker anyway). I got curious and did a little performance test to see which is fastest. I wrote 3 scripts that iterate through a list of 25,000 values and set a field to the next value until the end of the list is reached. Here are the results:

Counter Method: 23 seconds
Pop In Loop Method: 48 seconds
Pop Custom Function Method: 52 seconds

But... the question is, how often do you need to loop through 25,000 values? When I test lists of 1,000 and 5,000, the difference is minimal. Your Pop custom function is really easy to use and keeps the script very simple, I like it!

Here&#039;s a copy of my test file if anyone is interested:

http://www.scodigo.com/files/PopOrCounter.zip

Regards,
Micah</description>
		<content:encoded><![CDATA[<p>Hello Geoff,</p>
<p>I&#8217;ve always been a counter guy for loops so I never thought to use a pop method like this (in FileMaker anyway). I got curious and did a little performance test to see which is fastest. I wrote 3 scripts that iterate through a list of 25,000 values and set a field to the next value until the end of the list is reached. Here are the results:</p>
<p>Counter Method: 23 seconds<br />
Pop In Loop Method: 48 seconds<br />
Pop Custom Function Method: 52 seconds</p>
<p>But&#8230; the question is, how often do you need to loop through 25,000 values? When I test lists of 1,000 and 5,000, the difference is minimal. Your Pop custom function is really easy to use and keeps the script very simple, I like it!</p>
<p>Here&#8217;s a copy of my test file if anyone is interested:</p>
<p><a href="http://www.scodigo.com/files/PopOrCounter.zip" rel="nofollow">http://www.scodigo.com/files/PopOrCounter.zip</a></p>
<p>Regards,<br />
Micah</p>
]]></content:encoded>
	</item>
</channel>
</rss>

