After my hard drive crash, I decided that I should really create a way to automatically back up all the code for all of my active projects. So, I’ve added an “exportAllProjects()” method to my “startup projects” class. This method takes my list of active projects, iterates through them, and exports each one to a standard XPO file, in a sub-folder off the My Documents folder.
I’ve created a menu item for this, and attached it to the Development Tools menu. So, now I can backup all the objects in all of my active projects in one fell swoop. It would nice to be able to do this automatically, but I’m not sure I want to start messing around with doing this as a scheduled job just yet.
// https://gist.github.com/andyhuey/5470950 public void exportAllProjects() { // get the project list, and export all projects. Array projects; int i; ProjectNode sharedProjects, privateProjects, projectNode; str myDocsPath, filePath; #WinAPI myDocsPath = WinAPI::getFolderPath(#CSIDL_PERSONAL); myDocsPath += @"\xpo_backup"; // make sure myDocsPath exists. if (!WinAPI::pathExists(myDocsPath)) { WinAPI::createDirectoryPath(myDocsPath); } projects = this.getProjectList(); sharedProjects = Infolog.projectRootNode().AOTfindChild('Shared'); if (!sharedProjects) throw error("Error: cannot located shared project node!" ); privateProjects = Infolog.projectRootNode().AOTfindChild('Private'); if (!privateProjects) throw error("Error: cannot located private project node!" ); for (i= 1; i <= projects.lastIndex(); i++) { // skip any line starting with a semi-colon if (subStr (projects.value(i), 1, 1) == ";" ) continue; projectNode = sharedProjects.AOTfindChild(projects.value(i)); if (!ProjectNode) projectNode = privateProjects.AOTfindChild(projects.value(i)); if (projectNode) { filePath = myDocsPath + @"\" + projects.value(i) + ".xpo" ; projectNode.treeNodeExport(filePath); } else warning(strFmt("Project %1 cannot be found." , projects.value(i))); } }