Call csession to execute the method and output results

csession can be called with a variety of arguments:

  • tag+offset^routine
  • tag^routine([parameter-list])
  • ##CLASS(package.class).method([parameter-list])

For example I can call:

csession cache "##class(%SYSTEM.OBJ).ShowFlags()"

And that's the output I get because ShowFlags method writes to the current device:

    b - Include sub classes.
    c - Compile. Compile the class definition(s) after loading.
    d - Display. This flag is set by default.
    e - Delete extent.
    h - Generate help.
    i - Validate XML export format against schema on Load.
    k - Keep source.  When this flag is set, source code of
        generated routines will be kept.
    l - Lock classes while compiling.  This flag is set by default.
    p - Percent.  Include classes with names of the form %*.
    r - Recursive.  Compile all the classes that are dependency predecessors.
    s - Process system messages or application messages.
    u - Update only.  Skip compilation of classes that are already up-to-date.
    y - Include classes that are related to the current class in the way that
        they either reference to or are referenced by the current class in SQL usage.

The problem I have is when the method does not write to the current device, but rather returns a value. If I call it nothing is returned:

csession cache "##class(%SYSTEM.Version).GetVersion()"

Is there a way to call these methods and get their result written to the device?

  • 0
  • 49
  • 2
  • 1


What about a helper classmethod if the expected result is a string

Classmethod DumpHelper(call as %String ) {

   write @call,!


That would work, but I'm looking for a solution without user code.

Some system OutputToDevice method.

It seems that you are to write a couple of lines anyway, because nobody will do it but yourself. As you certainly know, it's possible to do it using shell scripting without going inside Caché, e.g.: 

csession cacheuc1 << EOF
write ##class(%SYSTEM.Version).GetVersion(),!