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
  • For older versions these tools does pretty much the same:

    mibuso.com/dlinfo.asp and mibuso.com/dlinfo.asp

  • Ok, I didn't know these tools. (Even googled for it in advance).

    Thanx for the input!

  • I know this is an old blog, but I've just tested out your v100 Documentation Extractor on a Cronus database.  The application broke when certain of your instructions caused variable lengths to exceed the size limit for the variable.  Since 1024 is the current text length limit, you'd probably need to rethink the way you assemble your output data.

    I really like that EXPORTOBJECT function in 6.0 though.  I used it to write a function to export all objects without worrying about breaking on objects I don't have a license to export.  It's a pretty cool time saver.

Related
Recommended