Question about INCLUDE statement

Hello,

Since I am new to Clarion, I want to ask community for a little help. I am having trouble understanding how INCLUDE works in Clarion. I assume that .INC file is something like .H file in C++, and .CLW file is something like .CPP file?

Clarion help does not say much. I have created test project just to test INCLUDE with my file, but I get compile error. I have tried to look code in LibSrc\win directory as an example, but I am not able to figure it out.

I create TestFile.INC and code in it:

OMIT('_EndOfInclude_',_TestFilePresent_)
_TestFilePresent_     EQUATE(1)

someString     STRING(8)

 MAP
  MODULE('TestFile.clw')
   someProcedure     PROCEDURE()
  END
 END

_EndOfInclude_

And in a TestFile.CLW I have wrote:

MEMBER()
INCLUDE('TestFile.inc')

MODULE
END

someProcedure     PROCEDURE()
CODE
 MESSAGE('Test')
RETURN

In test application in Global Embeds, section Before Global INCLUDEs I put include:

INCLUDE('TestFile.inc')

I get compiler error for .INC file, and it is:

Expected: ( , * ;

In line where is the procedure:

someProcedure     PROCEDURE()

I am not getting compile error when it is only variable in INC file. If I put QUEUE, I get error Illegal data type. I have not tried with class, since I am trying to get it to work with procedure first.

Can anyone explain hot does INCLUDE() work? I would be very grateful. I tried to google it, but I could not find anything.

Seems your mistake is MODULE/END in TestFile.CLW. MODULE must be declared inside MAP structure.

Take out this of your testfile.clw and I think it should be ok

This syntax is “archaic” and is no longer required. Instead use the ,ONCE attribute on your include statement. as in…

Example CBWndPreview.inc:

OMIT('_EndOfInclude_',_IFDef_CBWndPreview_)
_IFDef_CBWndPreview_  EQUATE(1)

One feature that offers is you can use the _Symbol_ in your own code. If the Include is commented out then the Symbol does not exist and any COMPILE(’**’,_Symbol_) does not Include the code. That’s unusual to Not always want a class. I have test / debug helpers like BingBangTheory and WndPreview that I want out of the build once the code is good.

  INCLUDE('CBWndPreview.INC'),ONCE   !Simply !comment this line to remove all code
    COMPILE('!** WndPrv **',_IFDef_CBWndPreview_)
WndPrvCls   CBWndPreviewClass
   '!** WndPrv **
...
    OPEN(Window)
    COMPILE('!** WndPrv **',_IFDef_CBWndPreview_)
    WndPrvCls.Init()
   '!** WndPrv **

That is a bit tricky to rely on that “hidden” _Symbol_ so I only do it with my own classes. Typically I declare my own equate e.g. I wanted to optionally include Geoff’s ST code:

!2 steps to use StringTheory: 1. Change _Have_ to (1), 2. Uncomment INCLUDE(..._ST')
_Have_StringTheory_   EQUATE(1)             !1. Set as (1) = Have StringTheory 
  INCLUDE('FindCleanCwIDE_ST.clw','GLOBAL') !2. Uncomment ! Include(StringTheory

  COMPILE('!**END ST Clean**', _Have_StringTheory_)
      CleanOk = ST_CleanClaPropXmlFile(CleanQ.PathBS & ClarionProperties_xml , pQuery, |
                                          ClnStats, CleanQ.CleanMsg)  
  !end COMPILE('!**END ST Clean**'

It is impressive how little ST code it took GR to shrink the FindPatterns.

It works with CLASS definition, CLARION is very confusing…

So, INC file is:

OMIT('_EndOfInclude_',_TestFilePresent_)
_TestFilePresent_     EQUATE(1)

MAP
END
 
 someClass CLASS,MODULE('TestFile.clw'),LINK('TestFile.clw',_ABCLinkMode_)
 someProcedure PROCEDURE()
 END

 _EndOfInclude_

The .CLW file:

 MEMBER()

  INCLUDE('TestFile.inc')

  someClass.someProcedure PROCEDURE()
  CODE
   MESSAGE('Test')
   RETURN