• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Need to Upgrade My FrameScript

New Here ,
Feb 05, 2020 Feb 05, 2020

Copy link to clipboard

Copied

Hi All,

I have a FrameScript that adds a standard text after body text "This section lists the main changes...", but now that body text is appended with a Note (Note text "Also see the RELEASE_NOTES file in the ARM_CORTEX_A5_TLM2_LT PSP for updates since this document was published") and the script has stopped working. I am not sure how to make this script look for the Note & add the standard lines after Note. Please Help.

Here is the script:

Set vgBookFile = '';


set vgBookFile = args[1];
  //set vgBookFile = 'FastModelfilelist.txt';
   
   if (vgBookFile = '')
      write console 'No books file specified. Exiting.';
      LeaveScript;
   else
      write console args[1] + 'latest';   
   EndIf
      
   vFileList = getFilesFromList{vgBookFile};
 

   Loop InitVal(1) Incr(1) LoopVar(vI) While(vI <=vFileList.count)
      Set vBookInfo = vFileList[vI];

      Set vBookInfo.mustclose = fTestOpen{vBookInfo.path,vBookInfo.book};
      if (vBookInfo.book = NULL)
         write console 'Could not open specified book file: '+vBookInfo.path;
         LeaveScript;
      else
         Loop ForEach(BookComponent) In(vBookInfo.book) LoopVar(gvBookComp)
         Set selectedfile = gvBookComp.name;
         //display selectedfile;
         Set charPos = eStr.FindString{selectedfile, '_rel.fm'};
         If charpos != 0
         //Display 'This is it';
         //Display 'Opening the rel file';
         Open Document File (selectedfile) NewVar(selFile)
         FileIsOldVersion(OK) FontNotFoundInDoc(OK) FontNotFoundInCatalog(OK)
         AlertUserAboutFailure(False) FileIsInUse(ResetLockAndContinue)
         RefFileNotFound(AllowAllRefFilesUnFindable) LanguageNotAvailable(OK)
         FontChangedMetric(OK) ReturnStatus(gvErrorList);  
         
         Loop ForEach(Pgf) In(selFile) LoopVar(oPgf)            
            Set charPos1 = eStr.FindString{oPgf.Text, 'This section lists the main changes and enhancements in this release of'};
            If (charPos1 != 0)
            //Display 'new para';
            //Display oPgf.Text;
            New Paragraph PrevObject(oPgf) PgfFmtName('H3') Text('O-2018.09-SP2-2') NewVar(oPgf1);
            New Paragraph PrevObject(oPgf1) PgfFmtName('Body') Text('There are no changes and enhancements in this release of .') NewVar(oPgf2);
            New TextLoc Object(oPgf2) Offset(ObjEndOffset-2) NewVar(oPgf3);            
            New Variable Format('product') NewVar(oPgf3) TextLoc(oPgf3);
            PopClipboard;
            EndIf          
         EndLoop

         Loop ForEach(Pgf) In(selFile) LoopVar(1Pgf)            
            Set charPos1 = eStr.FindString{1Pgf.Text, 'This section lists compatibility issues that you must take into account in this release of'};
            If (charPos1 != 0)
            //Display 'new para';
            //Display oPgf.Text;
            New Paragraph PrevObject(1Pgf) PgfFmtName('H3') Text('O-2018.09-SP2-2') NewVar(1Pgf1);
            New Paragraph PrevObject(1Pgf1) PgfFmtName('Body') Text('There are no compatibility issues in this release of .') NewVar(1Pgf2);
            New TextLoc Object(1Pgf2) Offset(ObjEndOffset-2) NewVar(1Pgf3);            
            New Variable Format('product') NewVar(1Pgf4) TextLoc(1Pgf3);
            PopClipboard;
            EndIf          
         EndLoop
        
         Loop ForEach(Pgf) In(selFile) LoopVar(2Pgf)            
           Set charPos1 = eStr.FindString{2Pgf.Text, 'If the problem has been assigned a Synopsys ID in the Synopsys defect tracking system, this number is also listed; otherwise, No ID is specified.'};
            If (charPos1 != 0)
            //Display 'new para';
           // Display oPgf.Text;
           New Paragraph PrevObject(2Pgf) PgfFmtName('H3') Text('O-2018.09-SP2-2') NewVar(2Pgf1);
            New Paragraph PrevObject(2Pgf1) PgfFmtName('Body') Text('There are no fixed problems in this release of .') NewVar(2Pgf2);
            New TextLoc Object(2Pgf2) Offset(ObjEndOffset-2) NewVar(2Pgf3);            
            New Variable Format('product') NewVar(2Pgf4) TextLoc(2Pgf3);
            PopClipboard;
               
            endif
            endloop
                   
         Save Document object(selfile);
         Close Document object(selfile) ignoremods;
         
         
      Endif
      EndLoop
      EndIf
      Set vFileList[vI] = vBookInfo;
     Close Document DocObject(vBookInfo.book) IgnoreMods;
   EndLoop
   
  
   Function getFilesFromList Using vFileListName;
   Local vFileList;
   New EVector NewVar(vFileList); 
   Set errorcode = 0;

   // Open the file and test for error...
   Open TextFile File(vFileListName) IOType(ReadOnly) NewVar(vBFile);
   if (vBFile = 0)
      // If the file cannot be opened, it's pretty much game over. 
     // fLog{logBoth, logFatal, 'Error opening list of books '+vFileListName+'.'};
      //fLogClose{};
      LeaveScript;
   EndIf   

   Read File(vBFile) Rewind;

   Set errorcode = 0;
   Read File(vBFile) NewVar(vBLine);
   Loop While (errorcode = 0)
      Get String FromString(vBLine) NewVar(vBLine) 
       RemoveLeading(' ') RemoveTrailing(' ')
      if vBLine.count NOT = 0;
         // Look for comment character
         Get Member Number(1) From(vBLine) NewVar(vBChar);
         if vBChar NOT = '#' 
            Set vBookInfo = eUtl.EStructure{
               'path',vBLine,
               'mustclose',0,
               'book',0
            };
            vFileList.PushBack{vBookInfo};
         EndIf
      EndIf
      Read File(vBFile) NewVar(vBLine);
   EndLoop

   Close TextFile Object(vBFile);
   // Log the success.
   //fLog{logBoth, logNote, 'Successs reading list of books from '+vFileListName+'.'};
   Set Result = vFileList;
 
EndFunction; 
   
   
   
Function fTestOpen Using vTOfilename BYREF vTOhandle;
   Local vTOmustclose(FALSE);
   Run isBookOpenAlready vFilename(vTOfilename) returns theBook(vTOHandle);
   if vTOHandle = 0
      Set vTOmustclose = TRUE;
      Find String('.book') InString(vTOfilename) NoCase ReturnStatus(vTOGotBook);
      Set ErrorCode = 0
      If vTOGotBook = TRUE
         Open Book File(vTOfilename) NewVar(vTOHandle) MakeIconic(True) 
            OpenDocViewOnly(True) AlertUserAboutFailure(FALSE);
      Else
         Open Document File(vTOfilename) NewVar(vTOHandle) MakeIconic(True) 
            OpenDocViewOnly(True) AlertUserAboutFailure(FALSE);
      EndIf
      if ErrorCode NOT = 0
         fLog{logBoth, logWarn, 'Open Failure-'+ErrorCode+' Msg-'+ErrorMsg};
         fLog{logBoth, logWarn, 'Open Messages-'+gvErrorList};
      EndIf

      if vTOHandle = 0
         fLog{logBoth, logWarn, 'The file '+vTOfilename+
           ' could not be opened; check the name and try again.'}
         Set Result = vTOmustclose;
         LeaveScript;
      endif
   Endif
   Set Result = vTOmustclose;
EndFunction // fTestOpen
      
    sub isBookOpenAlready using vFilename theBook
   Get string Fromstring (vFilename) uppercase NewVar(vFilenameUC);  // Upper case the string
   set theBook = 0;
   loop foreach(book) In(session) loopvar(vTestBook)
      get string fromstring (vTestBook.Name) uppercase newvar(vTname); // Upper case the string
      if vTname = vFilenameUC
         set theBook = vTestBook;
         leaveloop;
      endif
   endloop
endsub
 ​

 

TOPICS
Scripting

Views

249

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 06, 2020 Feb 06, 2020

Copy link to clipboard

Copied

LATEST

Hi, You won't likely get help with this because you have posted a large script that processes all of the components in a book and the people on this list don't have your files to test with. In addition, this script is very poorly written. Instead of one long script, you want to separate your code into discrete functions so that you can isolate and test different portions of the script. The best practice is to start with your cursor in a specific location and test the insertion of the text. Once that is working, you can create a function and then expand the script out to process multiple paragraphs, documents, etc., but all in separate functions. I am sorry I can't be more helpful.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines