· May 25 2m read

API to import/export routines

This is an article on the InterSystems FAQ site.

 1. Export API

a. Use $system.OBJ.Export() to specify individual routines to export. For example:

do $system.OBJ.Export("TEST1.mac,TEST2.mac","c:\temp\routines.xml",,.errors)

The format to specify is routine name.extension, and the extension is mac, bas, int, inc, obj.

Errors during export are stored in errors.

See the class reference %SYSTEM.OBJ for details on $system.OBJ.Export().

b. Use $system.OBJ.Export() even when exporting with wildcards. For example:

do $system.OBJ.Export("*.mac",c:\temp\allmacroutines.xml")

*Before version 2008.1, use $system.OBJ.ExportPattern().

2. Import API

a. Use $system.OBJ.Load() to import all routines contained in the file. For example:

do $system.OBJ.Load("c:\temp\routines.xml",,.errors)

b. Import only some of the routines contained in the file

If you want to select and import only some of the routines included in the XML file, set the 5th argument listonly to 1 once to load the XML file with $system.OBJ.Load(), and set the 4th argument (output argument ) to select the import target from the list obtained and specify it with the 6th argument. For example:

 Set file="c:\temp\routines.xml"
 // First get the list of items contained in the XML
 Do $system.OBJ.Load(file,,.errors,.list,1 /* listonly */)
 Set item=$Order(list(""))
 Kill loaditem
 While item'="" {
     If item["Sample" Set loaditem(item)="" {    // Import only those containing Sample
         Set item=$Order(list(item))
 // Execute import process with created list
 Do $system.OBJ.Load(file,,.errors,,,.loaditem)
Discussion (1)2
Log in or sign up to continue