Purpose | The <include> statement is used to include code in other files into a Superx++ program. This allows for partitioning of large programs into files of manageable sizes. | |||||||||||
Format |
<include> <src>{file path}</src> </include>
<include>
{file path} |
the path to the file with the Superx++ code to be include |
{parm type} |
(optional) the datatype of the parameter to be substituted into {finder expr} |
{parm name} |
(optional) the name of the parameter to be substituted into {finder expr} |
{parm value} |
(optional) the value of the parameter to be substituted into {finder expr} |
{finder expr} |
the expression to be used to find the set of objects within the file to be included-- this allows for partial inclusion |
|
|
Example #1 |
<include> <src>C:\\MyDir\\MyFile.xml</src> </include> This will include all the contents of the file found at C:\\MyDir\\MyFile.xml. This kind of inclusion where the whole contents of a file are included into the program is common in other languages. You might call it complete inclusion. |
|||||||||||
Example #2 |
<include> <src>http://MyServer/MyDir/MyFile.xml</src> <object> <parm type="string" name="abc">class</parm> <parm type="string" name="xyz">XPlant</parm> <expr> has node:abc and attr:name=xyz </expr> </object> </include> This will include only the class statement defining the XPlant class within the file found at http://MyServer/MyDir/MyFile.xml. If there are other statements in the file then they are not included. This is called partial inclusion. |
|||||||||||
Example #3 |
<if> <cond> <eval> <parm type="string" name="kind">partial</parm> <expr>kind = "partial"</expr> </eval> </cond> <true> <include> <src>http://MyServer/MyDir/MyFile.xml</src> <object> <parm type="string" name="abc">class</parm> <expr> has node:abc </expr> </object> </include> </true> <false> <include> <src>http://MyServer/MyDir/MyFile.xml</src> </include> </false> </if> This will include all the class statements within the file found at http://MyServer/MyDir/MyFile.xml because the parameter kind is set to partial. If kind had a different value then the entire contents of the file would be included instead. This run-time determination of what gets included (or in a different example, you could make it include different files entirely) is called conditional inclusion. |