Good point, though I guess I was thinking more along the lines of demonstrating abstracting agent code when two or more agents are using identical methods to show how keeping things central reduces maintenance hassles in the long run, rather than trimming agent times which as you point out are already good. Perhaps abstracting is a bit much for an introductory document, though, you could be right there.
Here is a solution for the version checker which looks like it can be accomplished with a single note and attribute:
Attribute: MyVersion
Note (/UTILS/Version Checker):
Text: `
5.0.0`
MyVersion: `
5.0.0`
DisplayExpression: `
$Name + " (" + $Text + ")"`
AutoFetch: `
true`
URL: Set to wherever this note will generate.
Rule: `
if ($MyVersion != $Text) { $Color = "red"; $Container="/"; $Name="New version available"; } else { $Color=; $Container="/UTILS"; $Name="Version Checker"; };`
The template for this item would export MyVersion instead of Text, so the website version would fetch with whatever is the current version of the document. However the user’s downloaded copy would have Text set to whatever the website is reporting. The reset stuff in the Rule is probably not necessary, I just had it in there for testing.
One problem with this is that older versions of the web site (say the user was using a pre-release) would report as well. Perhaps a numeric and then math instead of string matching would be an alternate solution.
I have tested this by setting the URL to a text file on my web server
[1] that simply says ‘5.0.1’ and then setting MyVersion to ‘5.0.0’. When the document loads, it fetches the URL, notes the mismatch, and moves the note to the top level. The only issue is that it gets moved to the very bottom of the outline, but since OutlineOrder is read-only, I’m not sure how to get around that. Perhaps have the Rule modify the attributes of "/A Tinderbox Reference File" ?
This might be a good recipe for other Tinderbox documents as well that need to keep themselves up to date with a central source, or are distribution based periodicals,
et cetera.
Footnotes:
- [1] If you want to test this, the url is here.