@Vitaliy Serdtsev

Thank you for the examples. However, replacing a "For" loop isn't quite what I'm looking for.
I'm able to create a simple *.mac routine to achieve the desired functionality, but my issue lies in understanding why the "For" macro fails to compile when used in a .inc file.
What I'm really aiming for is something like Robert's example:
    #define MyLoop(%count) set x="" for i=1:1:%count set x=$order(^%SYS("JOURNAL",x),-1)
(Benjamin's example is more complex, but essentially follows the same idea.)
Also, just to note — I'm encountering a similar issue with IF statements in .inc files. Here's a reference to a related discussion:
https://community.intersystems.com/post/failure-compile-inc-simple-if-st...

Thanks again for your help!

@Benjamin De Boe

Sorry for bothering - I was so exited macro was compiled that didn't check for real life usage. Please, help me find a syntax error in:  #define logDebug(%arr) $SELECT(^GlFSL("Debug")>0:Entry^HS.Local.VA.Util.Log(%arr,,"D"),:QUIT).

FYI, "Direct" macro as: #define logDebug(%arr)     Entry^HS.Local.VA.Util.Log(%arr,,"D") works, but I would like to use "SELECT" (or "IF").  

Thank you 

@Benjamin De Boe
You are right about "mbChuck" initiation for runtime, but the discussion is about compiling macro reference in a class which is way prior runtime.

I need output from macro "For" - so I can't just use "$$$AndBits(^glo1,^glo2)" (or "do $$$AndBits(^glo1,^glo2)"). I am testing compilation and upon finding a right syntax, "For" macro will be extended to return value I am looking for (for example: argument could be an array and output will be comma-separated sting of array values). ObectScript code, to achieve it, is not an issue - I would like to have it as macro in *inc file. So, any ideas how to transform your example into compilable entry? Thank you

@Robert Cemper

I've created separate post for *.inc "If" issue (https://community.intersystems.com/post/failure-compile-inc-simple-if-st...), hoping somebody could bring an idea for resolving the issue. 
If no positive resolution I would try to create WRC ticket based on your note that everything works on your environment.

But getting back to the initial issue regarding "For" loop in *.inc file.
Can you post any example of using "For" loop in a macro?
Thank you.

@Robert Cemper

Re: "If" in *.inc

#define TestIf(%arr) if (%arr 0) QUIT } is already included in ...Utility.inc (which contains hundreds of macros successfully used throughout the application). 

Include (....Utility) is already declared within a ...FSLogging class.

set = $$$TestIf(3) is set within a LogArchive classmethod.  Expected "a" value is 5

And compilation error: 

Where is an issue? Thank you

@Robert Cemper 

I realized that AI-generated answer looked "unreal".

I would like to have *inc file entry to convert an array into a string and string into an array. ObjectScript code to do it is not an issue at all - I just want to have it as a macro in *.inc file. There is a chance I have no enough knowledge regarding  *.inc macros because the simple "if" statement doesn't work as well (error on compiling within a class) like: #define TestIf(%arr)        if (%arr > 0) { QUIT 5 }. What am I missing? Thank you.