Stein Vidar Hagfors Haugan wrote:
> Probably the best thing to start with is the JOURNAL
> command. The system variable !JOURNAL is set to the
I made the enclosed jnl.pro, and I also put it in my startup-file.
The purpose is to save a few keystrokes, make sure you're allways
journalling, and that you can can easily close the journal file and
start a new one.
(I seem to recall that in IDL on (NT-)windows, FLUSH doesn't seem to
work.)
But I didn't get to the point where I could machine-edit the
journal-file.
- Kristian
; Begin code ------------------------------
pro jnl, close=close, stop=stop, $
automatic=automatic, new=new, flush=flush, $
query=query, help=help, usage=usage, $
debug=debug, replace=replace, $
filename=filename, text=text, atext
;PURPOSE: jnl.pro is a wrapper routine for JOURNAL
;CALLING SEQUENCE:
; jnl, [atext,] /<keywords>
;INPUTS:
; atext : Filename or text to journal (optional)
;KEYWORD PARAMETERS:
;MODIFICATION HISTORY:
; K. Kjaer Riso Nov-98:
;-
true=1
sep='/'
if (!version.os_family eq 'Windows') then sep='\'
case true of
(keyword_set(close) or keyword_set(stop)) and (!JOURNAL gt 0) : begin
; Close the journal file:
fstat_journal=fstat(!JOURNAL)
journal_file=findfile(fstat_journal.name) ; truncated if IDLversion lt
5.
JOURNAL
Print, 'Closed journal file '+fstat_journal.name+' ('+journal_file+')'
end
(keyword_set(close) or keyword_set(stop)) and (!JOURNAL eq 0) : begin
Print, 'Not journalling'
end
keyword_set(query) and (!JOURNAL eq 0) : begin
Print, 'Not journalling'
end
keyword_set(query) and (!JOURNAL gt 0) : begin
if keyword_set(verbose) then help,/str,fstat(!JOURNAL)
fstat_journal=fstat(!JOURNAL)
journal_file=findfile(fstat_journal.name) ; truncated if IDLversion lt
5.
Print, 'Journalling to '+fstat_journal.name+' ('+journal_file+')'
end
keyword_set(flush) and (!JOURNAL gt 0) : begin
flush,!journal ; Seems to have no effect!
end
keyword_set(help) or keyword_set(usage) : begin
Print,'Usage: jnl, /close, /stop, /automatic, /new, /flush, /query,
/help, /usage,/debug, /replace, filename="...", text="...",
"filename_without_blanks", "text with blanks in it"'
end
(keyword_set(new) or keyword_set(automatic)) and (!JOURNAL gt 0) : begin
jnl, debug=debug, replace=replace,/close
jnl, debug=debug, replace=replace,/new
end
(keyword_set(new) or keyword_set(automatic)) and (!JOURNAL eq 0) : begin
journal_file=getenv('temp') ; the temp directory
if keyword_set(debug) then print, 'temp directory: '+journal_file
if (journal_file eq '') then begin
print, 'temp is not assigned'
print, 'Pls. assign an environment variable temp to point to
your chosen scratch directory!'
journal_file='.'
endif
if (strmid(journal_file,strlen(journal_file)-1,1) ne sep) then
journal_file=journal_file+sep
if keyword_set(debug) then print, journal_file
; Generate a new, unique file name (I'm sorry that, so far this is
systime() converted to 8.3 format):
journal_file=journal_file+string(systime(1)*.1,format='(f12. 3)')
; Another approach could be based on bin_date(systime(0))
if keyword_set(debug) then print, journal_file
jnl, debug=debug, replace=replace,filename=journal_file
end
exist(filename) and (!JOURNAL gt 0) : begin
jnl, debug=debug, replace=replace,/close
jnl, debug=debug, replace=replace,filename=filename
end
exist(filename) and (!JOURNAL eq 0) : begin
; Open the journal file:
; (1st check if filename already present !)
findfilename=findfile(filename,count=count)
if ((count gt 0) and not keyword_set(replace)) then begin
Print, 'Journal file '+filename+' already present. Use
jnl,...,/replace or another file name !'
Print, 'Not journalling.'
endif else begin
JOURNAL,filename
fstat_journal=fstat(!JOURNAL)
journal_file=findfile(fstat_journal.name) ; truncated if IDLversion
lt 5.
Print, 'Started journalling to '+fstat_journal.name+'
('+journal_file+')'
endelse
end
exist(text) and (!JOURNAL gt 0) : begin
JOURNAL,TEXT
end
exist(text) and (!JOURNAL eq 0) : begin
jnl, debug=debug, replace=replace,/query
end
exist(atext) : begin
if (strcompress(strtrim(atext,2),/remove_all) eq atext) then $
jnl, debug=debug, replace=replace,filename=atext else $
jnl, debug=debug, replace=replace,text =atext
end
else: begin
jnl, debug=debug, replace=replace,/help
jnl, debug=debug, replace=replace,/query
end
endcase
end
; End code ------------------------------
|