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

Home » Public Forums » archive » naming PS plots: variable+ string?
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: naming PS plots: variable+ string? [message #47641 is a reply to message #47543] Fri, 17 February 2006 00:44 Go to previous message
peter.albert@gmx.de is currently offline  peter.albert@gmx.de
Messages: 108
Registered: July 2005
Senior Member
Hi again,

the reason for the error message is than in both examples you are
trying to add an integer variable (figname) to a string variable
('.ps'). IDL starts with interpreting

"figname + ..." so it expects that the variable after the "+" sign is
any kind of number, too. It is difficult to guess which number is
represented by the string ".ps", therefore IDL is giving up ...

You want to use the "+" sign for concatenating strings, so you must
ensure that "figname" is a string _before_ "adding" it to ".ps".

You would start with

psfilename = string(figname) + ".ps"

and be surprised about the many blanks in the filename. Hence,
something like

psfilename = string(figname, format = '(i4.4)') + ".ps"

already looks much better. Or, alternatively

psfilename = strcompress(string(figname), /remove_all) + ".ps"

The first example leaves you with 4 characters before the ".ps", no
matter which value figname has:

0001.ps
0002.ps
...
2004.ps
...

but fails when figname exceeds 9999. The second example works with all
integer values but creates filenames like

1.ps
2.ps
10.ps
...

Cheers,

Peter
[Message index]
 
Read Message
Read Message
Read Message
Previous Topic: Image proccesing programs
Next Topic: Re: Fractional Pixels Origin?

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

Current Time: Wed Oct 08 13:07:57 PDT 2025

Total time taken to generate the page: 0.00474 seconds