Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: QBASIC Help  (Read 5173 times)

0 Members and 1 Guest are viewing this topic.

CosmicFlux

    Topic Starter


    Rookie

    QBASIC Help
    « on: July 25, 2008, 04:35:40 AM »
    Hey,

    I have an idea for a program, but I'm unsure as to how QBASIC would do this. I want to have:

    Type <R> to read from drive A... etc.

    And then using the SHELL statement access the drive, redirect the contents to a file and then print the contents of the file to stdout in a format that I choose. Maybe in a box or grid and aligned to the middle. So far I have the output of DIR A: redirected to a .txt file but I don't know how to use the OPEN statement to get the file placed in the variable.

    Anyone help?

    I know QBASIC is vintage stuff, but it's fun to mess around with it and learn stuff .

    Dias de verano

    • Guest
    Re: QBASIC Help
    « Reply #1 on: July 25, 2008, 06:02:27 AM »
    This belongs in the Programming forum.

    Dusty



      Egghead

    • I could if she would, but she won't so I don't.
    • Thanked: 75
    • Experience: Beginner
    • OS: Windows XP
    Re: QBASIC Help
    « Reply #2 on: July 27, 2008, 01:37:29 AM »
    Which version of QBasic are you using?
    One good deed is worth more than a year of good intentions.

    Dias de verano

    • Guest
    Re: QBASIC Help
    « Reply #3 on: July 27, 2008, 01:46:05 AM »
    Yes. There's the QBasic ide / interpreter which comes with MS-DOS & Windows 95/98/ME, and there's QuickBasic (various versions).

    CosmicFlux

      Topic Starter


      Rookie

      Re: QBASIC Help
      « Reply #4 on: July 28, 2008, 02:31:42 AM »
      I'm using the Qbasic IDE with MS-DOS 7.10.

      Dusty



        Egghead

      • I could if she would, but she won't so I don't.
      • Thanked: 75
      • Experience: Beginner
      • OS: Windows XP
      Re: QBASIC Help
      « Reply #5 on: July 28, 2008, 04:13:57 AM »
      As you have the latest and greatest MS-Dos version I will assume you have QuickBasic ver 4.5.

      At the top RH corner you will see "Help" which gives access to the QuickB help file.  Access the Open command in the index and you will find a great screed about how files are opened..   I have attached two screen images from it to make things simple for you.  The first image (Open) shows the latest way of opening a file in QuickB, the second (Open1) which I prefer to use when Access and Lock are not required,  shows an older version which is included for backward compatibility with QB.

      The simplest command to open a sequential Input file (see Open1) is IMHO:
      OPEN "I", #1, "Path\Filename"

      Good luck



      [recovering disk space -- attachment deleted by admin]
      One good deed is worth more than a year of good intentions.

      Dias de verano

      • Guest
      Re: QBASIC Help
      « Reply #6 on: July 28, 2008, 10:28:35 AM »
      QuickBasic 4.5 is the last version of the commercial Microsoft BASIC ide & compiler which can make .exe files. Qbasic is the cut down product provided as part of MS-DOS and Windows 9x. It cannot make exe files. I think it is clear that CosmicFlux has the latter.

      Dusty



        Egghead

      • I could if she would, but she won't so I don't.
      • Thanked: 75
      • Experience: Beginner
      • OS: Windows XP
      Re: QBASIC Help
      « Reply #7 on: July 28, 2008, 04:42:06 PM »
      QuickBasic 4.5 is the last version of the commercial Microsoft BASIC ide & compiler which can make .exe files. Qbasic is the cut down product provided as part of MS-DOS and Windows 9x. It cannot make exe files. I think it is clear that CosmicFlux has the latter.

      Then he has the perfect reason to upgrade...
      One good deed is worth more than a year of good intentions.

      CosmicFlux

        Topic Starter


        Rookie

        Re: QBASIC Help
        « Reply #8 on: July 30, 2008, 02:07:02 AM »
        I know how to use the OPEN statement, I'm just unsure of the string that I'd use to read the contents of a file and display them on the screen.

        I'll have another look!

        Thanx!

        Oh, the IDE says MS-DOS QBasic version 1.1. Should I get 4.5?


        Dusty



          Egghead

        • I could if she would, but she won't so I don't.
        • Thanked: 75
        • Experience: Beginner
        • OS: Windows XP
        Re: QBASIC Help
        « Reply #9 on: July 30, 2008, 02:38:16 AM »
        Oh, the IDE says MS-DOS QBasic version 1.1. Should I get 4.5?

        Certainly, why drive a Skoda when you could be behind the wheel of a RR?

        How you input the contents of the file depends on its format, you could start by looking at the Input and Line Input commands in the Help file.

        Good luck

        One good deed is worth more than a year of good intentions.

        Dias de verano

        • Guest
        Re: QBASIC Help
        « Reply #10 on: July 30, 2008, 04:50:49 AM »
        You should know that QBasic 4.5 is a Microsoft copyright product and the only legal way to get it is to buy a floppy install set e.g. on Ebay.

        To open a text file and display it on screen

        Code: [Select]
        open "I", 1, "myfile.txt"
        REM alternative format of OPEN command
        REM open "myfile.txt" for input as #1
        do
             if eof (1) exit do
             line input #1, l$
             print l$
        loop
        close 1