Author Topic: URL Website Browser Loader  (Read 4533 times)

0 Members and 1 Guest are viewing this topic.

Offline SierraKen

  • Forum Resident
  • Posts: 1454
    • View Profile
URL Website Browser Loader
« 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.  

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: URL Website Browser Loader
« Reply #1 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.
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline SierraKen

  • Forum Resident
  • Posts: 1454
    • View Profile
Re: URL Website Browser Loader
« Reply #2 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.

Offline TempodiBasic

  • Forum Resident
  • Posts: 1792
    • View Profile
Re: URL Website Browser Loader
« Reply #3 on: August 10, 2019, 05:20:54 pm »
Well
we need only that somebody  says us how to do for MAC/OS
Programming isn't difficult, only it's  consuming time and coffee

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: URL Website Browser Loader
« Reply #4 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. 
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline pforpond

  • Newbie
  • Posts: 76
  • I am me
    • View Profile
Re: URL Website Browser Loader
« Reply #5 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.  
Loading Signature...