skip to main content NIST Center for Neutron Research NIST Center for Neutron Research National Institute of Standards and Technology
Home Live Data Instruments CHRNS Proposals

Details of Program CIFEDIT

Program CIFEDIT starts by setting a value for variable CIF(maxvalues). This variable defines the maximum number of data values that the program can process. Note that for this purpose, values inside a loop are counted individually, so that

          loop_   _cif_name   a b c d e 
is counted as five data values. This maximum is defined so that CIFEDIT will not attempt to use more computer memory than is available. The effect of the variable is to terminate parsing of a CIF if it is larger than the selected limit. The value for CIF(maxvalues) in the code as distributed (100,000) is sufficient for CIFs up to perhaps 0.5 Mb, but this value can be increased to allow larger CIFs to be opened on larger computers. A value of 0, or if this value is not specified, turns off the size checking -- effectively an infinite limit. For heavily loaded or smaller computers, it might be desirable to lower this value, if reading in a large CIF causes the computer performance to be seriously degraded. CIFEDIT then continues by requesting the user to supply a file name, unless one is provided on the command line. The location where the cifedit.tcl file is located is then determined, as the BWidget Tcl package is expected to be located as a subdirectory there, also two additional Tcl files, browsecif.tcl and CIF_index are expected in that directory. The browsecif.tcl file is read, the version of Tcl is then checked and the BWidget package is loaded. The CIF_index file is then read and then the dictionary search path variable is updated with likely data directories.

Then the GUI is constructed. A text widget [.t, CIF(txt)] is created in the root window, along with a scroll bar [.s] and a frame for buttons [.f]. A toplevel window [.def, defw] is created with a second text widget [.def.t, CIF(defBox)] to be used to display CIF definitions. A window is created to hold the CIF browser [CIF(browser)] and a series of buttons are placed at the bottom.

The "wm protocol * WM_DELETE_WINDOW" delete commands are used to intercept an attempt to delete any of the windows. In the case of the definitions or CIF contents window, the windows are hidden rather than destroyed. An attempt to delete the browser is interpreted as an attempt to exit and routine ConfirmDestroy is used to see if there are unsaved changes (see CIF(changes) in next paragraph) and if so routine SaveCIFtoFile is used to write the CIF to disk.

The CIF is then read from the file and is parsed in routine ParseCIF. The CIF editor/browser window is populated using the CIFOpenBrowser routine. routine and then the Finally, the contents of the browser window is created using the CIFBrowser routine. Note that these routines are documented more completely in the browsecif.tcl documentation.

Buttons & Associated Routines
The variable CIF(changes) tracks the number of changes made to to the CIF file that are not saved to disk. Every time the variable is changed routine EnableSaveEdits is called to enable the "Save" button [or disable it if CIF(changes) is zero.]

Variable CIF(undolist) holds a list of changes that have been made to the CIF. If the "undo" button is used to reverse these changes, the "undone" changes are copied to the CIF(redolist) variable. Routine EnableUndo is used to disable the Undo and Redo buttons when the appropriate list is empty.

The "Show CIF Definitions" button, invokes routine ShowDefWindow which displays the window and changes the label on the button to "Hide CIF Definitions". Pressing the button again, as well as an attempt to destroy the window invokes the routine again. The "Show CIF Contents" uses routine ShowCIFWindow to show and hide the CIF contents window in a similar fashion.

On the CIF contents window there is a button labeled "Open for Editing". This button calls routine EditCIFBox which opens the CIF to be edited manually and changes the label on the button. It also disables most of the buttons on the browser window so that changes cannot be made in both places at the same time. The browser can still be used to navigate within the CIF file while it is open for editing. When the same button (now labeled "Close Editing") is pressed, the windows are restored to their original configuration and the CIF is parsed using the ParseCIF routine (note that the file name is not supplied as an argument) and then the browser window is regenerated using the CIFBrowser routine.

Comments, corrections or questions:
Last modified 25-July-2003 by website owner: NCNR (attn: Craig Brown) $Revision: 1.1 $ $Date: 2003/01/06 17:16:21 $