open a file in the default web browser

Started by cormullion, December 09, 2008, 09:30:21 AM

Previous topic - Next topic

cormullion

I've written this for running on MacOS X:


(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 other Unixes, or is 'open' standard?

newdep

#1
Under unix/linux you dont have bindings to a file extention on OS basis,

though some window managers like XFCE, KDE or GNOME can do that its this,

but because of a newlisp execute it wont work, i think...

(i dont use eighter of them so i cant test it..)



You have to explicit execute the webbrowser the user is using for this...



Under windows you might have more luck because that can bind to file

extentions, but also there..its executed from within newlisp so i dot know

the outcome...
-- (define? (Cornflakes))

DrDave

#2
Quote from: "newdep"
Under windows you might have more luck because that can bind to file

extentions, but also there..its executed from within newlisp so i dot know

the outcome...

In windows, you associate file extensions with an application to enable launching the application and opening the file by double clicking the file name. I think when you install the OS that it has default  association of .html and .htm to Internet Explorer. However, the user can change it to any other application, or even remove any associations. If removed, when the file is double clicked, a dialog opens rather than an application launching.
...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