• Print

Author Topic: well a bit of VBScript solved a problem for me.  (Read 491 times)

DarthWho

  • Hero Member
  • *****
  • Posts: 3857
  • Timelord of the Sith
well a bit of VBScript solved a problem for me.
« on: November 04, 2012, 09:19:41 PM »
well I needed a way to open a new tab in a browser from my programs and this bit of VBScript was the solution I went with:
Code: [Select]
Option Explicit
Dim wsh
Dim args
args = WScript.Arguments(0)
Set wsh=WScript.CreateObject("WScript.Shell")
wsh.Run args
save that as "browser.vbs" (sans quotation marks of course)
and here is the BM file I use to call it:
Code: [Select]
SUB browser (strg$)
SHELL "browser.vbs " + CHR$(34) + strg$ + CHR$(34)
END SUB

Does anyone have another way to do this that is this easy to use?

(btw this is actually how i plan to provide the help options for the go engine I am still working on.
« Last Edit: November 04, 2012, 09:25:09 PM by DarthWho »
Rassilon: My lord Doctor; My lord Master; My lord DarthWho
The Doctor and the master at the same time :WHAT!?!?!

FastMath 1.1.0 released: http://dl.dropbox.com/u/12359848/fastmath.h

TerryRitchie

  • Hero Member
  • *****
  • Posts: 2269
  • FORMAT C:\ /Q /U /AUTOTEST (How to repair Win8)
    • Email
Re: well a bit of VBScript solved a problem for me.
« Reply #1 on: November 04, 2012, 09:29:35 PM »
That will work as long as strg$ contains an extension, such as .HTM or .HTML, that is associated with a browser.  If strg$ contains a text file, .TXT for example, Notepad will open it.

You may not even need to use the script. If you have a file called example.htm for example, you can simply type example.htm at the command prompt and the program associated with .HTM files, usually a browser, will open it.  In other words windows will send the file to the appropriate binary to open it.

The problem lies in the fact that perhaps some users will have .HTM files pointing elsewhere, such as to an HTML editor.

DarthWho

  • Hero Member
  • *****
  • Posts: 3857
  • Timelord of the Sith
Re: well a bit of VBScript solved a problem for me.
« Reply #2 on: November 04, 2012, 09:48:48 PM »
that is one of the problems that I took into account since I actually have a similar set up on one of my machines.
Rassilon: My lord Doctor; My lord Master; My lord DarthWho
The Doctor and the master at the same time :WHAT!?!?!

FastMath 1.1.0 released: http://dl.dropbox.com/u/12359848/fastmath.h

TerryRitchie

  • Hero Member
  • *****
  • Posts: 2269
  • FORMAT C:\ /Q /U /AUTOTEST (How to repair Win8)
    • Email
Re: well a bit of VBScript solved a problem for me.
« Reply #3 on: November 04, 2012, 10:02:54 PM »
I'll dig through my VBScript books sometime in the next few days and see if there is a way to force a file to open in a browser.  There most likely is through the combination of finding the correct registry entry for browsers installed and which one is the default along with its location.

SMcNeill

  • Hero Member
  • *****
  • Posts: 2440
    • Email
Re: well a bit of VBScript solved a problem for me.
« Reply #4 on: November 04, 2012, 10:34:51 PM »
See if this little bit of code helps:  http://www.mredkj.com/vbnet/OpenURL.html
http://bit.ly/TextImage -- Library of QB64 code to manipulate text and images, as a BM library.
http://bit.ly/Color32 -- A set of color CONST for use in 32 bit mode, as a BI library.

http://bit.ly/DataToDrive - A set of routines to quickly and easily get data to and from the disk.  BI and BM files

small no more

  • Sr. Member
  • ****
  • Posts: 258
  • Ask and you will receive, Seek and you will find
    • not launched
Re: well a bit of VBScript solved a problem for me.
« Reply #5 on: January 27, 2013, 02:04:24 AM »
this VBscript opens any program in the set default application


set wShell = CreateObject("Shell.Application")
wShell.Open "http://www.qb64.net"
A good teacher must be able to put himself in the place of those who find learning hard.


                                           Eliphas Levi

mcalkins

  • Hero Member
  • *****
  • Posts: 1279
    • qbasicmichael.com
    • Email
Re: well a bit of VBScript solved a problem for me.
« Reply #6 on: January 27, 2013, 07:23:05 AM »
Why not just use:
SHELL "http://www.qb64.net"

Regards,
Michael
The QBASIC Forum Community: http://www.network54.com/index/10167 Includes off-topic subforums.
QB64 Off-topic subforum: http://qb64offtopic.freeforums.org/

LeChuck

  • Hero Member
  • *****
  • Posts: 895
  • 18 * 37
Re: well a bit of VBScript solved a problem for me.
« Reply #7 on: January 27, 2013, 09:52:35 AM »
Nice one Michael, good to know. :)
Two or more, use a FOR!

Clippy

  • Hero Member
  • *****
  • Posts: 16446
  • I LOVE π = 4 * ATN(1)    Use the QB64 WIKI >>>
    • Pete's Qbasic Site
    • Email
Re: well a bit of VBScript solved a problem for me.
« Reply #8 on: January 27, 2013, 02:02:05 PM »
Qbasic could do that!
QB64 WIKI: Main Page
Download Q-Basics Code Demo: Q-Basics.zip
Download QB64 BAT, IconAdder and VBS shortcuts: QB64BAT.zip
Download QB64 DLL files in a ZIP: Program64.zip

mcalkins

  • Hero Member
  • *****
  • Posts: 1279
    • qbasicmichael.com
    • Email
Re: well a bit of VBScript solved a problem for me.
« Reply #9 on: January 27, 2013, 02:59:23 PM »
Quote from: Clippy on January 27, 2013, 02:02:05 PM
Qbasic could do that!

In QBASIC 1.1, you would use:
SHELL "cmd /c start http://www.qb64.net"

QB64's code for SHELL is complex. I believe that QB64's SHELL uses CreateProcess and/or ShellExecuteEx to run stuff. I suspect that ShellExecuteEx is what is succeeding for SHELL "http://www.qb64.net". However, my understanding of QB64's SHELL is very weak, so this is a guess.

Regards,
Michael
The QBASIC Forum Community: http://www.network54.com/index/10167 Includes off-topic subforums.
QB64 Off-topic subforum: http://qb64offtopic.freeforums.org/

Clippy

  • Hero Member
  • *****
  • Posts: 16446
  • I LOVE π = 4 * ATN(1)    Use the QB64 WIKI >>>
    • Pete's Qbasic Site
    • Email
Re: well a bit of VBScript solved a problem for me.
« Reply #10 on: January 27, 2013, 03:04:49 PM »
Supposedly QB64 SHELL does the "cmd /c" part already, but we have had occasion to need it anyway for some odd reason.

It doesn't hurt to use it anyhow.
QB64 WIKI: Main Page
Download Q-Basics Code Demo: Q-Basics.zip
Download QB64 BAT, IconAdder and VBS shortcuts: QB64BAT.zip
Download QB64 DLL files in a ZIP: Program64.zip

mcalkins

  • Hero Member
  • *****
  • Posts: 1279
    • qbasicmichael.com
    • Email
Re: well a bit of VBScript solved a problem for me.
« Reply #11 on: January 27, 2013, 03:46:04 PM »
But "cmd /c" would not be sufficient either. If you type:
http://www.qb64.net
On the cmd line, you get:

Quote
'http:' is not recognized as an internal or external command,
operable program or batch file.

The "start" is necessary also. I don't think QB64 is using start, so I believe that it is shell32.dll's ShellExecuteEx which is working (as opposed to kernel32.dll's CreateProcess).

Regards,
Michael
The QBASIC Forum Community: http://www.network54.com/index/10167 Includes off-topic subforums.
QB64 Off-topic subforum: http://qb64offtopic.freeforums.org/

  • Print