Skip to main content
Known Participant
December 17, 2009
Question

Suppressing warning messages

  • December 17, 2009
  • 1 reply
  • 831 views

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

    This topic has been closed for replies.

    1 reply

    Legend
    December 17, 2009

    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;
    }

    Legend
    December 17, 2009

    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

    eric247Author
    Known Participant
    December 18, 2009

    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