Support

Saving files to different directories using the save() command

Written by Admin | Aug 30, 2021 4:00:00 AM

Question

I am attempting to use the save() command in a CCL routine to save the current lens. I want to save the lens to a particular directory, but I am having trouble specifying that directory using the "directory_name" parameter. What is the problem?

Synopsis

Saving files to different directories using the save() command

Symptoms

Perhaps the best way to approach this problem is by way of example: Let's assume that your current directory is the ".../private/len" directory, and you want to save a lens file to a sub-directory that is down two levels: ".../private/len/ProjectX/phase1". If you use the command syntax
  save(len,cur,projectX/phase1,test_lens);
you will find this does not work.

Solution

The reason the syntax described above does not work is that you can only specify one level of sub-directory in the "directory_name" parameter. In the example described above, this would mean that only the single level sub-directory "ProjectX" can be specified in the "directory_name" parameter. However, the remaining path definition can be appended to the front of the "file_name" parameter. This means that the correct syntax for the above example would be: save(len,cur,projectX,phase1/test_lens); NOTE: The current directory is saved as a read-only OSLO preference named current_directory (cdir). You can view the status of this preference by issuing the command: show_preference current_directory;or shp cdir; on the command line. It is important to realize that the value of the current_directory preference can change by the actions of the user, and this leaves a CCL programmer in an awkward position where he/she cannot rely on the value of the current_directory parameter when saving a file. It might be better to reference the private directory when creating the syntax to save a file. The command syntax for this above example using approach would be: save(len,pri,len,projectX/phase1/test_lens);