Question
· 8 hr ago

How can I code "IF Studio"?

Studio's Output window is interactive, and code can ask questions there if it is a Studio environment. How do I check for that?

Product version: Caché 2017.1
Discussion (2)2
Log in or sign up to continue

At least, there are four different ways to get that info

ClassMethod StudioTest()
{
	write "Call from Studio1: ",..InStudio1(),!
	write "Call from Studio2: ",..InStudio2(),!
}

/// Is the invocation from the Studio?
ClassMethod InStudio1()
{
	for i=$st:-1:1 if $st(i,"PLACE")["%Studio.General." ret 1
	ret 0
}

/// Is there a connection to Superserver?
ClassMethod InStudio2()
{
	set port=1972 // see iris.cpf, section [Startup], DefaultPort=...
	quit $p($v(-1,$j),"^",3)[("|TCP|"_port_"|")
}
Compiling routine DC.Util.1
Compilation finished successfully in 0.024s.

do ##class(DC.Util).StudioTest()
Call from Studio1: 1
Call from Studio2: 1


ICINDY:USER>; from PuTTY   -------------------

ICINDY:USER>do ##class(DC.Util).StudioTest()
Call from Studio1: 0
Call from Studio2: 0

 

The other two methods are: checking for the presence of
a) a dedicated variable or
b) a dedicated object
but both require a usage of undocumented functions