Question
· Dec 28, 2016

How do I create a List of a subset of routines from the ^$ROUTINE global?

I want to generate a list object of routines from the ^$ROUTINE global without directly reading the [^$ROUTINE] global.


E.G. I want to create an array/variable/object with names of all routines that start with "ABC" so that an application process can use each routine name as input for a subsequent process.

Discussion (3)0
Log in or sign up to continue

Is there any specific reason for not wanting to use the RoutineList() query from the %Library.Routine class?

query RoutineList(spec As %String(MAXLEN=512), dir As %Integer, type As %Integer, nsp As %String)

    This query provides a list of all routines that match the pattern specified by spec.

    spec may contain both * and ? as wildcards. It may also consist of more than one, comma-delimited selections. For example:
    "*.MAC"
    "A*.MAC"
    "A?.MAC"
    "A*.MAC,B*.MAC"
    dir specifies the direction to search in, 1 is forwards and -1 is backwards.
    type is 1 to include OBJ files in the search and the default, 0 will just include INT, MAC, INC, BAS.
    nsp is the namespace to list from. If omitted, the query returns the routines from the current namespace. nsp can be either an explicit or an implied namespace. 
 

Your request could then be implemented with a simple call like:

 s tRS=##class(%ResultSet).%New("%Routine:RoutineList")
 d tRS.Execute("ABC*.INT")
 f  q:'tRS.Next()  s routName=tRS.GetData(1) w "Found ",routName,!