go to post Michael Akselrod · 13 hr ago 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-st... Don't pay attention on proposed replacement $SELECT option - I really want to have "clean" IF statement in *inc file. Thank you.
go to post Michael Akselrod · 14 hr ago It works! Thank you - let me try to set "real life" code and test.
go to post Michael Akselrod · 15 hr ago "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 xAnd setting in classmethod as: set x = $$$MyLoop(5)I got the following compilation error:
go to post Michael Akselrod · 16 hr ago @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!
go to post Michael Akselrod · 17 hr ago @Robert Cemper "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: Thank you.
go to post Michael Akselrod · Oct 29 @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
go to post Michael Akselrod · Oct 29 @Benjamin De BoeYou 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
go to post Michael Akselrod · Oct 29 While definition should look like " $select(%arr>2:5,%arr<2:123)" it WORKS! - thank you
go to post Michael Akselrod · Oct 29 @Benjamin De Boe 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: Upon deleting line "set mbChunk="" ##continue" (seems like unnecessary) the error is more definitive (pointing to "for" itself"):
go to post Michael Akselrod · Oct 29 @Robert CemperWhile 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.
go to post Michael Akselrod · Oct 29 Of course, statement "set a = $$$TestIf(3)" has space (Tab) prior - otherwise compilation error would be different - related to class - not invalid function "If.."
go to post Michael Akselrod · Oct 29 @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.
go to post Michael Akselrod · Oct 28 @Robert Cemper #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 574Server IRIS for Windows (x86-64) 2022.1.2 (Build 574_0_22407U)
go to post Michael Akselrod · Oct 28 @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 }
go to post Michael Akselrod · Oct 28 @Robert Cemper 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: Where is an issue? Thank you
go to post Michael Akselrod · Oct 28 @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.
go to post Michael Akselrod · Oct 28 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?
go to post Michael Akselrod · Oct 28 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.