Is there an API for determining the size of a routine?

Is there an API I can call to determine the size of a routine in a CACHE.DAT file so that I don't have to directly reference the ^ROUTINE global?

  • 0
  • 0
  • 271
  • 1
  • 3


You can use class %Routine

set rtn=##class(%Routine).%OpenId("hello.mac")
write rtn.Size

Or if you want to display or get that value with a single line of code (assuming you do not care about error handling), then you could do the following:

Write ##class(%Routine).%OpenId("hello.mac").SizeGet()

If you want the sizes of a lot of routines the Studio open dialog query is very handy and you can sort by the routine size too. There is also a routine specific query in %Routine class to, but if you need to see classes, or CSP pages etc then the open dialog query is the best:


d ##class(%ResultSet).RunQuery("%RoutineMgr","StudioOpenDialog","*.*",,,,1)

Also, you can use the built-in %RD routine.  After you enter the routine name or names that you want to see the sizes for, then answer "L" for Long Form at the next prompt.   that will display additional attributes about the specified routines - one of which will be the size in bytes.

Example Output:

                 Long Listing of Selected Routine/Include Files
                              Namespace:  TEST
                         22 Aug 2016  6:14 PM   Page 1

NAME                            .EXT.VER  LANG  DATE/TIME             #BYTES

UTTest                          .MAC            20 May 2016  10:21 am  14252