Hello David,
You are not manipulating the text inset but a copy of the text inset's filename. Your parameter "pathtosource" is a local copy of the property you read from the actual text inset.
Try this code instead:
var doc = app.ActiveDoc;
var textinset = doc.FirstTiInDoc;
textinset.TiFile "c:\\B.fm"
Note that the backslash has to be escaped by the backslash to make it work in a JavaScript string. To make your script fail-safe, test the textinset filename before changing it. You may not have the textinset you expect to have, as there may also be text insets on master and reference pages. All text insets are in one single linked list.
Also, updating the text insets after changing the path may not always work, as FM compares the last changed date of the text inset file with the last time the textinset was updated. To force FM to update the textinset, you should include the following code line after changing the text inset file name:
textinset.LastUpdate = 0;
Then you can call the UpdateTextInset() method and it will work.
Good luck.
Jang