<?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>Function Chain &#8211; Xojo Programming Blog</title>
	<atom:link href="https://blog.xojo.com/tag/function-chain/feed/" rel="self" type="application/rss+xml" />
	<link>https://blog.xojo.com</link>
	<description>Blog about the Xojo programming language and IDE</description>
	<lastBuildDate>Wed, 21 Sep 2016 18:17:35 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>
	<item>
		<title>Untie These Chains &#8211; A Solution</title>
		<link>https://blog.xojo.com/2016/07/15/untie-these-chains-solution/</link>
		
		<dc:creator><![CDATA[Norman Palardy]]></dc:creator>
		<pubDate>Fri, 15 Jul 2016 13:14:36 +0000</pubDate>
				<category><![CDATA[Cross-Platform]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Function Chain]]></category>
		<category><![CDATA[Tips]]></category>
		<guid isPermaLink="false">http://blog.xojo.com/?p=1123</guid>

					<description><![CDATA[Earlier I posed the question about why these two similar bits of code do slightly different things: dim path1 as string = """C:\users\ieuser\desktop\new folder""" path1 =&#8230;]]></description>
										<content:encoded><![CDATA[<p>Earlier I posed the question about why these two similar bits of code do slightly different things:</p>
<pre style="padding-left: 30px;">dim path1 as string = """C:\users\ieuser\desktop\new folder"""
path1 = path1.mid(2)
path1 = path1.left(path1.len()-1)
 
dim path2 as string = """C:\users\ieuser\desktop\new folder"""
path2 = path2.mid(2).left(path2.len()-1)</pre>
<p>The issue here is the second bit of code, not the first. In the second each function in the chain returns a result and these results are held in temporary variables with the next function in the chain applied to that. The problem comes with:</p>
<pre style="padding-left: 30px;">left(path2.len()-1)
</pre>
<p>Why? Because path2 has not been altered yet. It is as if this is evaluated as:</p>
<pre style="padding-left: 30px;">dim path2 as string = """C:\users\ieuser\desktop\new folder"""

dim t1, t2 as string
t1 = path2.mid(2)
t2 = t1.left(path2.len()-1)</pre>
<pre style="padding-left: 30px;">path2 = t2</pre>
<p>Now you can see the issue. Where we compute t2 we want the altered length to be able to calculate the right number of characters to retain. But we don&#8217;t have access to that temporary, so your solution is to do something like this:</p>
<pre style="padding-left: 30px;">dim path2 as string = """C:\users\ieuser\desktop\new folder"""
path2 = path2.mid(2).left(path2.mid(2).len()-1)</pre>
<p>And now they both give us the same value!</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Untie These Chains &#8211; A Riddle</title>
		<link>https://blog.xojo.com/2016/07/15/untie-these-chains-a-riddle/</link>
		
		<dc:creator><![CDATA[Norman Palardy]]></dc:creator>
		<pubDate>Fri, 15 Jul 2016 10:02:14 +0000</pubDate>
				<category><![CDATA[Cross-Platform]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Function Chain]]></category>
		<category><![CDATA[Tips]]></category>
		<guid isPermaLink="false">http://blog.xojo.com/?p=1121</guid>

					<description><![CDATA[Here&#8217;s a riddle for you! Suppose you are in the habit of using &#8220;function chaining&#8221; like this to reduce your lines of code: path2 =&#8230;]]></description>
										<content:encoded><![CDATA[<p>Here&#8217;s a riddle for you!</p>
<p>Suppose you are in the habit of using &#8220;function chaining&#8221; like this to reduce your lines of code:</p>
<pre style="padding-left: 30px;">path2 = path2.mid(2).left(path2.len()-1)</pre>
<p>If so, be careful as they can sometimes surprise you with the results you get. Consider  the following code:</p>
<pre style="padding-left: 30px;">dim path1 as string = """C:\users\ieuser\desktop\new folder"""
path1 = path1.mid(2)
path1 = path1.left(path1.len()-1)
 
dim path2 as string = """C:\users\ieuser\desktop\new folder"""
path2 = path2.mid(2).left(path2.len()-1)

break
</pre>
<p>These two look a lot alike but do not give you the same result. Share your thoughts as to why this happens in the comments or go right to<a href="https://blog.xojo.com/?p=1123&amp;preview=true"> the solution</a>.</p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
