Print format question for the Experts [message #25988] |
Thu, 02 August 2001 11:51  |
jmcfee
Messages: 17 Registered: August 1995
|
Junior Member |
|
|
I have a question which I think should have a simple answer. Being a master of
kludging code for physics problems, it's not surprising that I haven't been able
to figure it out. I'm hoping the experts in this group can.
I am using IDL to read records one at a time from a file and I want to print out
a message that each record was successfully read, i.e., I would print something
like the following for record 5:
Record number 5 out of 1500
Because I can have several thousand records in a run, I do not want to have a
flowing list like:
...
Record number 1034 out of 1500
Record number 1035 out of 1500
Record number 1036 out of 1500
...etc.
but instead just want one line where the record number increments, i.e.,
Record number n out of 1500 [where n changes at the same spot]
To do that I tried the following code:
i=0
print, format='($,"Record number ",t19,i6,t27,"out of " , t28,i6)',i+1,max_rec
for i=0,max_rec-1 do begin
read_a_record_function
print, format='($,tl42,i6)', i+1
endfor
What I get is something like:
Record number 1 out of 1500 2 3 4 5 6 7 8 9 10 11 13 14
15....etc.
In other words, the $ format character supresses the new line, but each new
print sets the next line's "left-right" pointer at the right edge of the
previous printed line.
I've tried the t format char as well as the tl character with no more luck.
Does anybody know how to do this?
Thanks
John McFee
--
Dr. John E. McFee
Defence Research Establishment Suffield
Box 4000, Medicine Hat, AB Canada T1A 8K6
(403) 544-4739 (voice) 544-4704 (fax)
e-mail: John.McFee@dres.dnd.ca
--
____________
Dr. John E. McFee | John.McFee@dres.dnd.ca
Head Threat Detection Group | www.dres.dnd.ca, www.ccmat.gc.ca
Defence Research Establishment Suffield | PH: 403-544-4739
|
|
|
Re: Print format question -> DEcTerm Title utility [message #26120 is a reply to message #25988] |
Thu, 02 August 2001 20:47  |
Andrew Cool
Messages: 219 Registered: January 1996
|
Senior Member |
|
|
John McFee wrote:
>
> Because I can have several thousand records in a run, I do not want to have a
> flowing list like:
>
> ...
> Record number 1034 out of 1500
> Record number 1035 out of 1500
> Record number 1036 out of 1500
> ...etc.
>
> but instead just want one line where the record number increments, i.e.,
>
> Record number n out of 1500 [where n changes at the same spot]
For VMS users,
This ancient utility to change the title of VMS DECTerms and
optionally the associated Icon labels may be of interest as an
alternative to print statements to the Output log, or even
a widget progress-meter-thingy.
There's an overhead of course, and for large loops it would
be prudent to call the routine every nth iteration or so.
Note that a string array applied to the Icon produces multiple
lined labels.
This works nicely under OVMS 7.3
Cheers,
Andrew
;+
;1 DECTERM_TITLE
;
; Write out supplied string/array to either DecTerm title window
; or the DecTerm's Icon.
;
; Calling with no title parameter resets the window/icon title
; to the title as it existed when the IDL session was started up.
;
; If a string array is passed to the ICON label, Line feeds (LF) will
be
; inserted automatically to create a multiple line icon. There is a
limit
; of about 50-60 characters all up for multiple line icons, including 1
LF
; character per line.
;
; If a string array is passed to the DecTerm title, a single blank
space
; is inserted between array elements.
;
; Examples :
;
; Insert new title : DECTERM_TITLE,'Executing Test.exe'
; DECTERM_TITLE,'Test.exe',/ICON
; DECTERM_TITLE,/ICON,['This','is a','test']
;
; Reset to previous title : DECTERM_TITLE
; DECTERM_TITLE,/ICON
;
; Format:
; IDL> DECTERM_TITLE [,title,/ICON]
;
;
;2 Amendments
; 23-Aug-93 Andrew COOL 1.00 Baseline.
;
;
;*********************************************************** ********************
; Surveillance Systems Division
; Defence Science & Technology Organisation (DSTO)
; Salisbury, Adelaide, AUSTRALIA
;
; andrew.cool@dsto.defence.gov.au
;*********************************************************** ********************
;-
PRO Decterm_Title, title, ICON = icon
IF N_ELEMENTS(title) EQ 0 THEN title = ''
;... Define <ESC> sequence characters
osc = STRING(157B)
st = STRING(156B)
;... If writing to ICON, then set lf to LINE FEED, else set to blank pad
IF KEYWORD_SET(icon) NE 0 THEN BEGIN
lf = STRING(10B)
ENDIF ELSE BEGIN
lf = ' '
ENDELSE
;... If title is an array, then concatenate elements and add LF's
IF N_ELEMENTS(title) GT 1 THEN BEGIN
tmp = title(0) + lf
FOR i = 1,N_ELEMENTS(title)-1 DO BEGIN
tmp = tmp + title(i) + lf
END
title = tmp
ENDIF
IF KEYWORD_SET(icon) NE 0 THEN BEGIN
cmd = osc + '2L;' + title + st
ENDIF ELSE BEGIN
cmd = osc + '21;' + title + st
ENDELSE
;... Just writing this to the screen affects either the DecTerm title
;... or the icon
PRINT,cmd
END
------------------------------------------------------------ ---------
Andrew D. Cool .->-.
Electromagnetics & Propagation Group `-<-'
Surveillance Systems Division Transmitted on
Defence Science & Technology Organisation 100% recycled
PO Box 1500, Salisbury electrons
South Australia 5108
Phone : 061 8 8259 5740 Fax : 061 8 8259 6673
Email : andrew.cool@dsto.defence.gov.au
------------------------------------------------------------ ---------
|
|
|