<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://www.infopathdev.com:443/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>General</title><link>https://www.infopathdev.com:443/forums/41.aspx</link><description>If you're not sure where to ask your question, ask it here. If necessary, our moderators will make sure it gets classified in the correct board.</description><dc:language>en</dc:language><generator>CommunityServer 2007 SP3 (Build: 31118.962)</generator><item><title>Re: Computing a power of 2 in an expression box</title><link>https://www.infopathdev.com:443/forums/thread/23826.aspx</link><pubDate>Fri, 19 Oct 2007 08:22:51 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:23826</guid><dc:creator>brisco</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/23826.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=41&amp;PostID=23826</wfw:commentRss><description>&lt;p&gt;Thanks for the tip, but it actually only &amp;quot;kind of&amp;quot; works... The problem is that my A, B and C attributes are in a repeating block, and I&amp;#39;d like the expression box to display the value for the &lt;b&gt;current &lt;/b&gt;element. &lt;/p&gt;
&lt;p&gt;Imagine I have the following XML:&lt;/p&gt;
&lt;pre&gt;&amp;lt;root&amp;gt;&amp;nbsp;&lt;br /&gt;&amp;nbsp; &amp;lt;element A=&amp;quot;15&amp;quot; B=&amp;quot;12&amp;quot; C=&amp;quot;1024&amp;quot;/&amp;gt;&amp;nbsp;&lt;br /&gt;&amp;nbsp; &amp;lt;element A=&amp;quot;14&amp;quot; B=&amp;quot;10&amp;quot; C=&amp;quot;103582&amp;quot;/&amp;gt;&lt;br /&gt;&amp;lt;/root&amp;gt;&amp;nbsp;&lt;/pre&gt;
&lt;p&gt;Assuming my formula is D = C / (2^(A-B)), I&amp;#39;d like to display (pardon the basic layouting !)&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;15&amp;nbsp;&amp;nbsp;&amp;nbsp; 12&amp;nbsp;&amp;nbsp;&amp;nbsp; 1024&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 128.0&lt;/p&gt;
&lt;p&gt;14&amp;nbsp;&amp;nbsp;&amp;nbsp; 10&amp;nbsp;&amp;nbsp;&amp;nbsp; 103582&amp;nbsp;&amp;nbsp;&amp;nbsp; 6473.875&lt;/p&gt;
&lt;p style="margin:0px;text-indent:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="margin:0px;text-indent:0px;"&gt;With the above instructions and the following Xpath:&lt;/p&gt;&lt;p style="margin:0px;text-indent:0px;"&gt;&amp;quot;@C div xdXDocument:GetDOM(&amp;quot;Util&amp;quot;)/PowersOfTwo/PowerOfTwo[position() = xdXDocument:get-DOM()/root/element/@A - xdXDocument:get-DOM()/root/element/@B]&amp;nbsp;&lt;/p&gt;&lt;p style="margin:0px;text-indent:0px;"&gt;the values in both expression boxes use the same A and B, but different C values. I somehow understand that as @C appears before we change contexts and start from the document root again. But that does not answer my needs :-(&lt;br /&gt;&lt;/p&gt;&lt;p style="margin:0px;text-indent:0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin:0px;text-indent:0px;"&gt;Note that I&amp;#39;ve removed the my: prefix which Infopath says is unknown. I don&amp;#39;t think that explains the problem, though...&lt;br /&gt;&lt;/p&gt;</description></item><item><title>Re: Computing a power of 2 in an expression box</title><link>https://www.infopathdev.com:443/forums/thread/23822.aspx</link><pubDate>Thu, 18 Oct 2007 21:31:16 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:23822</guid><dc:creator>davidair</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/23822.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=41&amp;PostID=23822</wfw:commentRss><description>&lt;p&gt;Introduce a secondary data source with a repeating element which will contain all the values, something like that:&lt;/p&gt;
&lt;p&gt;&amp;lt;values&amp;gt;&lt;br /&gt;&amp;nbsp; &amp;lt;value&amp;gt;2&amp;lt;/value&amp;gt;&lt;br /&gt;&amp;nbsp; &amp;lt;value&amp;gt;4&amp;lt;/value&amp;gt;&lt;br /&gt;&amp;nbsp; &amp;lt;value&amp;gt;8&amp;lt;/value&amp;gt;&lt;br /&gt;&amp;nbsp; ..&lt;br /&gt;&amp;nbsp; &amp;lt;value&amp;gt;8388608&amp;lt;/value&amp;gt;&lt;br /&gt;&amp;lt;/values&amp;gt;&lt;/p&gt;
&lt;p&gt;Then in your expression box, refer to the row that corresponds to the value you want, something like this: &lt;/p&gt;
&lt;p&gt;xdXDocument:GetDOM(&amp;quot;values&amp;quot;)/values/value[position() = xdXDocument:get-DOM()/my:myFields/my:A - xdXDocument:get-DOM()/my:myFields/my:B]&lt;/p&gt;
&lt;p&gt;This expresssion will return the power of two corresponding to the difference between A and B (I am assuming A, B are children of myFields and the secondary data source is named &amp;quot;values&amp;quot;)&lt;/p&gt;</description></item><item><title>Computing a power of 2 in an expression box</title><link>https://www.infopathdev.com:443/forums/thread/23821.aspx</link><pubDate>Thu, 18 Oct 2007 21:12:39 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:23821</guid><dc:creator>brisco</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/23821.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=41&amp;PostID=23821</wfw:commentRss><description>&lt;div class="ForumPostBodyArea"&gt;
									    &lt;div class="ForumPostContentText"&gt;
										    &lt;p&gt;Hi,&lt;/p&gt;&lt;p&gt;I&amp;#39;ve spent a good part of the afternoon trying to get an expression box to display a calculated value which uses a &amp;quot;non-trivial&amp;quot; (i.e. not available in XPath 1.0) function. In an element with 3 attributes A, B and C I&amp;#39;d like to display a D value computed as D = C / (2^(A-B)) but D is redundant with A, B and C and I don&amp;#39;t want to have to add it to the schema. It&amp;#39;s really for information purposes only... I&amp;#39;d like it to be updated whenever A, B or C change however !&lt;br /&gt;&lt;/p&gt;&lt;p&gt;I did manage to display C / (A-B) using an expression box and the following Xpath: &amp;quot;@C div (number(@A) -
number(@B))&amp;quot;, but somehow I&amp;#39;ve not managed to compute 2^(A-B). I tried various tricks (including &amp;quot;xdExtension:computeD(A,B,C)&amp;quot; and computeD(...) implemented in script.js, or a secondary datasource with a table of powers of 2) without success :-( I must say that I&amp;#39;m new to JScript and such non-trivial use of Infopath, so I may have missed something pretty obvious.&lt;br /&gt; &lt;/p&gt;&lt;p&gt;Note : A-B is an integer varying in a known range (1 to 23) which makes it possible to pre-compute the values if that can help. &lt;br /&gt;&lt;/p&gt;
										    
									    &lt;/div&gt;
									    
									    &lt;/div&gt;&lt;p&gt;&amp;nbsp;Any help would be appreciated :-) Thanks !&lt;br /&gt;&lt;/p&gt;</description></item></channel></rss>