Possible to put URL links in Q basic just by question or have it open?

is it possibel to put a url link in a qbasic program or have it open a url in the browser using qbasic just by question? and if so how?

Comments

  • : is it possibel to put a url link in a qbasic program or have it open a url in the browser using qbasic just by question? and if so how?
    :

    Sure, you can run basically any program with QB by using the "SHELL" command to execute DOS commands. Most browsers will allow you to specify a URL as a parameter. For example, on my computer to open the Programmer's Heaven website from Internet Explorer, the DOS command is:

    "C:Program FilesPlus!Microsoft InternetIexplore.exe" "http://www.programmersheaven.com"

    And to open Netscape Navigator the command is:

    "C:Program FilesNetscapeCommunicatorProgram
    etscape.exe" -browser "http://www.programmersheaven.com"

    The directory paths might be slightly different for your computer. Of course, you can take out the quotation marks and write the paths in the old DOS format (ie, C:PROGRA~1PLUS~1...etc...) - its up to you. So to load the website in IE using QBASIC, I would type:

    SHELL CHR$(34) + "C:Program FilesPlus!Microsoft InternetIexplore.exe" + CHR$(34) + " " + CHR$(34) + "http://www.programmersheaven.com" + CHR$(34)

    Please note that ASCII character 34 (ie. "CHR$(34)") is the character for a quotation mark. The same thing in Netscape would be:

    SHELL CHR$(34) + "C:Program FilesNetscapeCommunicatorProgram
    etscape.exe" + CHR$(34) + " -browser " + CHR$(34) + "http://www.programmersheaven.com" + CHR$(34)

    This command opens doors to all sorts of cool programs you can write. For example, download the file CDT.EXE from:

    http://www.amtechdisc.com/max/comp/archive/

    This program lets you use DOS commands on your CD-ROM. For example, you can open/close the tray, lock it shut, play tracks, and a whole bunch of other things. With a bit of creativity you can create your own CD player software.

    By the way, I didn't test this code before I posted it so let me know if it worked!

  • Alister is correct. However, for lots of users, ie and nn may not be installed into their default locations, so get the url, such as http://www.programmersheaven.com, and then

    url$ = "http://www.programmersheaven.com"
    open "temp.url" for output as #1
    print #1, "[InternetShortcut]"
    print #1, "URL=" + url$
    close #1
    shell "start temp.url"

    Start is flexible in it's tasks. It can start a windows program, or an ms-dos program. But, what can you do about non-programs, eg url files, or .bmp files? Just START them.

    Start IMAGE.JPG

    To begin with, start would query windows to find out what program is associated with the .JPG extension.

    In my case, the .jpg and .jpeg extensions are associated with
    "C:PROGRA~1INTERN~1iexplore.exe" -nohome

    Now, when I start the .jpg file, windows finds and starts iexplore.exe for me, and passes along whatever file I wanted to the call that it's making. The result is a .jpg opened from the command line. Not bad. Here's the syntax for start:


    Runs a Windows program or an MS-DOS program.

    START [options] program [arg...]
    START [options] document.ext

    /m[inimized] Run the new program minimized (in the background).
    /max[imized] Run the new program maximized (in the foreground).
    /r[estored] Run the new program restored (in the foreground). [default]
    /w[ait] Does not return until the other program exits.

    Ok, check this out. If I wrote a program in C++ that played a .wav file for me using SNDPLAYSOUND, I could
    start /m /w myfile.exe C:windowsmediawav.wav
    and the wav.wav file would play. see the parameters? wav.wav would play, then return to the program, and the myfile.exe would be minimized in the background, so the current program would not be brought down to the taskbar to display the new program.

    In summary, start can be used to start executable files (programs), as well as files that are properly associated with windows.

  • Start only works when windows is active, because it's a WIN32 program.

  • Thanks for the tip. I also found when I tried this out myself that you can just type "start http://www.programmersheaven.com/" and it starts automatically, you don't need to create a URL file. Does creating a URL file have any advantages?

    Just another point on that topic - if you are creating a program that needs to access the Windows directory, DOS now has shortcuts so you don't even need to know the name of the directory. This is good because the windows directory has different names on different versions of Windows (eg. it could be win, windows, winnt, etc). You can access this directory simply by specifying %windir% as the path.

    For example, get into DOS onto the same disk drive as you have Windows installed (eg. C:) and then type "cd %windir%", and you should change directories into your Windows directory. Try this command in QBASIC, and it should pop up Notepad:

    SHELL CHR$(34) + "%windir%
    ote.com" + CHR$(34)

    Theres a couple other directories that you can do this with. One of them is %temp% - this is the directory your computer uses for temporarily storing files, such as during installation of software. I'm not sure what the other ones are

    : Alister is correct. However, for lots of users, ie and nn may not be installed into their default locations, so get the url, such as http://www.programmersheaven.com, and then
    :
    : url$ = "http://www.programmersheaven.com"
    : open "temp.url" for output as #1
    : print #1, "[InternetShortcut]"
    : print #1, "URL=" + url$
    : close #1
    : shell "start temp.url"
    :
    : Start is flexible in it's tasks. It can start a windows program, or an ms-dos program. But, what can you do about non-programs, eg url files, or .bmp files? Just START them.
    :
    : Start IMAGE.JPG
    :
    : To begin with, start would query windows to find out what program is associated with the .JPG extension.
    :
    : In my case, the .jpg and .jpeg extensions are associated with
    : "C:PROGRA~1INTERN~1iexplore.exe" -nohome
    :
    : Now, when I start the .jpg file, windows finds and starts iexplore.exe for me, and passes along whatever file I wanted to the call that it's making. The result is a .jpg opened from the command line. Not bad. Here's the syntax for start:
    :
    :
    : Runs a Windows program or an MS-DOS program.
    :
    : START [options] program [arg...]
    : START [options] document.ext
    :
    : /m[inimized] Run the new program minimized (in the background).
    : /max[imized] Run the new program maximized (in the foreground).
    : /r[estored] Run the new program restored (in the foreground). [default]
    : /w[ait] Does not return until the other program exits.
    :
    : Ok, check this out. If I wrote a program in C++ that played a .wav file for me using SNDPLAYSOUND, I could
    : start /m /w myfile.exe C:windowsmediawav.wav
    : and the wav.wav file would play. see the parameters? wav.wav would play, then return to the program, and the myfile.exe would be minimized in the background, so the current program would not be brought down to the taskbar to display the new program.
    :
    : In summary, start can be used to start executable files (programs), as well as files that are properly associated with windows.
    :


  • No specific advantages, but a URL file could help you define more complex site names, as the command line buffer for dos is limited. Also, if you have escape characters in the url string, dos might read these wrong. It's best to go with a temp url file, then kill the file, just to make sure everything's matching up. Or, just type the url on the command line. Either way works.

    A note about the %windir% thing you found, when working with batch files, you must do %%parameter%%, because %param% will be seen as an errorlevel return. Qbasic and batch files don't go near eachother most of the time, that was just FYI.


Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories