[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Print format question for the Experts
- Subject: Re: Print format question for the Experts
- From: david(at)dfanning.com (David Fanning)
- Date: Thu, 2 Aug 2001 13:41:24 -0600
- Newsgroups: comp.lang.idl-pvwave
- Organization: Fanning Software Consulting
- References: <996778221.628028@coyote>
- Xref: news.doit.wisc.edu comp.lang.idl-pvwave:25989
John McFee writes:
> 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?
How about this:
PRO Example
max_rec=20
base = Widget_Base()
text = Widget_Text(base, Value="", Scr_XSize=200, YSize=1)
screenSize = Get_Screen_Size()
xCenter = screenSize(0) / 2
yCenter = screenSize(1) / 2
geom = Widget_Info(base, /Geometry)
xHalfSize = geom.Scr_XSize / 2
yHalfSize = geom.Scr_YSize / 2
Widget_Control, base, XOffset = xCenter-xHalfSize, $
YOffset = yCenter-yHalfSize
Widget_Control, base, /Realize
maxnumber = StrTrim(max_rec, 2)
for I=0,max_rec-1 do begin
wait, 0.5 ; Or read a record or whatever.
number = StrTrim(I+1, 2)
Widget_Control, text, Set_Value='Record number ' + number + $
' out of ' + maxnumber + '.'
endfor
Widget_Control, base, /Destroy
END
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting
Phone: 970-221-0438 E-Mail: davidf@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155