This demo is awesome:
Has all the functions you need for letter merging. Just thought I'd share it since I have it bookmarked.
As for your function, I would recommend doing an ExecuteSQL() calculation to lookup the value.
If you took <<FirstName1245>>, your calculation would look like:
ExecuteSQL("SELECT FirstName FROM TableName WHERE ID = ?" ; "" ; "" ; "1245" )
You would need to build the above function statement by parsing your tag, but that's fairly easy as well.
I think you'd want another special charater, say § to go inside the << >> tags.Something like <<FirstName§1245>> and then parse that.
Thank you. Execute SQL will get me started.