<!DOCTYPE OMNotebook>
<Notebook>
 <GroupCell closed="false" >
  <GroupCell closed="false" >
   <TextCell style="Title" >
    <Text>&lt;html>&lt;head>&lt;meta name="qrichtext" content="1" />&lt;/head>&lt;body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;">&lt;p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:Arial; font-size:38pt; font-weight:600; color:#000000;">Package Access&lt;/p>&lt;/body>&lt;/html></Text>
   </TextCell>
   <GroupCell closed="false" >
    <TextCell style="Section" >
     <Text>&lt;html>&lt;head>&lt;meta name="qrichtext" content="1" />&lt;/head>&lt;body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;">&lt;p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:Times; font-size:18pt; font-weight:600; color:#000000;">General Description&lt;/p>&lt;/body>&lt;/html></Text>
    </TextCell>
    <TextCell style="Text" >
     <Text>&lt;html>&lt;head>&lt;meta name="qrichtext" content="1" />&lt;/head>&lt;body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;">&lt;p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:Times New Roman; font-size:12pt; color:#000000;">There are essentially two ways of accessing the definitions of a package either &lt;span style=" font-style:italic;">direct reference&lt;/span> by prefixing the package name to the definition names or &lt;span style=" font-style:italic;">importing definitions&lt;/span> from the package. We have already used the first method in the &lt;a href="PackasADTs.onb#Complex Example
">&lt;span style=" text-decoration: underline; color:#0000ff;">Complex Example&lt;/span>&lt;/a>. It is usually more convenient and often necessary to use the &lt;span style=" font-family:Courier New;">import&lt;/span> mechanism, which is the subject for the next section.&lt;/p>&lt;/body>&lt;/html></Text>
    </TextCell>
   </GroupCell>
   <GroupCell closed="false" >
    <TextCell style="Section" >
     <Text>&lt;html>&lt;head>&lt;meta name="qrichtext" content="1" />&lt;/head>&lt;body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;">&lt;p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:Times; font-size:18pt; font-weight:600; color:#000000;">Importing Definitions from a Package&lt;/p>&lt;/body>&lt;/html></Text>
    </TextCell>
    <TextCell style="Text" >
     <Text>&lt;html>&lt;head>&lt;meta name="qrichtext" content="1" />&lt;/head>&lt;body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;">&lt;p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:Times New Roman; font-size:12pt; color:#000000;">&lt;span style=" font-family:Courier New;">Import&lt;/span> statements in a package or class fill the two needs of either making definitions from other packages available for use in a package or class or explicit declaration of usage dependences on other packages. An &lt;span style=" font-family:Courier New;">import&lt;/span> statement can occur in several syntactic forms. In the examples below we want to access the &lt;span style=" font-family:Courier New;">Add&lt;/span> operation of the package Modelica.Math.ComplexNumbers.&lt;br />&lt;/p>&lt;/body>&lt;/html></Text>
    </TextCell>
    <InputCell style="Input" closed="true" >
     <Input>import Modelica.Math.ComplexNumbers;        // Access by ComplexNumbers.Add
</Input>
     <Output></Output>
    </InputCell>
    <TextCell style="Text" >
     <Text>&lt;html>&lt;head>&lt;meta name="qrichtext" content="1" />&lt;/head>&lt;body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;">&lt;p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:Times New Roman; font-size:12pt; color:#000000;">&lt;/p>&lt;/body>&lt;/html></Text>
    </TextCell>
    <InputCell style="Input" closed="true" >
     <Input>import Modelica.Math.ComplexNumbers.Add;      // Access by Add
</Input>
     <Output></Output>
    </InputCell>
    <TextCell style="Text" >
     <Text>&lt;html>&lt;head>&lt;meta name="qrichtext" content="1" />&lt;/head>&lt;body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;">&lt;p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:Times New Roman; font-size:12pt; color:#000000;">&lt;/p>&lt;/body>&lt;/html></Text>
    </TextCell>
    <InputCell style="Input" closed="true" >
     <Input>import Modelica.Math.ComplexNumbers.*;        // Access by Add
</Input>
     <Output></Output>
    </InputCell>
    <TextCell style="Text" >
     <Text>&lt;html>&lt;head>&lt;meta name="qrichtext" content="1" />&lt;/head>&lt;body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;">&lt;p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:Times New Roman; font-size:12pt; color:#000000;">&lt;/p>&lt;/body>&lt;/html></Text>
    </TextCell>
    <InputCell style="Input" closed="true" >
     <Input>import Co = Modelica.Math.ComplexNumbers;      // Access by Co.Add
</Input>
     <Output></Output>
    </InputCell>
    <GroupCell closed="false" >
     <TextCell style="Subsection" >
      <Text>&lt;html>&lt;head>&lt;meta name="qrichtext" content="1" />&lt;/head>&lt;body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;">&lt;p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:Times; font-size:14pt; font-weight:600; color:#000000;">Qualified Import&lt;/p>&lt;/body>&lt;/html></Text>
      <Rule name="CellTags" >Qualified Import</Rule>
     </TextCell>
     <TextCell style="Text" >
      <Text>&lt;html>&lt;head>&lt;meta name="qrichtext" content="1" />&lt;/head>&lt;body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;">&lt;p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:Times New Roman; font-size:12pt; color:#000000;">The&lt;span style=" font-style:italic;"> qualified import &lt;/span>statement of the form &lt;span style=" font-family:Courier New;">import&lt;/span> ; imports all definitions in a package, which subsequently can be referred to by names &lt;span style=" font-style:italic;">simplepackagename.definitionname&lt;/span>, where the &lt;span style=" font-style:italic;">simplepackagename&lt;/span> is the &lt;span style=" font-style:italic;">packagename&lt;/span> without its prefix. This is the most common form of &lt;span style=" font-family:Courier New;">import&lt;/span> &lt;span style=" font-family:Courier New;">(&lt;/span>see &lt;span style=" font-family:Courier New;">ComplexUser1) &lt;/span>that eliminates the risk for name collisions when importing from several packages.&lt;br />&lt;/p>&lt;/body>&lt;/html></Text>
     </TextCell>
     <InputCell style="Input" closed="true" >
      <Input>encapsulated package ComplexUser1
  import ComplexNumbers;

  class User
    ComplexNumbers.Complex  a(x = 1.0, y = 2.0);
    ComplexNumbers.Complex  b(x = 1.0, y = 2.0);
    ComplexNumbers.Complex  z, w;
  equation
    z = ComplexNumbers.Multiply(a, b);
    z = ComplexNumbers.Add(a, b);
  end User;

end ComplexUser1;
</Input>
      <Output></Output>
     </InputCell>
    </GroupCell>
    <GroupCell closed="false" >
     <TextCell style="Subsection" >
      <Text>&lt;html>&lt;head>&lt;meta name="qrichtext" content="1" />&lt;/head>&lt;body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;">&lt;p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:Times; font-size:14pt; font-weight:600; color:#000000;">Single Definition Import&lt;/p>&lt;/body>&lt;/html></Text>
      <Rule name="CellTags" >Single Definition Import</Rule>
     </TextCell>
     <TextCell style="Text" >
      <Text>&lt;html>&lt;head>&lt;meta name="qrichtext" content="1" />&lt;/head>&lt;body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;">&lt;p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:Times New Roman; font-size:12pt; color:#000000;">The&lt;span style=" font-style:italic;"> single definition import &lt;/span>statement of the form &lt;span style=" font-family:Courier New;">import&lt;/span> &lt;span style=" font-style:italic;">.&lt;/span>; allows you to import a single specific definition from a package and use that definition referred to by its &lt;span style=" font-style:italic;">definitionname&lt;/span> without the package prefix. This allows you to only write &lt;span style=" font-family:Courier New;">Add&lt;/span> (see &lt;span style=" font-family:Courier New;">ComplexUser2&lt;/span> below) but still you have to write an &lt;span style=" font-family:Courier New;">import&lt;/span> statement for each imported definition which can be a bit cumbersome. There is no risk for name collision as long as you do not try to import two definitions with the same short name.&lt;br />&lt;/p>&lt;/body>&lt;/html></Text>
     </TextCell>
     <InputCell style="Input" closed="true" >
      <Input>encapsulated package ComplexUser2
  import ComplexNumbers.Complex;
  import ComplexNumbers.Multiply;
  import ComplexNumbers.Add;

  class User
    Complex  a(x = 1.0, y = 2.0);
    Complex  b(x = 1.0, y = 2.0);
    Complex  z, w;
  equation
    z = Multiply(a, b);
    z = Add(a, b);
  end User;

end ComplexUser2;
</Input>
      <Output></Output>
     </InputCell>
    </GroupCell>
    <GroupCell closed="false" >
     <TextCell style="Subsection" >
      <Text>&lt;html>&lt;head>&lt;meta name="qrichtext" content="1" />&lt;/head>&lt;body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;">&lt;p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:Times; font-size:14pt; font-weight:600; color:#000000;">Unqualified Import&lt;/p>&lt;/body>&lt;/html></Text>
      <Rule name="CellTags" >Unqualified Import</Rule>
     </TextCell>
     <TextCell style="Text" >
      <Text>&lt;html>&lt;head>&lt;meta name="qrichtext" content="1" />&lt;/head>&lt;body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;">&lt;p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:Times New Roman; font-size:12pt; color:#000000;">The&lt;span style=" font-style:italic;"> unqualified import &lt;/span>statement of the form &lt;span style=" font-family:Courier New;">import&lt;/span> &lt;span style=" font-style:italic;">packagename.*&lt;/span>; imports all definitions from the package using their short names without qualification prefixes. This is shown in &lt;span style=" font-family:Courier New;">ComplexUser3&lt;/span> below. There is a high risk of name collisions as well as future compilation errors, but nice for the lazy programmer.&lt;br />&lt;/p>&lt;/body>&lt;/html></Text>
     </TextCell>
     <InputCell style="Input" closed="true" >
      <Input>class ComplexUser3
  import ComplexNumbers.*;
  Complex  a(x = 1.0, y = 2.0);
  Complex  b(x = 1.0, y = 2.0);
  Complex  z, w;
equation
  z = Multiply(a, b);
  z = Add(a, b);
end ComplexUser3;
</Input>
      <Output></Output>
     </InputCell>
    </GroupCell>
    <GroupCell closed="false" >
     <TextCell style="Subsection" >
      <Text>&lt;html>&lt;head>&lt;meta name="qrichtext" content="1" />&lt;/head>&lt;body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;">&lt;p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:Times; font-size:14pt; font-weight:600; color:#000000;">Renaming Import&lt;/p>&lt;/body>&lt;/html></Text>
      <Rule name="CellTags" >Renaming Import</Rule>
     </TextCell>
     <TextCell style="Text" >
      <Text>&lt;html>&lt;head>&lt;meta name="qrichtext" content="1" />&lt;/head>&lt;body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;">&lt;p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:Times New Roman; font-size:12pt; color:#000000;">The&lt;span style=" font-style:italic;"> renaming import &lt;/span>statement of the form &lt;span style=" font-family:Courier New;">import&lt;/span> &lt;span style=" font-style:italic;"> = &lt;/span>; imports a package and renames it locally to &lt;span style=" font-style:italic;">shortpackagename&lt;/span>. You can refer to imported definitions using  &lt;span style=" font-style:italic;">shortpackagename &lt;/span>as a presumably shorter package prefix. In the class &lt;span style=" font-family:Courier New;">ComplexUser4&lt;/span> below, Co is used instead of the longer name &lt;span style=" font-family:Courier New;">ComplexNumbers&lt;/span>.&lt;br />&lt;/p>&lt;/body>&lt;/html></Text>
     </TextCell>
     <InputCell style="Input" closed="true" >
      <Input>class ComplexUser4
  import Co = ComplexNumbers;
  Co.Complex  a(x = 1.0, y = 2.0);
  Co.Complex  b(x = 1.0, y = 2.0);
  Co.Complex  z, w;
equation
  z = Co.Multiply(a, b);
  z = Co.Add(a, b);
end ComplexUser4;
</Input>
      <Output></Output>
     </InputCell>
    </GroupCell>
   </GroupCell>
  </GroupCell>
 </GroupCell>
</Notebook>
