Question
· Feb 3

Load ObjectScript external file and run code

Hi,

I have Objectscript routine stored in an external Linux file which I've called /my/home/DisplayDB.int

This file does not include any Class definitions and is simply a set a Object script routines. I think this is called INT objectscript

The file looks like this:

set db=##class(Config.Databases).DatabasesByServer("",.dbList)
for i=1:1:$LENGTH(dbList,",") {
  set dbName= $PIECE(dbList,",",i)
  write dbName,!
}

How do I load and compile the Objectscript code?
Do $system.OBJ.Load("/my/home/DisplayDB.int", "ck")

How would I run the code?
do ^DisplayDB

Thanks in advance for any help

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

Your file format doesn't fit, but you are close.
UDL Header is missing, also leading blanks in the lines as you have no labels.
And you have to switch to namespace %SYS and back to make it work.

ROUTINE DisplayDB[Type=INT]
 new $namespace
 zn "%SYS"
 set db=##class(Config.Databases).DatabasesByServer("",.dbList)
 for i=1:1:$LENGTH(dbList,",") {
   set dbName= $PIECE(dbList,",",i)
   write dbName,!
 }
 quit