How to export the whole project

How would I export the WHOLE PROJECT rather than just a single class file out to an XML file?


I would like to, on every file change export the whole project to XML


Thanks for your time

  • 0
  • 300
  • 11
  • 3


You can use $System.OBJ.Export() for it.

For every project where I need it I have a project cheatsheet file, where I have:

s list="MyPackage*.INC,MyPackage*.CLS,Folder*.DFI"
D $System.OBJ.Export(list,"release"_$tr($zd($h,3),"-","")_".xml")

So when I need to export the whole project into importable xml file I call these two lines in terminal.


What about if I want to export the ROUTINES which are INT files

my supervisor said something about 


and it worked but it's not XML ;,(


i guess im really having issues with understanding what exactly a "package" is

Just add *.INT into the list var:

s list="MyPackage*.INC,MyPackage*.CLS,Folder*.DFI,*.INT"

Coty, judging by the update you made here (where you originally raised this question as a comment one another post), for you the term "whole project" means "everything in a namespace". You have discovered that SET sc= $SYSTEM.OBJ.ExportAllClasses(filename) does what you want.

For many of us the word "project" refers to a Studio feature that allows us to group a subset of a namespace's code.

Studio projects can be manipulated programmatically using the %Studio.Project class.

Wow, that's so much for your answer. Very informative that I needed to know


now what I need to do is export the INT ROUTINES that we also have

I would like to, on every file change export the whole project to XML

What do you want to achieve with that?

Custom git tool for GitHub. 

Ive read the documentation on the source control hooks, but I'm more interested in exporting all files from the database into typical file system files that I can have my way with in perl since I use that language often for working with files


For now I don't want to implement the check in and checkout for single files at a time. This is a startup so I'm trying to get everything stable first

There is a GitHub Studio Hook already built out there in the wild. I wouldn't rewrite another one if I were you...

On the other hand, I wouldn't use this hook exactly because it generates XML exports of our files and I hate seeing my source code as XML on GitHub.

Instead, I would use Atelier with EGit plugin connected to my local Caché server. If you don't like Atelier, you can still use Studio if you want to. You will spend most of your time working with Studio on your local machine. When you are ready to commit your work to GitHub, you can open Atelier, synchronize your source code (what will export each class/routine to plain text files with your plain source code instead of XML) and commit the changes to GitHub.

It's like using Atelier as you would use Tortoise, except that Tortoise won't connect to Caché and export all/import all your source code for you like Atelier does... ;)

I like Atelier. I am used to it. Try it and maybe you will like it too. I can't wait to see the new release of it! Good luck!


I already wrote the perl script to do if. It's like 30 lines of code. I was using it because I was exporting the whole project with csp files and int files. 

Literally the only thing I have left to finish is the export like done with studio GUI but have it done programmatically. 

I saw in the documentation you can use studio from the windows command line but I couldn't find/figure out how to have it export the whole project through an argument.


thanks so much for your reply! I will look into everything you mentioned!

For the case of Github, I think one file per one program/class would be the better approach.

You can use Atelier, like [@Amir Samary] mentioned. And in case you have no Atelier I can recommend also this very simple util: cache-udl

Setup the folder with:

d ##class(sc.code).workdir("your/workdir")

And export everything in a namespace with:

d ##class(sc.code).export()

For import use:

d ##class(sc.code).import()

to import all, or:

d ##class(sc.code).importUpdated()

for the recently updated files.

And yes, it exports in UDL. I think for Github UDL is more suitable. 

May I ask you, why do you need XML for your code files?




We have like 5 different applications/webapps all part of this one project and so I need to grab only the files that start with MARS*.csp and not the whole project

Also I do not feel comfortable bringing other dependencies in to deal with this issue since this is dealing with our database too

I've gotten everything to work for what I needed (so thank you so much so far for your help), but one problem I'm having is getting the 'clean' .csp code exported (not the compiled .csp code that is put into a routine).

For instance I would like to export the following MARS*.csp files you see under the csp/cah folder on the screenshot and cannot do that (much like clicking Tools -> Export... -> Okay exports the files that are shown in the workspace pane) ; I'm having to export the compiled code for the .csp files for now.

Any idea on a low level command to export that particular file would be a lot of help so I can finish this puzzle.


I tried to create a class and inherit from %Studio.Project, but it wouldn't compile. Maybe because I need to somehow import that class in, but I am stuck.

If you want to work on a project basis and versionate it, but still want to work with Studio, you can try using Port to test if it satisfies you. By default Port will export your project using UDL format and also a XML for backward compability.


If you want to export only files that ends with .csp, you can save your current project with another name and use the Remove classes, Remove routines. From the Source Control menu. Remember though, that Port is made to be ran locally instead of making your pc work like a thin client for Caché. That means your Source code should preferably be local and not remote.

Also, you're welcome to open issues. And, even though there's an alert about the nightly branch is pretty stable for now, since I have been working mostly on adding unit tests and fixing minor bugs.

P.S: Just to take a note. The Port repository is exported using itself.

Why do you want CSP files to be exported? Why not take them from /csp/ folder as files and put directly to the repo as is?

I see what you're saying. After I posted the question, actually that's what I ended up resorting to yesterday but Im having to guess on which files are actually in the project because I don't know for sure because It's not ALL of the files in the directory, I still would like to do that however or at least have a list generated of what files are in this studio project so I can know

but to answer you this would be because  not all of the files that we use on the server are necessarily part of the project and we always keep Studio's project with all of the files needed for production. Like if we create a new file that will be used for production we then immediately add it to the project. I cant remember exactly but its like tools -> Add -> [file menu comes up] and here you select the file.

Anyways,  this list or export of these items (either one) is really what Im after so I can have that compatability of the studios project items file structure in my git repo without all of the other items that arent meant for production


Hopefully that makes sense