InterSystems FAQ rubric
You can programmatically retrieve routine dates and sizes using the RoutineList query of the %Library.Routine (or just %Routine) class.
The RoutineList query has an argument, and the routine name to be searched can be specified by prefix match or middle match. (For wildcards, specify * or ?)
In the example below, *.MAC is specified as an argument.
SET tStatement = ##class(%SQL.Statement).%New()
DO tStatement.%PrepareClassQuery("%Routine" , "RoutineList")
SET rs = tStatement.%Execute("*.MAC",,0)
DO rs.%Display()
ObjectScriptObjectScript
In addition to the routine list, you can also get the class definition list.
What about this ?
USER>set r="" for i=1:1:7 set r=$O(^$ROUTINE(r)) quit:r="" write r,! %APILIB %APILOG %APISERV %ASKDIR %ASKSYS %AUDIT %Activate.Enum.0 USER>
https://docs.intersystems.com/iris20223/csp/docbook/Doc.View.cls?KEY=RCOS_sroutine
You can use ^$ROUTINE to return information on the OBJ code version.
while one can list routines of any given code type using the OP's approach.