Loading ...
Sorry, an error occurred while loading the content.

Re: Still Stuck, file split on the basis of format and marker

Expand Messages
  • jang
    Hello Maninder, From what you are writing about splitting the file and using DITA markers, I assume you are preparing to move unstructured content into (DITA)
    Message 1 of 3 , Mar 16, 2012
    View Source
    • 0 Attachment
      Hello Maninder,

      From what you are writing about splitting the file and using DITA markers, I assume you are preparing to move unstructured content into (DITA) structured content. I would suggest first converting the materials to structured FM and then do the splitting - possibly using the FrameSLT plug-in from WestStreet consulting. This would remove a lot of hassle searching markers in unstructured content and would probably be a safer method. I have just finished a big project doing this type of conversion - for very large books with lots of paragraph formats and conditional texts. Without moving to structured FM first, you have a very limited set of functions available in FM - or in FrameScript - to help you. And the structured content does not have to be valid against your (DITA ?) EDD to be able to process it with tools like FrameSLT.

      Good luck

      Jang



      --- In framescript-users@yahoogroups.com, "singh13_maninder" <singh13_maninder@...> wrote:
      >
      > Hi,
      >
      > I am stuck at this script. I am trying to split a file on the basis of paragraph format heading (Head1) and marker of type DITA. I am not able to iterate through the whole document and getting stuck at the first H1 heading. In simple words, I am not able to iterate and process the next H1 Heading. The script keeps on processing the same paragraphs.
      >
      > Appreciate inputs. Here is the script:
      >
      > IF ActiveDoc = 0
      > MSGBOX 'No Active Document';
      > LEAVESUB;
      > ENDIF
      > SET out = 0;
      > SET CMDcount = 0;
      > SET str = ' ';
      > SET SRCDoc = ActiveDoc;
      >
      >
      > //Set the loop var to the first para in the flow
      > SET PGFVar = SRCDoc.mainFlowInDoc.FirstPgfInFlow;
      > SET i = 0;
      >
      >
      > //Loop until the loop variable is nothing (e.g., the last paragraph)
      > LOOP UNTIL(PGFVar = 0)
      > //Find the first instance of 1H_Head
      > if out = 1
      > SET PGFVar = PGFVar.NextPgfInFlow;
      > else
      > endif
      >
      > LOOP UNTIL(PGFVar.Name = '1H_Head1')
      > // Set the current paragraph containing the insertion point
      >
      > Set PGFVar = Textselection.Begin.Object;
      > // Get a textlist of marker anchors
      > Get Textlist Inobject(PGFVar) Newvar(vTlist) Markeranchor;
      > // Loop within the textlist
      > display 'vTlist.Count :-' + vTlist.Count;
      > //display i;
      > Loop While(i <= vTlist.Count) LoopVar(i) Init(1) Incr(1)
      > //New Paragraph PrevObject(PGFVar) NewVar(PGFVar);
      > Get Member Number(i) From(vTlist) NewVar(vMarker);
      > Set vMarker = vMarker.TextData;
      > //display vMarker.TextData;
      > //display vMarker.MarkerText;
      > display vMarker.MarkerTypeId.Name;
      >
      >
      > If vMarker.MarkerText = 'concept'
      > //display vMarker.MarkerText;
      > set str = 'c_';
      > set out = 1;
      > leaveloop;
      >
      > elseif vMarker.MarkerText = 'topic'
      > set str = 't_';
      > set out = 1;
      > //display vMarker.MarkerText;
      > leaveloop;
      > elseif vMarker.MarkerText = 'task'
      > set str = 'tk_';
      > set out = 1;
      > leaveloop;
      > elseif vMarker.MarkerText = 'reference'
      > set str = 'r_';
      > set out = 1;
      > leaveloop;
      > else
      > endif
      > ENDLOOP
      >
      > SET PGFStart = PGFVar;
      > SET PGFVar = PGFVar.NextPgfInFlow;
      > //else
      > //endif
      > //Loop until you find the next 1H_Head..
      > LOOP UNTIL (PGFVar.Name = '1H_Head1');
      > //...Or until you reach the last paragraph in the document
      >
      > IF PGFVar.NextPgfInFlow = 0
      > LEAVELOOP;
      > ELSE
      > SET PGFVar = PGFVar.NextPgfInFlow;
      > ENDIF
      > ENDLOOP
      >
      > //SET PGFVar = PGFVar.NextPgfInFlow;
      >
      > IF PGFVar.Name = '1H_Head1'
      > NEW TextRange NEWVAR(TRCmd) Object(PGFStart) Object(PGFVar);
      > ELSE
      > //Otherwise it is the last paragraph in the document, so you have to extend the range to encompass
      > //the full offset using objEndOffset.
      > NEW TextRange NEWVAR(TRCmd) Object(PGFStart) Object(PGFVar) Offset(objEndOffset);
      > ENDIF
      >
      > // Replace spaces with underscores
      > Get String FromString(PGFStart.Text) NewVar(CMDFileName)
      > ReplaceAll(' ') With('_');
      > display CMDFileName.Text;
      >
      > //display str;
      > set CMDFileName = str + CMDFileName;
      > //display CMDFileName.Text;
      > //Select the text
      > SET SRCDoc.TextSelection = TRCmd;
      >
      > //Copy the selected text to the clipboard
      > COPY TEXT DocObject(SRCDoc);
      >
      > //Create a new document. Note that the MakeVisible(False) option might seem like a good idea here
      > //but for some reason the PASTE TEXT command doesn't work with documents opened as invisible
      >
      > // For example: C:\Data\FrameScript\Wip\Deconstruct
      >
      > NEW Document Template('C:\Data\FrameScript\Wip\IOS_SAWG_MasterTemplate_Config.fm') NEWVAR(CMDDoc) RefFileNotFound(AllowAllRefFilesUnFindable);
      > // For example: C:\Data\FrameScript\Wip\
      >
      > //Paste the text into the new document
      > PASTE TEXT DocObject(CMDDoc);
      > //Save it.
      > //display str;
      > SAVE DOCUMENT DocObject(CMDDoc) File('C:\Data\FrameScript\Wip\SBC_Command_Files\' + CMDFileName + '.fm');
      >
      > WRITE CONSOLE 'Wrote command ' + CMDFileName + ' to file C:\Data\FrameScript\Wip\Deconstruct\' + CMDFileName + '.fm';
      > // For example: C:\Data\FrameScript\Wip\Deconstruct\
      >
      > //increment the counter of files successfully saved
      > SET CMDCount = CMDCount + 1;
      >
      > //Close the document and move on
      > CLOSE DOCUMENT DocObject(CMDDoc);
      > //
      > ENDLOOP
      > SET PGFVar = PGFVar.NextPgfInFlow;
      >
      > IF PGFVar.NextPgfInFlow = 0
      > MSGBOX 'All Done! ' + CMDCount + ' CmdRef files created!';
      > LEAVELOOP;
      > ELSE
      > ENDIF
      > ENDLOOP
      >
      >
      > ***************
      >
      > Thanks & regards,
      > Maninder
      >
    • maninder singh
      Thanks jang. ________________________________ From: jang To: framescript-users@yahoogroups.com Sent: Friday, 16 March 2012 6:45 PM Subject:
      Message 2 of 3 , Mar 16, 2012
      View Source
      • 0 Attachment
        Thanks jang.


        From: jang <jang@...>
        To: framescript-users@yahoogroups.com
        Sent: Friday, 16 March 2012 6:45 PM
        Subject: [framescript-users] Re: Still Stuck, file split on the basis of format and marker

         
        Hello Maninder,

        From what you are writing about splitting the file and using DITA markers, I assume you are preparing to move unstructured content into (DITA) structured content. I would suggest first converting the materials to structured FM and then do the splitting - possibly using the FrameSLT plug-in from WestStreet consulting. This would remove a lot of hassle searching markers in unstructured content and would probably be a safer method. I have just finished a big project doing this type of conversion - for very large books with lots of paragraph formats and conditional texts. Without moving to structured FM first, you have a very limited set of functions available in FM - or in FrameScript - to help you. And the structured content does not have to be valid against your (DITA ?) EDD to be able to process it with tools like FrameSLT.

        Good luck

        Jang



        --- In framescript-users@yahoogroups.com, "singh13_maninder" <singh13_maninder@...> wrote:
        >
        > Hi,
        >
        > I am stuck at this script. I am trying to split a file on the basis of paragraph format heading (Head1) and marker of type DITA. I am not able to iterate through the whole document and getting stuck at the first H1 heading. In simple words, I am not able to iterate and process the next H1 Heading. The script keeps on processing the same paragraphs.
        >
        > Appreciate inputs. Here is the script:
        >
        > IF ActiveDoc = 0
        > MSGBOX 'No Active Document';
        > LEAVESUB;
        > ENDIF
        > SET out = 0;
        > SET CMDcount = 0;
        > SET str = ' ';
        > SET SRCDoc = ActiveDoc;
        >
        >
        > //Set the loop var to the first para in the flow
        > SET PGFVar = SRCDoc.mainFlowInDoc.FirstPgfInFlow;
        > SET i = 0;
        >
        >
        > //Loop until the loop variable is nothing (e.g., the last paragraph)
        > LOOP UNTIL(PGFVar = 0)
        > //Find the first instance of 1H_Head
        > if out = 1
        > SET PGFVar = PGFVar.NextPgfInFlow;
        > else
        > endif
        >
        > LOOP UNTIL(PGFVar.Name = '1H_Head1')
        > // Set the current paragraph containing the insertion point
        >
        > Set PGFVar = Textselection.Begin.Object;
        > // Get a textlist of marker anchors
        > Get Textlist Inobject(PGFVar) Newvar(vTlist) Markeranchor;
        > // Loop within the textlist
        > display 'vTlist.Count :-' + vTlist.Count;
        > //display i;
        > Loop While(i <= vTlist.Count) LoopVar(i) Init(1) Incr(1)
        > //New Paragraph PrevObject(PGFVar) NewVar(PGFVar);
        > Get Member Number(i) From(vTlist) NewVar(vMarker);
        > Set vMarker = vMarker.TextData;
        > //display vMarker.TextData;
        > //display vMarker.MarkerText;
        > display vMarker.MarkerTypeId.Name;
        >
        >
        > If vMarker.MarkerText = 'concept'
        > //display vMarker.MarkerText;
        > set str = 'c_';
        > set out = 1;
        > leaveloop;
        >
        > elseif vMarker.MarkerText = 'topic'
        > set str = 't_';
        > set out = 1;
        > //display vMarker.MarkerText;
        > leaveloop;
        > elseif vMarker.MarkerText = 'task'
        > set str = 'tk_';
        > set out = 1;
        > leaveloop;
        > elseif vMarker.MarkerText = 'reference'
        > set str = 'r_';
        > set out = 1;
        > leaveloop;
        > else
        > endif
        > ENDLOOP
        >
        > SET PGFStart = PGFVar;
        > SET PGFVar = PGFVar.NextPgfInFlow;
        > //else
        > //endif
        > //Loop until you find the next 1H_Head..
        > LOOP UNTIL (PGFVar.Name = '1H_Head1');
        > //...Or until you reach the last paragraph in the document
        >
        > IF PGFVar.NextPgfInFlow = 0
        > LEAVELOOP;
        > ELSE
        > SET PGFVar = PGFVar.NextPgfInFlow;
        > ENDIF
        > ENDLOOP
        >
        > //SET PGFVar = PGFVar.NextPgfInFlow;
        >
        > IF PGFVar.Name = '1H_Head1'
        > NEW TextRange NEWVAR(TRCmd) Object(PGFStart) Object(PGFVar);
        > ELSE
        > //Otherwise it is the last paragraph in the document, so you have to extend the range to encompass
        > //the full offset using objEndOffset.
        > NEW TextRange NEWVAR(TRCmd) Object(PGFStart) Object(PGFVar) Offset(objEndOffset);
        > ENDIF
        >
        > // Replace spaces with underscores
        > Get String FromString(PGFStart.Text) NewVar(CMDFileName)
        > ReplaceAll(' ') With('_');
        > display CMDFileName.Text;
        >
        > //display str;
        > set CMDFileName = str + CMDFileName;
        > //display CMDFileName.Text;
        > //Select the text
        > SET SRCDoc.TextSelection = TRCmd;
        >
        > //Copy the selected text to the clipboard
        > COPY TEXT DocObject(SRCDoc);
        >
        > //Create a new document. Note that the MakeVisible(False) option might seem like a good idea here
        > //but for some reason the PASTE TEXT command doesn't work with documents opened as invisible
        >
        > // For example: C:\Data\FrameScript\Wip\Deconstruct
        >
        > NEW Document Template('C:\Data\FrameScript\Wip\IOS_SAWG_MasterTemplate_Config.fm') NEWVAR(CMDDoc) RefFileNotFound(AllowAllRefFilesUnFindable);
        > // For example: C:\Data\FrameScript\Wip\
        >
        > //Paste the text into the new document
        > PASTE TEXT DocObject(CMDDoc);
        > //Save it.
        > //display str;
        > SAVE DOCUMENT DocObject(CMDDoc) File('C:\Data\FrameScript\Wip\SBC_Command_Files\' + CMDFileName + '.fm');
        >
        > WRITE CONSOLE 'Wrote command ' + CMDFileName + ' to file C:\Data\FrameScript\Wip\Deconstruct\' + CMDFileName + '.fm';
        > // For example: C:\Data\FrameScript\Wip\Deconstruct\
        >
        > //increment the counter of files successfully saved
        > SET CMDCount = CMDCount + 1;
        >
        > //Close the document and move on
        > CLOSE DOCUMENT DocObject(CMDDoc);
        > //
        > ENDLOOP
        > SET PGFVar = PGFVar.NextPgfInFlow;
        >
        > IF PGFVar.NextPgfInFlow = 0
        > MSGBOX 'All Done! ' + CMDCount + ' CmdRef files created!';
        > LEAVELOOP;
        > ELSE
        > ENDIF
        > ENDLOOP
        >
        >
        > ***************
        >
        > Thanks & regards,
        > Maninder
        >


      Your message has been successfully submitted and would be delivered to recipients shortly.