Problem
You want to pass data to the current topic from an INCLUDEd topic.
Context
The included topic collects and/or generates some information. The including topic needs to get access to the data, for further scripting. Ordinary user-defined TML variables are not returned from included files. (This is considered to be a "feature")
Solution
There are at least two ways to do this; both use
SpreadSheetPlugin.
$SET/$GET
SpreadSheetPlugin's variables are accessible by the calling topic. So, you can use $SET in the included topic:
%CALC{"$SET(Bar, 21)"}%
%CALC{"$SET(Foo, 42)"}%
and $GET in the including topic:
%INCLUDE{FooPage}%
%CALC{"$GET(Bar)"}% is less than %CALC{"$GET(Foo)"}%.
This should yield: 21 is less than 42.
Generate a (hidden) table
SpreadSheetPlugin is able to extract data from the most recent table in the current topic. So, have the included topic generate a table:
| Bar | 21|
| Foo | 42|
Now hide it and then extract data from it.
<!--
%INCLUDE{FooPage}%
-->
%CALC{"$T(R1:C2)"}% is less than %CALC{"$T(R2:C2)"}%.
This should yield: 21 is less than 42.
Known Uses
These techniques can be used both within the context of a wiki and when the included page is on another (eg, PHP) server.
Known Limitations
Complex and non-intuitive.
See Also