QB64.org Forum

Active Forums => Programs => Topic started by: SierraKen on August 09, 2019, 12:38:03 am

Title: URL Website Browser Loader
Post by: SierraKen on August 09, 2019, 12:38:03 am
I'm sure you guys have talked about this before. But it's all new to me :). Tonight I found out how to load a website address URL from QB64 to your default web browser by using the SHELL command. Here is my little example program. It uses the START command built into Windows.

Code: QB64: [Select]
  1. _TITLE "URL Website Browser Loader"
  2. PRINT "URL Website Browser Loader"
  3. PRINT "Type URL here to load with your default browser."
  4. INPUT "-> ", u$
  5. SHELL "START " + u$
  6.  
Title: Re: URL Website Browser Loader
Post by: SMcNeill on August 09, 2019, 12:53:00 am
                INPUT url$
                IF INSTR(_OS$, "[WINDOWS]") THEN
                    SHELL url$
                ELSE
                    SHELL "xdg-open " + url$
                END IF

Use the above to open web pages in both Windows and Linux.
Title: Re: URL Website Browser Loader
Post by: SierraKen on August 09, 2019, 12:30:07 pm
That's interesting, you also don't use the START command and it works fine in Windows. I just tried putting just a URL in Windows Command Prompt and it won't work that way lol. Pretty cool.
Title: Re: URL Website Browser Loader
Post by: TempodiBasic on August 10, 2019, 05:20:54 pm
Well
we need only that somebody  says us how to do for MAC/OS
Title: Re: URL Website Browser Loader
Post by: SMcNeill on August 10, 2019, 05:42:22 pm
Well
we need only that somebody  says us how to do for MAC/OS

SHELL "xdg-open " + url$ works for MAC as well as Linux, I believe. 
Title: Re: URL Website Browser Loader
Post by: pforpond on August 11, 2019, 06:22:11 am
SHELL "xdg-open " + url$ works for MAC as well as Linux, I believe. 
Regretfully xdg-open does not function on MacOS, at least the latest version (10.14.6) anyway.

I've figured the solution for MacOS :)
Code: QB64: [Select]
  1.                 INPUT url$
  2.                 IF INSTR(_OS$, "[WINDOWS]") THEN
  3.                     SHELL url$
  4.                 END IF
  5.                 IF INSTR(_OS$, "[LINUX]") THEN
  6.                     SHELL "xdg-open " + url$
  7.                 END IF
  8.                 IF INSTR(_OS$, "[MACOSX]") THEN
  9.                     SHELL "open -a safari https://" + url$
  10.                 END IF
  11.