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

Home » Public Forums » archive » Re: The usage of PS_END
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: The usage of PS_END [message #62778] Mon, 06 October 2008 21:55
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
David Fanning writes:

> http://www.dfanning.com/programs/psconfig.zip
>
> Sorry for the mix-up. It seems if I make one small change in this
> library, I have to fix 50. Weird.

Yikes! I can't even get the filename right. :-(

http://www.dfanning.com/programs/fsc_psconfig.zip

David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
Re: The usage of PS_END [message #62779 is a reply to message #62778] Mon, 06 October 2008 21:54 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
duxiyu@gmail.com writes:

> I have found the reason that made PS_END not to covert PS file to
> another type file.
> Because my file path contains a space like 'C:\My Documents'.
>
> The string 'cmd' in PS_END is 'convert -density 300 D:\My Documents
> \lineplot.ps -resize 25% D:\My Documents\lineplot.png'
> When the command 'SPAWN, cmd' is executed, the windows system cannot
> identify 'My Documents' as a whole directory name.
> So the double quotation marks shouble be added for the filename with
> filepath.
> The cmd become 'convert -density 300 "D:\My Documents\lineplot.ps" -
> resize 25% "D:\My Documents\lineplot.png"'.
>
> Therefore, I change the line 187 in PS_START/PS_END into
> cmd =3D 'convert -density 300 ' + '"' + ps_struct.filename + '"' + ' -
> resize 25% ' + '"' + outfilename + '"'
> And now the command 'PS_END, /png' can create 'lineplot.png'
> successfully.
>
> But I want to konw how to call PS_START with the whole path filename,
> for example:
> ps_start,filename=3D'D:\plot.ps'

Well, this turned out to be partly my fault, sorry. :-(

PSConfig was written so that you had to pass it a filename and a
directory name. Of course, no one does, probably. They just pass
it a filename that has directories appended to the name. So, I if you
did to that, I was appending something else on to the front of that,
and ... well, it was ugly. So that is fixed.

Then, I just fixed PS_END so the command that I am going to SPAWN
will accept filenames with spaces in them.

You can get all the files you need (assuming you following my
advice this morning and downloaded a new copy of the Coyote
Library), by downloading and installing this file over the top
of your Coyote Library files:

http://www.dfanning.com/programs/psconfig.zip

Sorry for the mix-up. It seems if I make one small change in this
library, I have to fix 50. Weird.

Cheers,

David

--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
Re: The usage of PS_END [message #62780 is a reply to message #62779] Mon, 06 October 2008 16:04 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Jeff N. writes:

> which of course means you have to split your string using '\' (or
> path_sep()) as a delimeter, search all the extracted strings for
> spaces and then put quotes around any that need them. Sigh. I hope i
> didn't have to do all that, that doesn't sound fun :(

Sounds like you have that function half-way written, Jeff. :-)

Cheers,

David

--
David Fanning, Ph.D.
Coyote's Guide to IDL Programming (www.dfanning.com)
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
Re: The usage of PS_END [message #62781 is a reply to message #62780] Mon, 06 October 2008 16:02 Go to previous message
jeffnettles4870 is currently offline  jeffnettles4870
Messages: 111
Registered: October 2006
Senior Member
On Oct 6, 6:56 pm, "Jeff N." <jeffnettles4...@gmail.com> wrote:
> On Oct 6, 5:22 pm, David Fanning <n...@dfanning.com> wrote:
>
>
>
>> dux...@gmail.com writes:
>>> I have found the reason that made PS_END not to covert PS file to
>>> another type file.
>>> Because my file path contains a space like 'C:\My Documents'.
>
>>> The string 'cmd' in PS_END is 'convert -density 300 D:\My Documents
>>> \lineplot.ps -resize 25% D:\My Documents\lineplot.png'
>>> When the command 'SPAWN, cmd' is executed, the windows system cannot
>>> identify 'My Documents' as a whole directory name.
>>> So the double quotation marks shouble be added for the filename with
>>> filepath.
>>> The cmd become 'convert -density 300 "D:\My Documents\lineplot.ps" -
>>> resize 25% "D:\My Documents\lineplot.png"'.
>
>>> Therefore, I change the line 187 in PS_START/PS_END into
>>> cmd =3D 'convert -density 300 ' + '"' + ps_struct.filename + '"' + ' -
>>> resize 25% ' + '"' + outfilename + '"'
>>> And now the command 'PS_END, /png' can create 'lineplot.png'
>>> successfully.
>
>>> But I want to konw how to call PS_START with the whole path filename,
>>> for example:
>>>      ps_start,filename=3D'D:\plot.ps'
>
>> Humm. This is a good point. Spaces in file names gave
>> me so damn much grief when the Windows and first Mac
>> versions of IDL came out, that I have never--from that
>> day to this--EVER named a directory with a space in it
>> on any computer I ever owned. (The definition of an
>> indelible experience, I guess.)
>
>> ITTVIS has produced a function (IDL_VALIDNAME) to let
>> you know if a string is a valid variable name. Perhaps
>> someone can write a function that can fix filenames with
>> spaces inside them. (I have to leave it as an exercise
>> for the reader, as I am late for a meeting.)
>
>> Cheers,
>
>> David
>
>> --
>> David Fanning, Ph.D.
>> Coyote's Guide to IDL Programming (www.dfanning.com)
>> Sepore ma de ni thui. ("Perhaps thou speakest truth.")
>
> This gave me an issue with ps_start/ps_end also.  You have to surround
> the path with quotes, but this turned out to not be as easy as I
> thought so what I did was use the ascii character for a quote:
>
> path = c:\documents and settings\blah\blah\blah'
> quote = string(34b)
> path = quote + path + quote
>
> That worked for me.
>
> Jeff

oops first line should be:
path = 'c:\documents and settings\blah\blah\blah'

Now that I think about it, i may even have had to quote the individual
directories, not the entire path string (so the path to pass to
convert.exe would be

c:\"documents and settings"\blah\blah\blah

and not

"c:\documents and settings\blah\blah\blah"

which of course means you have to split your string using '\' (or
path_sep()) as a delimeter, search all the extracted strings for
spaces and then put quotes around any that need them. Sigh. I hope i
didn't have to do all that, that doesn't sound fun :(

Jeff
Re: The usage of PS_END [message #62782 is a reply to message #62781] Mon, 06 October 2008 15:56 Go to previous message
jeffnettles4870 is currently offline  jeffnettles4870
Messages: 111
Registered: October 2006
Senior Member
On Oct 6, 5:22 pm, David Fanning <n...@dfanning.com> wrote:
> dux...@gmail.com writes:
>> I have found the reason that made PS_END not to covert PS file to
>> another type file.
>> Because my file path contains a space like 'C:\My Documents'.
>
>> The string 'cmd' in PS_END is 'convert -density 300 D:\My Documents
>> \lineplot.ps -resize 25% D:\My Documents\lineplot.png'
>> When the command 'SPAWN, cmd' is executed, the windows system cannot
>> identify 'My Documents' as a whole directory name.
>> So the double quotation marks shouble be added for the filename with
>> filepath.
>> The cmd become 'convert -density 300 "D:\My Documents\lineplot.ps" -
>> resize 25% "D:\My Documents\lineplot.png"'.
>
>> Therefore, I change the line 187 in PS_START/PS_END into
>> cmd =3D 'convert -density 300 ' + '"' + ps_struct.filename + '"' + ' -
>> resize 25% ' + '"' + outfilename + '"'
>> And now the command 'PS_END, /png' can create 'lineplot.png'
>> successfully.
>
>> But I want to konw how to call PS_START with the whole path filename,
>> for example:
>>      ps_start,filename=3D'D:\plot.ps'
>
> Humm. This is a good point. Spaces in file names gave
> me so damn much grief when the Windows and first Mac
> versions of IDL came out, that I have never--from that
> day to this--EVER named a directory with a space in it
> on any computer I ever owned. (The definition of an
> indelible experience, I guess.)
>
> ITTVIS has produced a function (IDL_VALIDNAME) to let
> you know if a string is a valid variable name. Perhaps
> someone can write a function that can fix filenames with
> spaces inside them. (I have to leave it as an exercise
> for the reader, as I am late for a meeting.)
>
> Cheers,
>
> David
>
> --
> David Fanning, Ph.D.
> Coyote's Guide to IDL Programming (www.dfanning.com)
> Sepore ma de ni thui. ("Perhaps thou speakest truth.")

This gave me an issue with ps_start/ps_end also. You have to surround
the path with quotes, but this turned out to not be as easy as I
thought so what I did was use the ascii character for a quote:

path = c:\documents and settings\blah\blah\blah'
quote = string(34b)
path = quote + path + quote

That worked for me.

Jeff
Re: The usage of PS_END [message #62783 is a reply to message #62782] Mon, 06 October 2008 14:22 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
duxiyu@gmail.com writes:

> I have found the reason that made PS_END not to covert PS file to
> another type file.
> Because my file path contains a space like 'C:\My Documents'.
>
> The string 'cmd' in PS_END is 'convert -density 300 D:\My Documents
> \lineplot.ps -resize 25% D:\My Documents\lineplot.png'
> When the command 'SPAWN, cmd' is executed, the windows system cannot
> identify 'My Documents' as a whole directory name.
> So the double quotation marks shouble be added for the filename with
> filepath.
> The cmd become 'convert -density 300 "D:\My Documents\lineplot.ps" -
> resize 25% "D:\My Documents\lineplot.png"'.
>
> Therefore, I change the line 187 in PS_START/PS_END into
> cmd =3D 'convert -density 300 ' + '"' + ps_struct.filename + '"' + ' -
> resize 25% ' + '"' + outfilename + '"'
> And now the command 'PS_END, /png' can create 'lineplot.png'
> successfully.
>
> But I want to konw how to call PS_START with the whole path filename,
> for example:
> ps_start,filename=3D'D:\plot.ps'

Humm. This is a good point. Spaces in file names gave
me so damn much grief when the Windows and first Mac
versions of IDL came out, that I have never--from that
day to this--EVER named a directory with a space in it
on any computer I ever owned. (The definition of an
indelible experience, I guess.)

ITTVIS has produced a function (IDL_VALIDNAME) to let
you know if a string is a valid variable name. Perhaps
someone can write a function that can fix filenames with
spaces inside them. (I have to leave it as an exercise
for the reader, as I am late for a meeting.)

Cheers,

David

--
David Fanning, Ph.D.
Coyote's Guide to IDL Programming (www.dfanning.com)
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
Re: The usage of PS_END [message #62784 is a reply to message #62783] Mon, 06 October 2008 13:32 Go to previous message
duxiyu@gmail.com is currently offline  duxiyu@gmail.com
Messages: 88
Registered: March 2007
Member
I have found the reason that made PS_END not to covert PS file to
another type file.
Because my file path contains a space like 'C:\My Documents'.

The string 'cmd' in PS_END is 'convert -density 300 D:\My Documents
\lineplot.ps -resize 25% D:\My Documents\lineplot.png'
When the command 'SPAWN, cmd' is executed, the windows system cannot
identify 'My Documents' as a whole directory name.
So the double quotation marks shouble be added for the filename with
filepath.
The cmd become 'convert -density 300 "D:\My Documents\lineplot.ps" -
resize 25% "D:\My Documents\lineplot.png"'.

Therefore, I change the line 187 in PS_START/PS_END into
cmd = 'convert -density 300 ' + '"' + ps_struct.filename + '"' + ' -
resize 25% ' + '"' + outfilename + '"'
And now the command 'PS_END, /png' can create 'lineplot.png'
successfully.

But I want to konw how to call PS_START with the whole path filename,
for example:
ps_start,filename='D:\plot.ps'


Du


On Oct 4, 1:42 pm, "dux...@gmail.com" <dux...@gmail.com> wrote:
> Hi, all.
>
> PS_START/PS_END is a very useful program in Coyote Program Library.
> But I have some troubles to use PS_END to convert ps file to another
> type.
>
> I have installed ImageMagick and the command COVERT is avaible when I
> test it in system.
> My OS is vista and the version of IDL is 7.0.
>
> However, I cannot repeat the example which is given in David's
> website.
> ;----------------------------------------------------------- ----------------------------------
>   PS_Start, FILENAME='lineplot.ps'
>   Plot, Findgen(11), COLOR=FSC_Color('navy'), /NODATA, XTITLE='Time',
> YTITLE='Signal'
>   OPlot, Findgen(11), COLOR=FSC_Color('indian red')
>   OPlot, Findgen(11), COLOR=FSC_Color('olive'), PSYM=2
>   PS_End, /PNG
> ;----------------------------------------------------------- ----------------------------------
> After I excuted them, there was no problem about the PS file
> 'lineplot.ps', but the PNG file was not created.
>
> Best wished,
> Du
Re: The usage of PS_END [message #62788 is a reply to message #62784] Mon, 06 October 2008 05:41 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
jlglover@gmail.com writes:

> While we are discusing these programs, I might ask the filename
> keyword works paths. If I call ps_start like this:
>
> ps_start,filename='plot.ps'
>
> the plot will sometimes appear in the directory of the program that
> calls ps_start and sometimes it appears in my home directory.
> Sometimes it even appears in the directory that stores ps_start.pro.
> Does anyone (David perhaps) have any advice about how to control where
> the output of ps_start appears? I am using IDL 7.0 on a Mac.

As a matter of fact, I do know something about this.
It appears to me, although I haven't confirmed this theory,
that there is a difference in how IDL 7 handles file names.
It used to be, for example, that in most of IDL's file name
machinery, you could use forward or backward slashes
interchangeably.

And while this appears still to be true for *some* of the
IDL routines, it is clearly *NOT* true for Dialog_Pickfile.
On Windows machines, at least, if you set the opening path with
forward slashes, Dialog_Pickfile ignores the PATH variable and
opens the file in the directory that was *last* opened in that
IDL session.

I found this out because I was starting to be confused by
PSConfig, too. So, this past weekend I looked into it, and
I traced the problem to FSC_FileSelect, which is what I use
to select files in PSConfig. FSC_FileSelect was routinely
changing back slashes to forward slashes whenever it had
to work with directory names, which was fairly often. I am
not sure now exactly *why* I thought that was a good idea
all those years ago when I wrote that program, but it is clearly
not a good idea now, so I have stripped all that code out of
the program. (Actually, I just commented it out, because
clearly I meant to do it for some reason, and absent the
reason, I am reluctant to commit 100 percent in the opposite
direction.)

It now appears to work consistently, as long as the user
specifies the directory name in a way that is consistent with
good practice for that particular operating system. However,
if the path is incorrect (maybe you have misspelled the
directory name), then Windows still uses the last opened
directory in Dialog_Pickfile.

So, if I were you, I think I would download a new copy of the
Coyote Library. I think I would do this anyway, since I have
made at least 20-30 changes to the library in the past couple
of weeks, including numerous changes to PSConfig. You can find
it here:

http://www.dfanning.com/programs/coyoteprograms.zip

I would encourage everyone to do this whose library is older
than, say, yesterday. :-)

Cheers,

David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
Re: The usage of PS_END [message #62792 is a reply to message #62788] Sun, 05 October 2008 23:48 Go to previous message
jlglover is currently offline  jlglover
Messages: 2
Registered: October 2008
Junior Member
First of all, let me say that I love ps_config. I use it in many of my
programs and it makes producing postscript plots so much easier.

While we are discusing these programs, I might ask the filename
keyword works paths. If I call ps_start like this:

ps_start,filename='plot.ps'

the plot will sometimes appear in the directory of the program that
calls ps_start and sometimes it appears in my home directory.
Sometimes it even appears in the directory that stores ps_start.pro.
Does anyone (David perhaps) have any advice about how to control where
the output of ps_start appears? I am using IDL 7.0 on a Mac.
Re: The usage of PS_END [message #62796 is a reply to message #62792] Sun, 05 October 2008 16:20 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
duxiyu@gmail.com writes:

> I will use PSConfig instead of it.
> Because I found that the parameter filename for PS_START can not be
> set as the whole path file like 'D:\lineplot.ps'.
> It added the current path before the given filename, and get errors as
> calling DEVICE.

Well, uh, right. Whatever works. :-(

Cheers,

David

P.S. I get the feeling I know how Joe Biden felt
last Thursday.

--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
Re: The usage of PS_END [message #62797 is a reply to message #62796] Sun, 05 October 2008 16:07 Go to previous message
duxiyu@gmail.com is currently offline  duxiyu@gmail.com
Messages: 88
Registered: March 2007
Member
I will use PSConfig instead of it.
Because I found that the parameter filename for PS_START can not be
set as the whole path file like 'D:\lineplot.ps'.
It added the current path before the given filename, and get errors as
calling DEVICE.

Best regards,
Du


On Oct 4, 3:58 pm, David Fanning <n...@dfanning.com> wrote:
> dux...@gmail.com writes:
>> PS_START/PS_END is a very useful program in Coyote Program Library.
>> But I have some troubles to use PS_END to convert ps file to another
>> type.
>
>> I have installed ImageMagick and the command COVERT is avaible when I
>> test it in system.
>> My OS is vista and the version of IDL is 7.0.
>
>> However, I cannot repeat the example which is given in David's
>> website.
>> ;----------------------------------------------------------- ----------------------------------
>>   PS_Start, FILENAME='lineplot.ps'
>>   Plot, Findgen(11), COLOR=FSC_Color('navy'), /NODATA, XTITLE='Time',
>> YTITLE='Signal'
>>   OPlot, Findgen(11), COLOR=FSC_Color('indian red')
>>   OPlot, Findgen(11), COLOR=FSC_Color('olive'), PSYM=2
>>   PS_End, /PNG
>> ;----------------------------------------------------------- ----------------------------------
>> After I excuted them, there was no problem about the PS file
>> 'lineplot.ps', but the PNG file was not created.
>
> Humm. Well, if you have confirmed that all the individual parts
> work, and that you can make a PNG file from your PS file by hand
> using ImageMagik, then I think the only possible explanation is computer
> gremlins. If this is the case, then I am afraid the only solution
> available to you is fervent prayer. :-(
>
> Cheers,
>
> David
> --
> David Fanning, Ph.D.
> Fanning Software Consulting, Inc.
> Coyote's Guide to IDL Programming:http://www.dfanning.com/
> Sepore ma de ni thui. ("Perhaps thou speakest truth.")
Re: The usage of PS_END [message #62798 is a reply to message #62797] Sun, 05 October 2008 15:53 Go to previous message
duxiyu@gmail.com is currently offline  duxiyu@gmail.com
Messages: 88
Registered: March 2007
Member
I am sorry.
I do not want to repeat my messenger.
I seems that there was some problem about this newsgroup yesterday.
I could not see the new post and thought that I did not post it with
some errors.
Therefore, I reposted it for several times.

I have deleted the others.


On Oct 4, 2:36 pm, James Kuyper <jameskuy...@verizon.net> wrote:
> I don't know the answer to your question. I'm responding just to point
> out that this is a usenet newsgroup, not a chat room. There's no need to
> repeat your messages, they'll wait around until someone who knows the
> answer sees them and decides to send a response. The person most likely
> to be helpful will be David Fanning; he lives in Colorado, and it's a
> weekend - you might have to wait quite a while until he checks his
> newsgroups.
Re: The usage of PS_END [message #62802 is a reply to message #62798] Sat, 04 October 2008 06:58 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
duxiyu@gmail.com writes:

> PS_START/PS_END is a very useful program in Coyote Program Library.
> But I have some troubles to use PS_END to convert ps file to another
> type.
>
> I have installed ImageMagick and the command COVERT is avaible when I
> test it in system.
> My OS is vista and the version of IDL is 7.0.
>
> However, I cannot repeat the example which is given in David's
> website.
> ;----------------------------------------------------------- ----------------------------------
> PS_Start, FILENAME='lineplot.ps'
> Plot, Findgen(11), COLOR=FSC_Color('navy'), /NODATA, XTITLE='Time',
> YTITLE='Signal'
> OPlot, Findgen(11), COLOR=FSC_Color('indian red')
> OPlot, Findgen(11), COLOR=FSC_Color('olive'), PSYM=2
> PS_End, /PNG
> ;----------------------------------------------------------- ----------------------------------
> After I excuted them, there was no problem about the PS file
> 'lineplot.ps', but the PNG file was not created.

Humm. Well, if you have confirmed that all the individual parts
work, and that you can make a PNG file from your PS file by hand
using ImageMagik, then I think the only possible explanation is computer
gremlins. If this is the case, then I am afraid the only solution
available to you is fervent prayer. :-(

Cheers,

David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
Re: The usage of PS_END [message #62803 is a reply to message #62802] Sat, 04 October 2008 05:36 Go to previous message
jameskuyper is currently offline  jameskuyper
Messages: 79
Registered: October 2007
Member
I don't know the answer to your question. I'm responding just to point
out that this is a usenet newsgroup, not a chat room. There's no need to
repeat your messages, they'll wait around until someone who knows the
answer sees them and decides to send a response. The person most likely
to be helpful will be David Fanning; he lives in Colorado, and it's a
weekend - you might have to wait quite a while until he checks his
newsgroups.
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Debugging C code called from CALL_EXTERNAL
Next Topic: Re: Debugging C code called from CALL_EXTERNAL

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

Current Time: Wed Oct 08 13:51:24 PDT 2025

Total time taken to generate the page: 0.00856 seconds