pro idlsav_demo ; demonstrate the use of idlsav files ; create some data arrNumbers = indgen(10) ; create a 10-element integer index array strarrWords = [ 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten' ] ; create a 10-element array of strings dblNumber = 123.456789d ; show structure and contents of each variable print, '======================================' print, 'Set variable values and print contents' print, '======================================' print, 'Structure of arrNumbers variable:' help, arrNumbers, /stru print, ' Contents:' print, arrNumbers, format='(I12)' print, '' print, 'Structure of strarrWords variable:' help, strarrWords, /stru print, ' Contents:' print, strarrWords, format='(A12)' print, '' print, 'Structure of dblNumber variable:' help, dblNumber, /stru print, ' Contents:' print, dblNumber, format='(F12.6)' print, '' print, 'Save contents of variables to an IDLSAV file:' ; save to idlsav file save, arrNumbers, strarrWords, dblNumber, /verbose, description='An IDLSAV example', filename='demo.idlsav' ; reset variables to destroy original values print, '' print, '======================================' print, 'Destroying original values:' print, '======================================' arrNumbers = [0] strarrWords = [ "nothing" ] dblNumber = 0.0d ; print to show current contents of variables print, 'Current contents of variables:' print, 'Structure of arrNumbers variable:' help, arrNumbers, /stru print, ' Contents:' print, arrNumbers, format='(I12)' print, '' print, 'Structure of strarrWords variable:' help, strarrWords, /stru print, ' Contents:' print, strarrWords, format='(A12)' print, '' print, 'Structure of dblNumber variable:' help, dblNumber, /stru print, ' Contents:' print, dblNumber, format='(F12.6)' print, '' ; restore idlsav file and view contents print, '======================================' print, 'Now restore original variables and print contents:' print, '======================================' restore, filename='demo.idlsav', /verbose print, 'Structure of arrNumbers variable:' help, arrNumbers, /stru print, ' Contents:' print, arrNumbers, format='(I12)' print, '' print, 'Structure of strarrWords variable:' help, strarrWords, /stru print, ' Contents:' print, strarrWords, format='(A12)' print, '' print, 'Structure of dblNumber variable:' help, dblNumber, /stru print, ' Contents:' print, dblNumber, format='(F12.6)' print, '' end