$ and $$ Operators

Purpose The $ operator is used in shortx to denote XML or a Superx++ object path expression. When the $$ operator is used it means the same as the $ operator. However, the difference is that if there is a simple value within the object being accessed, $ will simply return the value itself, whereas $$ will return the whole XML tree including the value.
Format ${object path}

${XML nodes}

$${object path}

{object path} the path expression for an object
{XML nodes} one or more XML nodes

Example #1 $MyFarm

An expression that will return the value of the MyFarm node.

Example #2 $MyFarm/MyCow

An expression that will return the value of the MyCow node that is contained in the MyFarm node.

Example #3 class XFarm {
   construct {
   public:
      <MyCow breed="Friesian" />
   }
};
node(XFarm) MyFarm;
xout("\r\nThe breed is " + $MyFarm/MyCow.breed);

The code above will instantiate an object called MyFarm which contains the MyCow object. The xout statement writes the following text to the output stream:

The breed is Friesian

Example #4 class XFarm {
   construct {
   public:
      <MyCow breed="Friesian">Bessie</MyCow>
   }
};
node(XFarm) MyFarm;
xout("\r\nThe cow's name is " + $MyFarm/MyCow);
xout("\r\nThe cow's XML is " + $$MyFarm/MyCow);

The code above will instantiate an object called MyFarm which contains the MyCow object. The xout statement writes the following text to the output stream:

The cow's name is Bessie
The cow's XML is <MyFarm class="XFarm" processcode="true" construct="true">
   <MyCow breed="Friesian">Bessie</MyCow>
</MyFarm>

Example #5 class XFarm {
   construct {
   public:
      <MyCow breed="Friesian">Bessie</MyCow>
   }
};
node(XFarm) MyFarm;
xout("\r\nThe cow's name is " + $MyFarm/MyCow);
xout("\r\nThe cow's XML is " + $$MyFarm/MyCow);
MyFarm = $<MyGoat age="3">Billy</MyGoat><MyPig age="1">Babe</MyPig>;
xout("\r\nMyFarm is " + $MyFarm);

The code above will instantiate an object called MyFarm which contains the MyCow object. The xout statement writes the following text to the output stream. However, it also reassigns the MyFarm node with a literal XML nodeset. The output stream contents follow:

The cow's name is Bessie
The cow's XML is <MyFarm class="XFarm" processcode="true" construct="true">
   <MyCow breed="Friesian">Bessie</MyCow>
</MyFarm>
MyFarm is <MyFarm class="XFarm" processcode="true" construct="true">
   <MyGoat age="3">Billy</MyGoat>
   <MyPig age="1">Babe</MyPig>
</MyFarm>