comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: print to a variable
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: print to a variable [message #5261] Fri, 24 November 1995 00:00
Frank J. �ynes is currently offline  Frank J. �ynes
Messages: 17
Registered: February 1995
Junior Member
dwu@larry.cc.emory.edu (Ding Wu) wrote:
> C R Shaw (C.Shaw@qub.ac.uk) wrote:
>
> : Have you tried the JOURNAL command??
> : --
>
> JOURNAL can record all the commands and the print results,
> but cannot save everything on the screen, such as help
> results.
>
> Thank you anyway.
> --
> Ding Wu

If I understand you correctly, you want to log everything, i.e. both
stderr and stdout, to a file during your idl session.

If you start idl via an xterm, the simplest is probably to enable
logging. Something like
xterm -l -lf logfile -e idl &

will start idl in an xterm, and everything will be logged to the file
logfile.

This is for "my" xterm. The flags -l and -lf may not be the same
on your xterm.

To run it in your current window, you could redirect stderr to stdin
and then use tee to log to a file:
idl 2>&1 | tee logfile
(this is valid for sh, bash, ....)

But beware, I'm not sure if the terminal window output will
keep its nice default formatting. You need to try it yourself.

--
/* Frank J. �ynes | frank@spacetec.no /*
/* Spacetec a.s | Phone: +47 77684500 Fax: +47 77655859 /*
/* Prestvannv. 38, | /*
/* N-9005 Troms�, Norway | (...with the bravery of being out of range!) /*
Re: print to a variable [message #5266 is a reply to message #5261] Wed, 22 November 1995 00:00 Go to previous message
dwu is currently offline  dwu
Messages: 14
Registered: November 1995
Junior Member
C R Shaw (C.Shaw@qub.ac.uk) wrote:

: Have you tried the JOURNAL command??
: --

JOURNAL can record all the commands and the print results,
but cannot save everything on the screen, such as help
results.

Thank you anyway.
--
Ding Wu
Re: print to a variable [message #5267 is a reply to message #5266] Wed, 22 November 1995 00:00 Go to previous message
C.Shaw is currently offline  C.Shaw
Messages: 1
Registered: November 1995
Junior Member
In article <48qs6j$32f@curly.cc.emory.edu>,
dwu@curly.cc.emory.edu (Ding Wu) writes:
> The question is how to print all the stuff into a string stead of screen.
> such as when you type help, you will see
> IDL> help
> % At $MAIN$
> Code area used: 0% (0/32768), Symbol area used: 0% (4/8192)
> # local variables: 0, # parameters: 0
> Compiled Procedures:
> $MAIN$
> Compiled Functions:
>
> What I want is a string or array of string to store these information.
>
> I have a method:
>
> shell> idl > idl.log
> IDL> (do the job, print, help,...)
> all of these will not be seen on the screen, it will be in the
> file idl.log
> IDL> (test how many lines in the file use NOT EOF(unit) )
> IDL> (replicate a string to an array of string)
> IDL> (readf the file to the string array)
>
> This method will print all the results, and not show them on the screen.
> Now my question is how to print only one command result, and also
> print everything to the screen simultaneously.
>

Have you tried the JOURNAL command??
--
------------------------------------------------------------ -
Mail : Dept. of Pure and Applied Physics,
Queen's University Belfast,
University Road.
Belfast BT7 1NN
E-mail : C.Shaw@QUB.ac.uk
Phone : (01232) 245133 Ext 3045
Fax : (01232) 438918
------------------------------------------------------------ -
Re: print to a variable [message #5278 is a reply to message #5266] Mon, 20 November 1995 00:00 Go to previous message
thompson is currently offline  thompson
Messages: 584
Registered: August 1991
Senior Member
gfu@shark.gsfc.nasa.gov (Gary Fu) writes:

> Hi,

> Is there a simple way to write outputs to a string variable that has
> the same result as by using the 'print' statement ?

> I'm asking something like 'sprintf' as to 'printf' in C.

Yes, you can use the STRING function with the /PRINT qualifier. For example,

IDL> print,indgen(10)
0 1 2 3 4 5 6 7 8
9
IDL> s = string(indgen(10),/print)
IDL> help,s
S STRING = Array(2)
IDL> print,s(0)
0 1 2 3 4 5 6 7 8
IDL> print,s(1)
9

Bill Thompson
Re: print to a variable [message #5279 is a reply to message #5278] Mon, 20 November 1995 00:00 Go to previous message
dwu is currently offline  dwu
Messages: 14
Registered: November 1995
Junior Member
The question is how to print all the stuff into a string stead of screen.
such as when you type help, you will see
IDL> help
% At $MAIN$
Code area used: 0% (0/32768), Symbol area used: 0% (4/8192)
# local variables: 0, # parameters: 0
Compiled Procedures:
$MAIN$
Compiled Functions:

What I want is a string or array of string to store these information.

I have a method:

shell> idl > idl.log
IDL> (do the job, print, help,...)
all of these will not be seen on the screen, it will be in the
file idl.log
IDL> (test how many lines in the file use NOT EOF(unit) )
IDL> (replicate a string to an array of string)
IDL> (readf the file to the string array)

This method will print all the results, and not show them on the screen.
Now my question is how to print only one command result, and also
print everything to the screen simultaneously.




Mark Rivers (rivers@cars3.uchicago.edu) wrote:
: In article <48qip6$i99@post.gsfc.nasa.gov>, gfu@shark.gsfc.nasa.gov (Gary Fu) writes:

: >Is there a simple way to write outputs to a string variable that has
: >the same result as by using the 'print' statement ?
: >
: >I'm asking something like 'sprintf' as to 'printf' in C.
: >

: Use the string() function:
: IDL> a = !pi
: IDL> b = 'This is PI: ' + string(a)
: IDL> print, b
: This is PI: 3.14159

: Note that the string function takes a "format" keyword, just like print:
: IDL> print, string(!pi, format='(f10.2)')
: 3.14

: ____________________________________________________________
: Mark Rivers (312) 702-2279 (office)
: CARS (312) 702-9951 (secretary)
: Univ. of Chicago (312) 702-5454 (FAX)
: 5640 S. Ellis Ave. (708) 922-0499 (home)
: Chicago, IL 60637 rivers@cars3.uchicago.edu (Internet)

--
Ding Wu
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Representing graphs in IDL
Next Topic: Read Hex numbers

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 18:07:34 PDT 2025

Total time taken to generate the page: 0.00514 seconds