iDevGames Forums
Is there a system call to open HTML file programatically? - Printable Version

+- iDevGames Forums (http://www.idevgames.com/forums)
+-- Forum: Development Zone (/forum-3.html)
+--- Forum: Game Programming Fundamentals (/forum-7.html)
+--- Thread: Is there a system call to open HTML file programatically? (/thread-4982.html)



Is there a system call to open HTML file programatically? - WhatMeWorry - Sep 28, 2005 12:08 AM

Is there a way (like some system call) to simply open up an HTML file
programatically from within an application which the user could read,
and then close off and return to the application from where the HTML
file was invoked?

I've been poking around Apple's documentation but I'm not finding
anything.


Is there a system call to open HTML file programatically? - akb825 - Sep 28, 2005 01:06 AM

Um, fopen/scanf?


Is there a system call to open HTML file programatically? - OneSadCookie - Sep 28, 2005 01:26 AM

Er, what? Ask questions in English Rasp


Is there a system call to open HTML file programatically? - BeyondCloister - Sep 28, 2005 01:55 AM

This is what I use in my Cocoa code for displaying a HTML file from my program in the default web browser.

Code:
[[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:@"http://www.url.co.uk/whatever.html"]];


or this code will open a HTML in the default program for viewing HTML files

Code:
[[NSWorkspace sharedWorkspace] openFile:@"filepath/filename.html"];

However you have to be careful with this as on my computer GoLive is the default application for viewing HTML files opened this way.


Is there a system call to open HTML file programatically? - Fenris - Sep 28, 2005 01:59 AM

I think you mean that the HTML file is opened in Safari or something, right? You could try issuing a system call with "open path/to/my/file"... I dug around the Cocoa docs for a while, but strangely I couldn't find anything.


Is there a system call to open HTML file programatically? - OneSadCookie - Sep 28, 2005 02:37 AM

in Cocoa, NSWorkspace handles opening files and URLs in other applications, in Carbon LaunchServices does the same. LaunchServices has a couple more features than NSWorkspace, so it may occasionally be necessary to use LS from Cocoa (not that that's hard, given the toll-free bridging of CFString<->NSString and CFURL<->NSURL).


Is there a system call to open HTML file programatically? - WhatMeWorry - Sep 28, 2005 03:15 PM

I've got a C++ application. Don't want to use Carbon. Tried just sticking
the [[NSWorkspace sharedWorkspace] openFile:@"filepath/filename.html"];
into it with this header that I got by looking at a Cocoa template project
in Xcode.

#import <Cocoa/Cocoa.h>

I get 9,742 errors which I belive is a record for me Smile

I don't know one iota about objective C. Come to think of it, I don't even know
what an iota is Smile

Is it possible to incorporate this snippet of objective c into a C++ application?
If it is trivial, could someone just post the code. I'm thinking it might be about
a long as a "hello world" program, but then I could be wrong here as well.


Is there a system call to open HTML file programatically? - akb825 - Sep 28, 2005 04:14 PM

If it's just a file localized on your HDD, I still recommend using fopen and fread.


Is there a system call to open HTML file programatically? - Steven - Sep 28, 2005 05:17 PM

If you don't want to use Carbon or Cocoa, use Fenris's idea:
Code:
system("open /path/to/myfile.html");



Is there a system call to open HTML file programatically? - BeyondCloister - Sep 28, 2005 05:17 PM

akb825 Wrote:If it's just a file localized on your HDD, I still recommend using fopen and fread.

Using this method you would need to have something in your application for rendering the HTML.

I think what he is asking for is a method to allow an external application designed for the purpose to do it.


Is there a system call to open HTML file programatically? - akb825 - Sep 28, 2005 05:41 PM

I thought he was asking how to just show the code. I'm wondering if there's a class that just takes text and renders the HTML, though. (since I know there are HTML classes in Carbon and Cocoa)


Is there a system call to open HTML file programatically? - WhatMeWorry - Sep 28, 2005 05:47 PM

Bingo. "...Renders the HTML" That's what I should of said.


Is there a system call to open HTML file programatically? - Steven - Sep 28, 2005 05:54 PM

WebKit might be the way to go...