When exactly do you want your script to be run? Do you want this value calculated when a manager edits a page?
If I understand you correctly, you have 2 fields in your templates, let’s say a and b. Your plugin could read the values, then choose which one to output. The event that would trigger its execution would be when someone edits a document... I’m not sure exactly which one to use, but login to the control panel --> Resources --> Manage Resources --> Plugin, then choose to create a new Plugin and look at its "System Events" tab. There you get a list of all system events. The following caught my eye under the "Documents" section:
- OnDocFormPrerender
- OnDocFormRender
Here’s one example of how to read a document’s page title:
$doc = $modx->getDocument(1);
echo $doc[‘pagetitle’];
You can probably use the document object api to put values back into a document before it renders. Does that make sense.
There isn’t much documentation on Plugins

but here’s the official page:
http://modxcms.com/plugin-examples.html
You might learn more by looking at the Document Object:
http://modxcms.com/the-document-object.html
The one thing I’m not seeing is how to access template variables using the document api... I know how to get them using a sql query, but that’s sort of a pain.
Hope this gets you started.