Re: Opening/displaying a text file [message #64782] |
Tue, 20 January 2009 01:17 |
Maarten[1]
Messages: 176 Registered: November 2005
|
Senior Member |
|
|
[cut to size in various places]
On Jan 19, 2:50 pm, jimmyb...@gmail.com wrote:
> On 19 Jan, 12:18, Gaurav <selfishgau...@gmail.com> wrote:
>>> Do I need to read in the text and re-display it or can I use
>>> a command to open that .txt file, as if it were opened seperate of
>>> IDL?
>
>> Yes, you can easily do that. Try:
>
>> SPAWN, 'notepad.exe c:\myFolder\myFile.txt', /noshell, /nowait
>
> Brilliant, worked like a charm- thanks!
Be sure to test for the OS before attempting this. Never say your code
will never be used on Linux/Mac/... and spawns like this will cause
trouble later on. Use !version.os_family or !version.os to select the
correct OS you will use this on. In your case you may want to provide
this functionalty only on Windows (at least I think that that is the
correct identifier, check for yourself):
if !version.os_family eq 'windows' then begin
spawn, notepad.exe c:\myFolder\myFile.txt', /noshell, /nowait
endif else begin
print, 'functionality not supported'
endelse
By the way, on the mac the command would be:
spawn, "open '" + filepath +"'"
|
|
|
Re: Opening/displaying a text file [message #64785 is a reply to message #64782] |
Mon, 19 January 2009 05:50  |
jimmybobs
Messages: 9 Registered: January 2009
|
Junior Member |
|
|
On 19 Jan, 12:18, Gaurav <selfishgau...@gmail.com> wrote:
> On Jan 19, 3:51 pm, jimmyb...@gmail.com wrote:
>
>> Hi, I'm writing a GUI for some code in IDL and want to include a help
>> document. Is there a command to open say a .txt file?
>
>> To explain a bit further: I've tried openu, but that doesn't display
>> the file. Do I need to read in the text and re-display it or can I use
>> a command to open that .txt file, as if it were opened seperate of
>> IDL?
>
> Yes, you can easily do that. Try:
>
> SPAWN, 'notepad.exe c:\myFolder\myFile.txt', /noshell, /nowait
>
> Cheers,
> Gaurav
Brilliant, worked like a charm- thanks!
|
|
|
Re: Opening/displaying a text file [message #64786 is a reply to message #64785] |
Mon, 19 January 2009 04:25  |
R.Bauer
Messages: 1424 Registered: November 1998
|
Senior Member |
|
|
jimmybobs@gmail.com schrieb:
> Hi, I'm writing a GUI for some code in IDL and want to include a help
> document. Is there a command to open say a .txt file?
>
> To explain a bit further: I've tried openu, but that doesn't display
> the file. Do I need to read in the text and re-display it or can I use
> a command to open that .txt file, as if it were opened seperate of
> IDL?
>
> Thanks!
look at xdisplayfile
cheers
Reimar
|
|
|
Re: Opening/displaying a text file [message #64787 is a reply to message #64786] |
Mon, 19 January 2009 04:18  |
Gaurav
Messages: 50 Registered: January 2007
|
Member |
|
|
On Jan 19, 3:51 pm, jimmyb...@gmail.com wrote:
> Hi, I'm writing a GUI for some code in IDL and want to include a help
> document. Is there a command to open say a .txt file?
>
> To explain a bit further: I've tried openu, but that doesn't display
> the file. Do I need to read in the text and re-display it or can I use
> a command to open that .txt file, as if it were opened seperate of
> IDL?
Yes, you can easily do that. Try:
SPAWN, 'notepad.exe c:\myFolder\myFile.txt', /noshell, /nowait
Cheers,
Gaurav
|
|
|