﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<?application progid="SMath Studio Desktop" version="1.0.8348.30405"?>
<worksheet xmlns="http://smath.info/schemas/worksheet/1.0">
  <settings ppi="96">
    <identity>
      <id>b23c0b4f-7dad-40b7-9361-54163443b6b1</id>
      <revision>32</revision>
    </identity>
    <metadata lang="eng">
      <author>Peter Johns</author>
    </metadata>
    <calculation>
      <precision>3</precision>
      <exponentialThreshold>5</exponentialThreshold>
      <trailingZeros>true</trailingZeros>
      <significantDigitsMode>false</significantDigitsMode>
      <roundingMode>0</roundingMode>
      <approximateEqualAccuracy>0</approximateEqualAccuracy>
      <fractions>decimal</fractions>
    </calculation>
    <pageModel active="false" viewMode="2" printGrid="false" printAreas="true" simpleEqualsOnly="false" printBackgroundImages="true">
      <paper id="9" orientation="Portrait" width="827" height="1169" />
      <margins left="39" right="39" top="49" bottom="49" />
      <header alignment="Center" color="#a9a9a9">&amp;[DATE] &amp;[TIME] - &amp;[FILENAME]</header>
      <footer alignment="Center" color="#a9a9a9">&amp;[PAGENUM] / &amp;[COUNT]</footer>
      <backgrounds />
    </pageModel>
    <dependencies>
      <assembly name="SMath Studio Desktop" version="1.0.8348.30405" guid="a37cba83-b69c-4c71-9992-55ff666763bd" />
      <assembly name="MathRegion" version="1.11.8348.30405" guid="02f1ab51-215b-466e-a74d-5d8b1cf85e8d" />
      <assembly name="SpecialFunctions" version="1.12.8348.30405" guid="2814e667-4e12-48b1-8d51-194e480eabc5" />
      <assembly name="TextRegion" version="1.11.8348.30405" guid="485d28c5-349a-48b6-93be-12a35a1c1e39" />
      <assembly name="Mathcad Toolbox" version="0.4.8520.34563" guid="ddc09821-49f1-4c21-a829-6499de0a8f06" />
      <assembly name="include" version="0.2.8085.37792" guid="dfdcd1f7-5005-45f1-8bf8-016fb072ccf3" />
    </dependencies>
  </settings>
  <regions type="content">
    <region left="0" top="0" width="115" height="23" color="#000000" fontSize="10">
      <text lang="eng" fontFamily="Arial" fontSize="10">
        <content>
          <p style="font-weight: bold;">Simple example</p>
        </content>
      </text>
    </region>
    <region left="0" top="36" width="46" height="24" color="#000000" fontSize="10">
      <math>
        <input>
          <e type="operand">a</e>
          <e type="operand">1</e>
          <e type="operator" args="2">:</e>
        </input>
      </math>
    </region>
    <region left="0" top="72" width="46" height="24" color="#000000" fontSize="10">
      <math>
        <input>
          <e type="operand">b</e>
          <e type="operand">2</e>
          <e type="operator" args="2">:</e>
        </input>
      </math>
    </region>
    <region left="0" top="108" width="141" height="72" color="#000000" fontSize="10">
      <math decimalPlaces="0">
        <description active="false" position="Top" lang="eng">
          <content></content>
        </description>
        <input>
          <e type="operand">x</e>
          <e type="operand">c</e>
          <e type="operand">b</e>
          <e type="operand">2</e>
          <e type="operator" args="2">^</e>
          <e type="operand">2</e>
          <e type="operator" args="2">+</e>
          <e type="operator" args="2">:</e>
          <e type="operand">c</e>
          <e type="operand">x</e>
          <e type="operand">a</e>
          <e type="operand">c</e>
          <e type="operator" args="2">+</e>
          <e type="operator" args="2">:</e>
          <e type="operand">3</e>
          <e type="operand">1</e>
          <e type="function" args="5">line</e>
          <e type="operator" args="2">:</e>
        </input>
        <result action="numeric">
          <e type="operand">7</e>
        </result>
      </math>
    </region>
    <region left="171" top="117" width="202" height="23" color="#000000" fontSize="10">
      <text lang="eng" fontFamily="Arial" fontSize="10">
        <content>
          <p>Value of c calculated seperately</p>
        </content>
      </text>
    </region>
    <region left="171" top="144" width="292" height="23" color="#000000" fontSize="10">
      <text lang="eng" fontFamily="Arial" fontSize="10">
        <content>
          <p>Would like to see the result of c here, i.e. c = 6 </p>
        </content>
      </text>
    </region>
    <region left="0" top="198" width="72" height="24" color="#000000" fontSize="10">
      <math error="2" errorLocation="1">
        <input>
          <e type="operand">c</e>
          <e type="operand">c</e>
          <e type="operator" args="2">:</e>
        </input>
        <result action="numeric">
          <e type="operand">#</e>
        </result>
      </math>
    </region>
    <region left="108" top="198" width="239" height="23" color="#000000" fontSize="10">
      <text lang="eng" fontFamily="Arial" fontSize="10">
        <content>
          <p>c is not available outside of scope of x</p>
        </content>
      </text>
    </region>
    <region left="0" top="252" width="138" height="23" color="#000000" fontSize="10">
      <text lang="eng" fontFamily="Arial" fontSize="10">
        <content>
          <p style="font-weight: bold;">Real world example</p>
        </content>
      </text>
    </region>
    <region left="0" top="288" width="341" height="23" color="#000000" fontSize="10">
      <text lang="eng" fontFamily="Arial" fontSize="10">
        <content>
          <p>For example, this would be useful in the instance below</p>
        </content>
      </text>
    </region>
    <region left="0" top="324" width="238" height="23" color="#000000" fontSize="10">
      <text lang="eng" fontFamily="Arial" fontSize="10">
        <content>
          <p style="font-weight: normal;">Calculate Euler critical buckling stress</p>
        </content>
      </text>
    </region>
    <region left="0" top="360" width="109" height="30" color="#000000" fontSize="10">
      <math optimize="0">
        <description active="true" position="Top" lang="eng">
          <content>
            <p>Young's modulus of steel</p>
          </content>
        </description>
        <input>
          <e type="operand">E.stl</e>
          <e type="operand">200</e>
          <e type="operand" style="unit">GPa</e>
          <e type="operator" args="2">*</e>
          <e type="operator" args="2">:</e>
        </input>
      </math>
    </region>
    <region left="198" top="360" width="139" height="39" color="#000000" fontSize="10">
      <math>
        <description active="true" position="Top" lang="eng">
          <content>
            <p>Area of beam</p>
          </content>
        </description>
        <input>
          <e type="operand">A.beam.1</e>
          <e type="operand">3250</e>
          <e type="operand" style="unit">mm</e>
          <e type="operand">2</e>
          <e type="operator" args="2">^</e>
          <e type="operator" args="2">*</e>
          <e type="operator" args="2">:</e>
        </input>
      </math>
    </region>
    <region left="342" top="360" width="129" height="30" color="#000000" fontSize="10">
      <math>
        <description active="true" position="Top" lang="eng">
          <content>
            <p>Length of beam</p>
          </content>
        </description>
        <input>
          <e type="operand">l.beam.1</e>
          <e type="operand">2000</e>
          <e type="operand" style="unit">mm</e>
          <e type="operator" args="2">*</e>
          <e type="operator" args="2">:</e>
        </input>
      </math>
    </region>
    <region left="486" top="360" width="113" height="30" color="#000000" fontSize="10">
      <math>
        <description active="true" position="Top" lang="eng">
          <content>
            <p>Radius of gyration of beam</p>
          </content>
        </description>
        <input>
          <e type="operand">r.beam.1</e>
          <e type="operand">33</e>
          <e type="operand" style="unit">mm</e>
          <e type="operator" args="2">*</e>
          <e type="operator" args="2">:</e>
        </input>
      </math>
    </region>
    <region left="0" top="432" width="170" height="116" color="#000000" fontSize="10">
      <math optimize="2">
        <description active="true" position="Top" lang="eng">
          <content>
            <p>Critical buckling stress</p>
          </content>
        </description>
        <input>
          <e type="operand">F.oc.1</e>
          <e type="operand">λ</e>
          <e type="operand">l.beam.1</e>
          <e type="operand">r.beam.1</e>
          <e type="operator" args="2">/</e>
          <e type="operator" args="2">:</e>
          <e type="operand">F.oc</e>
          <e type="operand">π</e>
          <e type="operand">2</e>
          <e type="operator" args="2">^</e>
          <e type="operand">E.stl</e>
          <e type="operator" args="2">*</e>
          <e type="operand">λ</e>
          <e type="operand">2</e>
          <e type="operator" args="2">^</e>
          <e type="operator" args="2">/</e>
          <e type="operator" args="2">:</e>
          <e type="operand">2</e>
          <e type="operand">1</e>
          <e type="function" args="4">line</e>
          <e type="operator" args="2">:</e>
        </input>
      </math>
    </region>
    <region left="189" top="468" width="339" height="23" color="#000000" fontSize="10">
      <text lang="eng" fontFamily="Arial" fontSize="10">
        <content>
          <p>Being able to see value of λ aids understanding of F.oc</p>
        </content>
      </text>
    </region>
    <region left="0" top="576" width="146" height="30" color="#000000" fontSize="10">
      <math>
        <input>
          <e type="operand">F.oc.1</e>
        </input>
        <contract>
          <e type="operand" style="unit">MPa</e>
        </contract>
        <result action="numeric">
          <e type="operand">537.400</e>
        </result>
      </math>
    </region>
    <region left="0" top="612" width="253" height="23" color="#000000" fontSize="10">
      <text lang="eng" fontFamily="Arial" fontSize="10">
        <content>
          <p>λ could be calculate seperately, such as:</p>
        </content>
      </text>
    </region>
    <region left="306" top="612" width="161" height="53" color="#000000" fontSize="10">
      <math>
        <description active="true" position="Top" lang="eng">
          <content>
            <p>Slenderness</p>
          </content>
        </description>
        <input>
          <e type="operand">λ.1</e>
          <e type="operand">l.beam.1</e>
          <e type="operand">r.beam.1</e>
          <e type="operator" args="2">/</e>
          <e type="operator" args="2">:</e>
        </input>
        <result action="numeric">
          <e type="operand">60.606</e>
        </result>
      </math>
    </region>
    <region left="0" top="702" width="48" height="23" color="#000000" fontSize="10">
      <text lang="eng" fontFamily="Arial" fontSize="10">
        <content>
          <p>Then:</p>
        </content>
      </text>
    </region>
    <region left="54" top="702" width="271" height="74" color="#000000" fontSize="10">
      <math>
        <input>
          <e type="operand">F.oc.1</e>
          <e type="operand">F.oc</e>
          <e type="operand">π</e>
          <e type="operand">2</e>
          <e type="operator" args="2">^</e>
          <e type="operand">E.stl</e>
          <e type="operator" args="2">*</e>
          <e type="operand">λ.1</e>
          <e type="operand">2</e>
          <e type="operator" args="2">^</e>
          <e type="operator" args="2">/</e>
          <e type="operator" args="2">:</e>
          <e type="operand">1</e>
          <e type="operand">1</e>
          <e type="function" args="3">line</e>
          <e type="operator" args="2">:</e>
        </input>
        <contract>
          <e type="operand" style="unit">MPa</e>
        </contract>
        <result action="numeric">
          <e type="operand">537.400</e>
        </result>
      </math>
    </region>
    <region left="0" top="792" width="177" height="23" color="#000000" fontSize="10">
      <text lang="eng" fontFamily="Arial" fontSize="10">
        <content>
          <p style="font-weight: bold;">Why I am trying to do this</p>
        </content>
      </text>
    </region>
    <region left="0" top="828" width="749" height="38" color="#000000" fontSize="10">
      <text lang="eng" fontFamily="Arial" fontSize="10">
        <content>
          <p>However, I am trying to reuse standardised worksheets in place of functions because they enable me to do a couple of extra things.  The actual calculation might look something like this:</p>
        </content>
      </text>
    </region>
    <region left="0" top="882" width="325" height="168" color="#000000" fontSize="10">
      <math optimize="2">
        <input>
          <e type="operand">F.oc.1</e>
          <e type="operand">E</e>
          <e type="operand">E.stl</e>
          <e type="operator" args="2">:</e>
          <e type="operand">A</e>
          <e type="operand">A.beam</e>
          <e type="operator" args="2">:</e>
          <e type="operand">l</e>
          <e type="operand">l.beam.1</e>
          <e type="operator" args="2">:</e>
          <e type="operand">r</e>
          <e type="operand">r.beam.1</e>
          <e type="operator" args="2">:</e>
          <e type="operand" style="string">Section Properties.sm</e>
          <e type="function" args="1">include</e>
          <e type="operand">λ</e>
          <e type="operand">F.oc</e>
          <e type="operand">7</e>
          <e type="operand">1</e>
          <e type="function" args="9">line</e>
          <e type="operator" args="2">:</e>
        </input>
      </math>
    </region>
    <region left="351" top="999" width="207" height="23" color="#000000" fontSize="10">
      <text lang="eng" fontFamily="Arial" fontSize="10">
        <content>
          <p>Would like to see result of λ here</p>
        </content>
      </text>
    </region>
    <region left="351" top="1026" width="352" height="23" color="#000000" fontSize="10">
      <text lang="eng" fontFamily="Arial" fontSize="10">
        <content>
          <p>Both λ and F.oc are calculated in "Section Properties.sm"</p>
        </content>
      </text>
    </region>
    <region left="0" top="1071" width="71" height="23" color="#000000" fontSize="10">
      <text lang="eng" fontFamily="Arial" fontSize="10">
        <content>
          <p style="font-weight: bold;">Solution </p>
        </content>
      </text>
    </region>
    <region left="0" top="1107" width="556" height="23" color="#000000" fontSize="10">
      <text lang="eng" fontFamily="Arial" fontSize="10">
        <content>
          <p>Using the method suggested by Alvaro, we can pass global variables byref into the function:</p>
        </content>
      </text>
    </region>
    <region left="0" top="1143" width="157" height="23" color="#000000" fontSize="10">
      <text lang="eng" fontFamily="Arial" fontSize="10">
        <content>
          <p>Clear previous variables</p>
        </content>
      </text>
    </region>
    <region left="216" top="1143" width="138" height="32" color="#000000" fontSize="10">
      <math>
        <input>
          <e type="operand">λ.1</e>
          <e type="function" args="1">Clear</e>
        </input>
        <result action="numeric">
          <e type="operand">1.000</e>
        </result>
      </math>
    </region>
    <region left="0" top="1197" width="221" height="26" color="#000000" fontSize="10">
      <math optimize="2">
        <input>
          <e type="operand">path</e>
          <e type="operand" style="string"></e>
          <e type="function" args="1">CurrentDirectory</e>
          <e type="operator" args="2">:</e>
        </input>
      </math>
    </region>
    <region left="0" top="1233" width="711" height="188" color="#000000" fontSize="10">
      <math>
        <input>
          <e type="operand">λ.beam.1</e>
          <e type="operand">F.oc.beam.1</e>
          <e type="function" args="2">F.oc.Beam.1</e>
          <e type="operand" style="string">Values used in Section Properties.sm</e>
          <e type="operand">E</e>
          <e type="operand">E.stl</e>
          <e type="operator" args="2">:</e>
          <e type="operand">l</e>
          <e type="operand">l.beam.1</e>
          <e type="operator" args="2">:</e>
          <e type="operand">r</e>
          <e type="operand">r.beam.1</e>
          <e type="operator" args="2">:</e>
          <e type="operand">path</e>
          <e type="operand" style="string">Section Properties.sm</e>
          <e type="function" args="2">concat</e>
          <e type="function" args="1">include</e>
          <e type="operand" style="string">Outputs</e>
          <e type="operand">λ.beam.1</e>
          <e type="operand">λ</e>
          <e type="operator" args="2">:</e>
          <e type="operand">F.oc.beam.1</e>
          <e type="operand">F.oc</e>
          <e type="operator" args="2">:</e>
          <e type="operand">8</e>
          <e type="operand">1</e>
          <e type="function" args="10">line</e>
          <e type="operator" args="2">:</e>
        </input>
        <contract>
          <e type="operand" style="unit">MPa</e>
        </contract>
        <result action="numeric">
          <e type="operand">537.400</e>
        </result>
      </math>
    </region>
    <region left="0" top="1413" width="122" height="30" color="#000000" fontSize="10">
      <math>
        <input>
          <e type="operand">λ.beam.1</e>
        </input>
        <result action="numeric">
          <e type="operand">60.606</e>
        </result>
      </math>
    </region>
    <region left="0" top="1449" width="178" height="30" color="#000000" fontSize="10">
      <math>
        <input>
          <e type="operand">F.oc.beam.1</e>
        </input>
        <contract>
          <e type="operand" style="unit">MPa</e>
        </contract>
        <result action="numeric">
          <e type="operand">537.400</e>
        </result>
      </math>
    </region>
    <region left="0" top="1485" width="762" height="38" color="#000000" fontSize="10">
      <text lang="eng" fontFamily="Arial" fontSize="10">
        <content>
          <p>Note: using the above syntax, the name of the function does not matter as is not reused, F.oc.beam.1 makes sense as it is the answer that the function block computes.</p>
        </content>
      </text>
    </region>
    <region left="0" top="1539" width="553" height="23" color="#000000" fontSize="10">
      <text lang="eng" fontFamily="Arial" fontSize="10">
        <content>
          <p>We can now calculate a second beam without the calculation from the first beam affecting it</p>
        </content>
      </text>
    </region>
    <region left="0" top="1575" width="129" height="30" color="#000000" fontSize="10">
      <math>
        <input>
          <e type="operand">l.beam.2</e>
          <e type="operand">3000</e>
          <e type="operand" style="unit">mm</e>
          <e type="operator" args="2">*</e>
          <e type="operator" args="2">:</e>
        </input>
      </math>
    </region>
    <region left="198" top="1575" width="113" height="30" color="#000000" fontSize="10">
      <math>
        <input>
          <e type="operand">r.beam.2</e>
          <e type="operand">45</e>
          <e type="operand" style="unit">mm</e>
          <e type="operator" args="2">*</e>
          <e type="operator" args="2">:</e>
        </input>
      </math>
    </region>
    <region left="0" top="1611" width="711" height="152" color="#000000" fontSize="10">
      <math>
        <input>
          <e type="operand">λ.beam.2</e>
          <e type="operand">F.oc.beam.2</e>
          <e type="function" args="2">F.oc.beam.2</e>
          <e type="operand">E</e>
          <e type="operand">E.stl</e>
          <e type="operator" args="2">:</e>
          <e type="operand">l</e>
          <e type="operand">l.beam.2</e>
          <e type="operator" args="2">:</e>
          <e type="operand">r</e>
          <e type="operand">r.beam.2</e>
          <e type="operator" args="2">:</e>
          <e type="operand">path</e>
          <e type="operand" style="string">Section Properties.sm</e>
          <e type="function" args="2">concat</e>
          <e type="function" args="1">include</e>
          <e type="operand">λ.beam.2</e>
          <e type="operand">λ</e>
          <e type="operator" args="2">:</e>
          <e type="operand">F.oc.beam.2</e>
          <e type="operand">F.oc</e>
          <e type="operator" args="2">:</e>
          <e type="operand">6</e>
          <e type="operand">1</e>
          <e type="function" args="8">line</e>
          <e type="operator" args="2">:</e>
        </input>
        <contract>
          <e type="operand" style="unit">MPa</e>
        </contract>
        <result action="numeric">
          <e type="operand">444.132</e>
        </result>
      </math>
    </region>
    <region left="0" top="1773" width="178" height="30" color="#000000" fontSize="10">
      <math>
        <input>
          <e type="operand">F.oc.beam.2</e>
        </input>
        <contract>
          <e type="operand" style="unit">MPa</e>
        </contract>
        <result action="numeric">
          <e type="operand">444.132</e>
        </result>
      </math>
    </region>
    <region left="0" top="1809" width="122" height="30" color="#000000" fontSize="10">
      <math>
        <input>
          <e type="operand">λ.beam.2</e>
        </input>
        <result action="numeric">
          <e type="operand">66.667</e>
        </result>
      </math>
    </region>
  </regions>
</worksheet>