WORKS!!! Thank you very much
- Log in to post comments
WORKS!!! Thank you very much
"Real life" *.inc entry is to execute macro routine "Entry^HS.Local.VA.Util.Log(%arr,,"D")" if Global ^GlFSL("Debug") is >0 by calling from a classmethod as $$$TestIf(arr) - no return value is required.
Initial attempt was by defining in *inc file as:
#define TestIf(%arr) if (^GlFSL("Debug")>0) {Entry^HS.Local.VA.Util.Log(%arr,,"D")}
Note: Without "IF", definition as "#define TestIf(%arr) Entry^HS.Local.VA.Util.Log(%arr,,"D")" works fine
Upon failures, macro was step-by-step simplified trying to figure out compilation issue -so, "set a = $$$TestIf(5)" is just oversimplified line.
Thank you
Real life" code works as well - thank you very much!
if you have time, please, look into similar issue with "IF" in *inc file https://community.intersystems.com/post/failure-compile-inc-simple-if-s…
Don't pay attention on proposed replacement $SELECT option - I really want to have "clean" IF statement in *inc file.
Thank you.
It works! Thank you - let me try to set "real life" code and test.
"Your" definition is NOT in *.inc file!
Upon inserting in *.inc as:
#define MyLoop(%count) set x="" for {i=1:1:%count set x=$order(^%SYS("JOURNAL",x),-1)} QUIT x
And setting in classmethod as:
set x = $$$MyLoop(5)
I got the following compilation error: .png)
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-s…
Thanks again for your help!
"My" syntax above is just one of many tried attempts, including "1:""", "1:$GET(QUIT)" - I didn't want to list all due to error is always the same:
.png)
Thank you.
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
While definition should look like "$select(%arr>2:5,%arr<2:123)" it WORKS! - thank you
I am pretty familiar with using "##continue" in macro definition - there are a lot for other macros with ##continue in "*inc file.
Upon defining the macro per your example the error is:
.png)
Upon deleting line "set mbChunk="" ##continue" (seems like unnecessary) the error is more definitive (pointing to "for" itself"):
.png)
@Robert Cemper
While the definition, IMO, seems valid, I got the error on attempt to compile class with call in it - see below. But the message does not contain annoying "Invalid function" - complain is regarding missing space in definition.
.png)
Of course, statement "set a = $$$TestIf(3)" has space (Tab) prior - otherwise compilation error would be different - related to class - not invalid function "If.."
I've created separate post for *.inc "If" issue (https://community.intersystems.com/post/failure-compile-inc-simple-if-s…), 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.
#define TestIf(%arr) if %arr>0 QUIT 5 - same error, while no "(" in the "Invalid command text in screenshot.
IRIS for Windows (x86-64) 2022.1.2 (Build 574_0_22407U) Wed Apr 5 2023 11:19:54 EDT
InterSystems Studio Client 2022.1.2 Build 574
Server IRIS for Windows (x86-64) 2022.1.2 (Build 574_0_22407U)
@Robert Cemper
Same compilation error for all options below:
#define TestIf(%arr) if (%arr>0) {QUIT 5}
#define TestIf(%arr) if (%arr> 0) {QUIT 5}
#define TestIf(%arr) if (%arr>0) { QUIT 5 }
Re: "If" in *.inc
#define TestIf(%arr) if (%arr > 0) { QUIT 5 } 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 a = $$$TestIf(3) is set within a LogArchive classmethod. Expected "a" value is 5
And compilation error: .png)
Where is an issue? Thank you
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.
I’d specifically like to use a *.inc file to define a for loop—assuming that’s even possible.
Also, is there a way to bypass the AI bot and direct my question exclusively to a human community?
Thank you for the line: #define ForAll(%in, %gn) SET gn%in=$NAME(%gn) SET %in="" FOR { SET %in=$ORDER(@gn%in@(%in)) QUIT:%in="" }
Please, explain what the arguments "%in" and "%gn" mean/define.