Question
· Jun 25, 2018

Help with dynamic Xecute in curly brackets

Typically, I have time to review the documentation, which I'm sure is here. However, I have a workaround (TEST1) but I was wondering if anyone could assist me in advising how I would need to adapt the curly brace snippet (TEST2) to provide the same result.

Thanks for any help you can provide.

 TEST1(STATUS=1) K (STATUS)
 X "S MSG=$S(STATUS:""HELLO"", 1:""GOODBYE"")"
 
 W !,MSG
 Q
 
TEST2(STATUS=1) PUBLIC {
X "S MSG=$S(STATUS:""HELLO"", 1:""GOODBYE"")"

W !,MSG
}
Discussion (3)1
Log in or sign up to continue

Have you considered using $xecute?

Version:1.0 StartHTML:00000092 EndHTML:00001371 StartFragment:00000172 EndFragment:00001337 CachÙ Studio clip   Class User.Exec [ Abstract ]
{

ClassMethod test(STATUS = 1) As %String
{
set greeting = $xecute("(STATUS) { return $S(STATUS:""HELLO"", 1:""GOODBYE"") }",STATUS)
return greeting
}

}

and here is this code in action:

PANTHER:XEP:DEV>w ##class(Exec).test()

HELLO

PANTHER:XEP:DEV>w ##class(Exec).test(0)

GOODBYE