open a file in a browser from a newLISP script

Machine-specific discussion
Unix, Linux, OS X, OS/2, Windows, ..?
Locked
cormullion
Posts: 2038
Joined: Tue Nov 29, 2005 8:28 pm
Location: latiitude 50N longitude 3W
Contact:

open a file in a browser from a newLISP script

Post by cormullion »

I've written this for running on MacOS X:

Code: Select all

(if (= ostype "OSX") 
    (exec (string "open " file ".html")))
which displays the file.html file in the default web browser. Is there an equivalent form for Windows?

DrDave
Posts: 126
Joined: Wed May 21, 2008 2:47 pm

Re: open a file in a browser from a newLISP script

Post by DrDave »

cormullion wrote:I've written this for running on MacOS X:

Code: Select all

(if (= ostype "OSX") 
    (exec (string "open " file ".html")))
which displays the file.html file in the default web browser. Is there an equivalent form for Windows?

Code: Select all

(set 'filename-with-path "c:/myhtmlfile.html")
(exec filename-with-path)
or more like your example

Code: Select all

(set 'path "c:/" 'filename "myhtmlfile")
(exec (string path filename ".html"))
Beware of spaces in the filename; you'll need to wrap the string like this

Code: Select all

(set 'path "c:/" 'filename {"my html file"})
(exec (string path filename ".html"))
...it is better to first strive for clarity and correctness and to make programs efficient only if really needed.
"Getting Started with Erlang" version 5.6.2

cormullion
Posts: 2038
Joined: Tue Nov 29, 2005 8:28 pm
Location: latiitude 50N longitude 3W
Contact:

Post by cormullion »

Thanks.

Locked