Extracting the documentation trigger

It's been a while since my last blog post. The most important reasons were mostly a kitchen rebuild and of course the World Championship Soccer :) But more important, I had not much to tell you guys and girls.

That was until last week, when my colleague Luc asked me if I could extract all the documentation from the documentation triggers in our add-on. Thinking about how to solve this issue without having to open each changed object, I created a processing only report to do the job for me.

In short, I'm using the new EXPORTOBJECTS function that was introduced in NAV 2009 to extract the text in the documentation trigger.

//Extract the object
CLEAR(TemporaryFile);
IF FILE.EXISTS(TemporaryFileName) THEN
  FILE.ERASE(TemporaryFileName);
lRecObject.RESET;  //Using a local rec variable because the EXPORTOBJECTS exports all objects witin the filter
lRecObject.SETRANGE(Type, Object.Type);
lRecObject.SETRANGE("Company Name", Object."Company Name");
lRecObject.SETRANGE(ID, Object.ID);
lRecObject.FINDFIRST;
EXPORTOBJECTS(TemporaryFileName, lRecObject, 0);
FirstLine := TRUE;

//Find the documentation trigger
CLEAR(TemporaryFile);
TemporaryFile.OPEN(TemporaryFileName);
TemporaryFile.WRITEMODE(TRUE);
TemporaryFile.TEXTMODE(TRUE);
REPEAT //Read until you find '  CODE'
  TemporaryFile.READ(BufferText);
UNTIL (BufferText = '  CODE');

REPEAT //Read until you find '    {'
  TemporaryFile.READ(BufferText);
UNTIL (BufferText = '    {') OR EOF;

//Start of documentation
IF NOT EOF THEN
  REPEAT //Read until you find '    }'
    TemporaryFile.READ(BufferText);
    IF NOT EOF THEN
      IF BufferText <> '    }' THEN
      BEGIN
        IF FirstLine THEN
          WriteObjectStart(Object);
          FirstLine := FALSE;
          WriteDocumentationLine(BufferText);
        END;
  UNTIL (BufferText = '    }') OR EOF;

IF NOT EOF THEN
  WriteObjectEnd;
TemporaryFile.CLOSE;

 You can download the complete tool here.

If you have any suggestions, please let me know!

Comment List
Anonymous
Related
Recommended