Opening a browser/URL on Mac
BlitzMax Forums/BlitzMax Programming/Opening a browser/URL on Mac
| ||
I searched around here a little, searched the internet and crawled the BlitzMax docs ... and came up totally empty. Does anyone know how to open a URL from within a BlitzMax app? I know there are lots of Windows specific hacks, but I really need this to work on the Mac. Any ideas out there? |
| ||
OpenURL has been added to System for the next release, here's the objective C code:int bbOpenURL( const char *aurl ){ NSURL *url; int res; res=0; url=[NSURL URLWithString:[NSString stringWithCString:aurl]]; if (url) res=[[NSWorkspace sharedWorkspace] openURL:url]; return res; } |
| ||
Compiling:OpenURL.m /Volumes/c-1/BlitzMax/OpenURL.m: In function `bbOpenURL': /Volumes/c-1/BlitzMax/OpenURL.m:2: error: `NSURL' undeclared (first use in this function) /Volumes/c-1/BlitzMax/OpenURL.m:2: error: (Each undeclared identifier is reported only once /Volumes/c-1/BlitzMax/OpenURL.m:2: error: for each function it appears in.) /Volumes/c-1/BlitzMax/OpenURL.m:2: error: `url' undeclared (first use in this function) /Volumes/c-1/BlitzMax/OpenURL.m:5: error: `NSString' undeclared (first use in this function) /Volumes/c-1/BlitzMax/OpenURL.m:6: error: `NSWorkspace' undeclared (first use in this function) Build Error: failed to compile /Volumes/c-1/BlitzMax/OpenURL.m:( |
| ||
I'm not at my own computer right now, so can't test this, but I assume you need to add it to... "BlitzMax\mod\brl.mod\system.mod\system.macos.m". Back it up before trying! |
| ||
I don't think I am actually understanding what you want. To open a browser from a bmax app? system_("open /Applications/Safari.app http://www.blitzmax.com") To open a remote URL from in order to present content in you app? Straight from the documentation: ' readstream.bmx ' opens a read stream to the blitzbasic.com website and ' dumps the homepage to the console using readline and print in=ReadStream("http::blitzbasic.com") If Not in RuntimeError "Failed to open a WriteStream to file mypage.htmlhttp::www.blitzbasic.com" While Not Eof(in) Print ReadLine(in) Wend CloseStream in ... anyway, hope you find whatever you are actually looking for... PLS |
| ||
pls Huh, yeah, that works. I could swear I tried that but apparently not! This works as well... system_("open http://www.blitzmax.com")Thanks! |
| ||
I tried system_("open /Applications/Safari.app/Contents/MacOS/Safari www.blitzmax.com") and system_("open www.blitzmax.com") Both complain about the path being wrong.Try pasting either of the above into BMax and building and executing. |
| ||
Don't know what to say. Worked for me... |
| ||
system_("open /Applications/Safari.app/Contents/MacOS/Safari www.blitzmax.com") doesn't work.I ran safari from the command line and it attempts to open file:///Applications/Safari.app/Contents/MacOS/www.google.com as I forgot the http:// system_ "open /bin/bash /sbin/ifconfig" works nicely as does system_ "open /Applications/Safari.app http://www.yahoo.com" Using brackets () doesn't work under Mac os X. |