Copy link to clipboard
Copied
Hi there
I'm working on an FAPI client at the moment, and the client needs to be scriptable.
Unfortunately, problems arise if FrameMaker has to display certain modal error or
dialog boxes like "This file was created with an earlier version of FrameMaker," or "Cannot display some imported graphics" or
"Document named X uses unavailable fonts, to reformat the document using available fonts, click ok". The script will hang pending user input.
I'm wondering is there anyway to programmatically suppress these errors to avoid this scenario?
Thanks
Eric
Copy link to clipboard
Copied
Hi Eric,
You should be able to suppress these messages with the proper open parameters, used with F_ApiOpen(). I've pasted the general-purpose file-opener function that I use below. If you study it, you should be able to get the idea of what is going on. Except for XML problems, this function will open just about anything without errors if the ignoreErrors and ignoreLock parameters are set to False. At the least, I'm pretty sure it will suppress all the errors you mentioned.
Russ
/////////////////////////////////////////////////////////////
// To open a document, send openCopy = False, a path, and copyDocId = 0.
// To open a copy of a document, send openCopy = True, then either the path or
// the ID of a currently-open document to copy
F_ObjHandleT ws_OpenFile(StringT path,
F_ObjHandleT copyDocId,
IntT openCopy,
IntT ignoreErrors,
IntT ignoreLock,
IntT hidden)
{
F_PropValsT openScript, *returnp = NULL;
UIntT sn;
F_ObjHandleT docId;
StringT tempPath;
IntT fileType;
if(copyDocId && openCopy)
tempPath = F_ApiGetString(FV_SessionId, copyDocId, FP_Name);
else tempPath = F_StrCopyString(path);
//If we can, determine the file type from the extension
//DEPRECATED, doesn't seem necessary.
/*
if(ws_IsSuffix(tempPath, ".xml", False))
fileType = FV_TYPE_XML;
else if(ws_IsSuffix(tempPath, ".sgml", False))
fileType = FV_TYPE_SGML;
else if(ws_IsSuffix(tempPath, ".mif", False))
fileType = FV_TYPE_MIF;
else if(ws_IsSuffix(tempPath, ".txt", False))
fileType = FV_TYPE_TEXT;
else
*/
fileType = FV_AUTORECOGNIZE;
openScript = F_ApiGetOpenDefaultParams();
sn = F_ApiGetPropIndex(&openScript, FS_AlertUserAboutFailure);
if(ignoreErrors)
openScript.val[sn].propVal.u.ival = False;
else
openScript.val[sn].propVal.u.ival = True;
sn = F_ApiGetPropIndex(&openScript, FS_BookIsInUse);
if(ignoreLock)
openScript.val[sn].propVal.u.ival = FV_ResetLockAndContinue;
else
openScript.val[sn].propVal.u.ival = FV_DoCancel;
sn = F_ApiGetPropIndex(&openScript, FS_DisallowMIF);
openScript.val[sn].propVal.u.ival = False;
sn = F_ApiGetPropIndex(&openScript, FS_DisallowXml);
openScript.val[sn].propVal.u.ival = False;
sn = F_ApiGetPropIndex(&openScript, FS_DontNotifyAPIClients);
openScript.val[sn].propVal.u.ival = True;
sn = F_ApiGetPropIndex(&openScript, FS_FileIsInUse);
if(ignoreLock)
openScript.val[sn].propVal.u.ival = FV_ResetLockAndContinue;
else
openScript.val[sn].propVal.u.ival = FV_DoCancel;
sn = F_ApiGetPropIndex(&openScript, FS_FileIsOldVersion);
openScript.val[sn].propVal.u.ival = FV_DoOK;
sn = F_ApiGetPropIndex(&openScript, FS_FontChangedMetric);
if(ignoreErrors)
openScript.val[sn].propVal.u.ival = FV_DoOK;
else
openScript.val[sn].propVal.u.ival = FV_DoCancel;
sn = F_ApiGetPropIndex(&openScript, FS_FontNotFoundInCatalog);
if(ignoreErrors)
openScript.val[sn].propVal.u.ival = FV_DoOK;
else
openScript.val[sn].propVal.u.ival = FV_DoCancel;
sn = F_ApiGetPropIndex(&openScript, FS_FontNotFoundInDoc);
if(ignoreErrors)
openScript.val[sn].propVal.u.ival = FV_DoOK;
else
openScript.val[sn].propVal.u.ival = FV_DoCancel;
sn = F_ApiGetPropIndex(&openScript, FS_LanguageNotAvailable);
if(ignoreErrors)
openScript.val[sn].propVal.u.ival = FV_DoOK;
else
openScript.val[sn].propVal.u.ival = FV_DoCancel;
sn = F_ApiGetPropIndex(&openScript, FS_LockCantBeReset);
if(ignoreLock)
openScript.val[sn].propVal.u.ival = FV_DoOK;
else
openScript.val[sn].propVal.u.ival = FV_DoCancel;
sn = F_ApiGetPropIndex(&openScript, FS_MakeVisible);
if(hidden)
openScript.val[sn].propVal.u.ival = False;
else
openScript.val[sn].propVal.u.ival = True;
sn = F_ApiGetPropIndex(&openScript, FS_NewDoc);
if(openCopy)
openScript.val[sn].propVal.u.ival = True;
else
openScript.val[sn].propVal.u.ival = False;
sn = F_ApiGetPropIndex(&openScript, FS_OpenAsType);
openScript.val[sn].propVal.u.ival = fileType;
sn = F_ApiGetPropIndex(&openScript, FS_OpenBookViewOnly);
openScript.val[sn].propVal.u.ival = False;
sn = F_ApiGetPropIndex(&openScript, FS_OpenDocViewOnly);
openScript.val[sn].propVal.u.ival = False;
sn = F_ApiGetPropIndex(&openScript, FS_OpenFileNotWritable);
if(ignoreErrors)
openScript.val[sn].propVal.u.ival = FV_DoOK;
else
openScript.val[sn].propVal.u.ival = FV_DoCancel;
sn = F_ApiGetPropIndex(&openScript, FS_RefFileNotFound);
if(ignoreErrors)
openScript.val[sn].propVal.u.ival = FV_DoOK;
else
openScript.val[sn].propVal.u.ival = FV_DoCancel;
sn = F_ApiGetPropIndex(&openScript, FS_UseAutoSaveFile);
openScript.val[sn].propVal.u.ival = FV_DoNo;
sn = F_ApiGetPropIndex(&openScript, FS_UpdateTextReferences);
openScript.val[sn].propVal.u.ival = FV_DoNo;
sn = F_ApiGetPropIndex(&openScript, FS_UpdateXRefs);
openScript.val[sn].propVal.u.ival = FV_DoNo;
sn = F_ApiGetPropIndex(&openScript, FS_UseRecoverFile);
openScript.val[sn].propVal.u.ival = FV_DoNo;
sn = F_ApiGetPropIndex(&openScript, FS_UseAutoSaveFile);
openScript.val[sn].propVal.u.ival = FV_DoNo;
//open the document
docId = F_ApiOpen(tempPath, &openScript, &returnp);
F_ApiDeallocateString(&tempPath);
//we are done with these structures, so deallocate
F_ApiDeallocatePropVals(&openScript);
F_ApiDeallocatePropVals(returnp);
//if something went wrong, ensure the return value is zero
if(!docId) docId = 0;
else if(hidden)
F_ApiSetInt(FV_SessionId, docId, FP_IsOnScreen, False);
return docId;
}
Copy link to clipboard
Copied
Eric,
Re-reading your post, you did not mention specifically that these errors are occurring when you open a file. I hope that is what you were talking about. Some of them (like the graphics one) can occur at other times. I'm not sure what to do in that case.
Russ
Copy link to clipboard
Copied
Hi Russ
Thanks for your reply. The errors do occur when we open a file which is our main concern.
I tried your code sample and it did suppress some of the messages successfully, which is fantastic.
As you said, the error about missing imported graphics seems to be a different kettle of fish.
It's the single most common error message I see when I'm using test files to verify code changes.
As our software is used by translators, we may just have to concede that some messages are
"unsuppressable," and tell them to make sure they have their imported files and graphics set up properly
if they don't want to be inundated with modal dialog boxes every time they use our application in script mode.
If you do figure out how it might be suppressed, I'd love to hear about it. Thanks for your code sample though,
you've been a big help as always ![]()
Eric
Copy link to clipboard
Copied
Hi Eric,
That graphics message does seem to be problematic. I notice that a file will open without error, but the error will surface as soon as the document is scrolled to the point where the graphic is missing. If the graphic is on the first page of the doc, you will get that error upon opening no matter what.
If it is any consolation, it seems to only appear one time per FrameMaker session, no matter how many documents with missing graphics that you open.
If you didn't need to see the graphics, you could always hide them with FP_ViewNoGraphics, then Frame would not care about missing files. You would need to hide the document upon opening (FS_MakeVisible = False), then set FP_ViewNoGraphics, then redisplay the document. I doubt that this is an option for you, though... I imagine that the graphics need to be seen.
If you wanted to be really slick, you could hide the document and the graphics, then sift through each referenced file to see if the file actually exists. If one doesn't, you could replace it with your own "File Not Found" image. This would not be too much coding; however, the sticky part would be to restore all the original paths when the document is saved. I can think of a few ways to do this but maybe that pie is to far in the sky ![]()
Russ
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more