Including CLW with MODULE definition inside Global Map throws error

In the documentation it’s said that INCLUDE “specifies source code to be compiled which exists in a separate file which is not a MEMBER module. Starting on the line of the INCLUDE directive, the source file, or the specified section of that file, is compiled as if it appeared in sequence within the source module being compiled”

So I thought I could move my MODULE definition which is inside the Global Map to a separate CLW file and include it, but then I get Expected: <ID> <LINEBREAK> ; END INCLUDE OMIT SECTION COMPILE PRAGMA MODULE

Is this just not supported? Am I doing it wrong?

CODE:

The CLW:

MODULE('')
SLEEP(LONG),PASCAL
END

THe Include:

INCLUDE('Helpers.clw'),ONCE

Hi Dylan

The problem is your spacing in the Helpers.clw. Also Helpers.clw can only contain MODULE definitions unless you use SECTIONS within the file. Take a look at the HELP for that :slight_smile:

If you format it to

  MODULE('')
    SLEEP(LONG),PASCAL
  END

I use two spaces here, but your coding style might be different.

          MAP
include('Helpers.clw'),ONCE
          END

You can put a space before the include or leave it out.

Note: For definitions, I would use .INC rather than .CLW, but obviously that’s just personal choice.

Mark

Thanks that did it - Clarion really needs better error messages related to formatting :rofl:
Just added a single space in front of the MODULE part till END and it compiles - really weird…

Also, note for others - don’t add the helpers.clw to the project as existing file - it will try to compile it - or set the Build action to none

Quick follow up question - The module is used for a DotNet 9 compiled DLL using NativeAOT - but I notice when closing the Application two errors are written to the Event Log of EventID: 1005 with message (translated from Dutch)

First

Toepassingsnaam met fout: Testing.exe, versie: 0.0.0.0, tijdstempel: 0x671b7fba
Naam van foutmodule: ClaRUN.dll, versie: 8.0.0.9759, tijdstempel: 0x50c8a384
Uitzonderingscode: 0xc0000096
Foutoffset: 0x001349e0
Foutproces-id: 0x3E48
Begintijd van foutieve toepassing: 0x1DB26D0C51A8ED3
Faulting-toepassingspad: {PROJECT_DIR}\Testing.exe
Faulting-modulepad: {PROJECT_DIR}\ClaRUN.dll
Rapport-id: 43001c7f-6473-4879-9316-84b0ddde56b7
Faulting-pakket volledige naam: 
Faulting-pakket-relatieve toepassings-id:  

Second

Cannot access file for one of the following reasons: There is a problem with the network connection, with the disk on which the file is stored, with the storage drivers on this computer, or the disk is missing. Program Testing.exe was terminated because of this error.

Program: Testing.exe
File:

The error value is displayed in the Additional Data section.
User Action
1. Reopen the file. This may be a temporary problem that will resolve itself when the program is run again.
2. If the file is still not accessible and
- If the file is on the network, the network administrator should verify that there is no problem with the network and that the connection to the server can be established.
- If the file is on a removable disk, such as a floppy disk or CD-ROM, verify that the disk is properly inserted into the disk drive.
3. Check and repair the file system with CHKDSK. To do this, click Start, Run, and type CMD. Click OK and type CHKDSK /F at the command prompt. Then press ENTER.
4. If the problem persists, restore the file from a backup medium.
5. Determine whether other files on the same disk can be opened. If not, the disk is damaged. If it is a hard disk, contact your network administrator or hardware vendor for assistance.

Additional information
Error value: 0x0
Disk type: 0x0

Any idea why that happens?

Is it because Clarion uses dlclose or freelibrary?

Something to know… in the Clarion language Column 1 is special, it is reserved for declaration labels i.e. Data Procedure Routine e.g.

ValidateRecord ROUTINE  ! starts on column 1
   DATA 
ColumnOneHasLabel   BYTE

You can put a Question Mark (?) in column 1 to indicate that line should only be on Debug Builds.

It’s very hard for compiler writers to take invalid code and decide what you intended and tell you. Seems like AI will help that.

Tip:
If the first of several errors does not make sense, i.e. the code looks fine, proceed to review the other errors or even the last error. Fix that last error and surprise, the first error goes away.

Thanks for the info - really helps!

Do you perhaps know anything of the follow up question?