Copy link to clipboard
Copied
Dear all patient helpers,
My current project is 're-furbishing' the FameMaker to EndNote' connection. This task comprises several steps:
For step 3 I have now researched a lot and found this:
docId = F_ApiGetId(0, FV_SessionId, FP_ActiveDoc);
params = F_ApiGetSaveDefaultParams();
i = F_ApiGetPropIndex(¶ms, FS_FileType);
params.val.propVal.u.ival = FV_SaveFmtFilter;
i = F_ApiGetPropIndex(¶ms, FS_SaveFileTypeHint);
params.val.propVal.u.sval = F_StrCopyString((StringT)"0001ADBEHTML");
So my interpretation of all this leads to this snippet:
var file = app.ActiveDoc;
SaveFileRTF (file);
function SaveFileRTF (file) {
var params = GetSaveDefaultParams();
var returnParamsp = new PropVals();
var i;
i = GetPropIndex (params, Constants.FS_FileType);
params.propVal.ival = Constants.FV_SaveFmtFilter;
i = GetPropIndex (params, FS_SaveFileTypeHint);
params.propVal.ival = "0001ADBERTF ");
file.Save(file.Name, params, returnParamsp);
return;
}
But alas, this reports a stange error: "Semicolon expected on line 13". Even If you help me to overcome this the next swamp lurks in step 4: how to open the RTF?
Hi Klaus, This works for me in FrameMaker 12. Please let me know if you have any questions or comments. -Rick
...#target framemaker
var doc = app.ActiveDoc;
saveRtf (doc);
function saveRtf (doc) {
var saveName, saveParams, retParams, i = 0;
// Get a property list to return any error messages.
retProps = new PropVals();
saveProps = GetSaveDefaultParams();
i = GetPropIndex (saveProps, Constants.FS_FileType);
saveProps.propVal.ival = Constants.FV_SaveFmtFilter;
Copy link to clipboard
Copied
Ah, at least line 12 should read
i = GetPropIndex (params, Constants.FS_SaveFileTypeHint);
And after spotting the superfluous ) at the end of line 13 - no error occurs,
but the script does nothing to an open/active doc
So what is missing?
Edit:
I notice that properties are starting lower case in the FM Object Reference.
So I change line 15 from
file.Save(file.Name, params, returnParamsp);
to
file.Save(file.name, params, returnParamsp);
But that has no effect.
Concerning the syntax
Using the FrameMaker 12 Ob ject model (chm) from Jongware as of 18-Jan-2015) i see this (the FM devnet is aged with FM10 scripting guide etc., however FrameMaker Support Center leads to the FrameMaker Learn & Support with the FM-12 Scripting Guide)
- In the FrameMaker 12 Object Reference properties start upper case (e.g. CurrentPage)
- Same is true for the methods there: AddText
- In the JS base classes properties start lower case (e.g. absoluteURI)
- Same is true for the methods there: concat
- For the Script UI classes the properties start lower case (e.g. parent)
- And the methods also start lowe case (e.g. drawOSControl)
IMHO this is more than tricky.
Copy link to clipboard
Copied
Hi Klaus, This works for me in FrameMaker 12. Please let me know if you have any questions or comments. -Rick
#target framemaker
var doc = app.ActiveDoc;
saveRtf (doc);
function saveRtf (doc) {
var saveName, saveParams, retParams, i = 0;
// Get a property list to return any error messages.
retProps = new PropVals();
saveProps = GetSaveDefaultParams();
i = GetPropIndex (saveProps, Constants.FS_FileType);
saveProps.propVal.ival = Constants.FV_SaveFmtFilter;
i = GetPropIndex (saveProps, Constants.FS_SaveFileTypeHint);
saveProps.propVal.sval = "0001ADBIRTF ";
saveName = doc.Name.replace (/\.[^\.]+$/, ".rtf");
doc.Save (saveName, saveProps, retProps);
}
Copy link to clipboard
Copied
The key here is on line 17. Since the file hint is a string you have to use sval instead of ival. ival would indicate an integer data type; sval is a string.
Copy link to clipboard
Copied
Thanks Rick!
Compared to my code the difference is in providing the extension rtf in the file name. The sval was there already.
Hence my other test with a hardcoded target file name (containing that rtf) worked, but not the 'flexible' script.
I still have to learn to more carefully compare go and nogo situations...