Can I create line numbers for a QBASIC program and reconvert it to a program without

Discussion in 'Programmer's Corner' started by lemuel rapsuk, Sep 2, 2006.

  1. lemuel rapsuk

    Thread Starter New Member

    Sep 1, 2006
    3
    0
    Why did GW BASIC used line numbers but not QBASIC? How did this change take place?
    Can I create line numbers for a QBASIC program in one-shot - that is, save the file as a QBASIC program, then next time I open it as a file with line numbers.
    And again next time probably reconvert it to a program without line numbers and on and on and on.
    Lemuel Rapsuk
     
  2. beenthere

    Retired Moderator

    Apr 20, 2004
    15,815
    282
    Hi,

    Qbasic was a new application that did not need line numbers, although it permitted the use of them.

    The editor will let you use line numbers, but you would have to manually delete them manually.

    Qbasic is very dated. The editor is the best ever created, something that Microsoft just let fall by the wayside when they went to the awkward Visual Basic. Why would you want to use line numbers, though? The GOTO structure is really pretty ugly. There are more elegant structures present in Qbasic.
     
  3. Joe S.

    Member

    Aug 28, 2006
    10
    0
    CNC machines use g code which is essentially just a text file.
    It is possible to cut and paste your program into a cnc program like DeskKam
    and use it to number your code lines, then cut and paste into notepad, remove the N at the beginning of each line and voila, you have it.
     
  4. markm

    Member

    Nov 11, 2008
    16
    0
    In Excel or Open Office, import the program as a text file. The spreadsheet will want to interpret spaces, tabs, or commas as separating lines into columns, so you have to change the import settings until it all comes in as one huge wide column.

    Add another column in front of the program text column. Fill it with a number series. (There are settings controlling this, too, so you can select a starting number and an increment of 10, for instance.) Now you've got your lines starting with line numbers, you've just got to get it out to a text file without Excel fouling it up. There's a few things you could try:

    1) Export to a text file. Set it for no separator character between columns and a fixed width for column 1. I hope this will give you a space fill between the line numbers and the start of the program line so all your text lines up.

    2) Create another spreadsheet page. In the top left block, enter a formula appending the first line number to the first program line. (Spreadsheets are pretty forgiving of mixed data types and will convert the numbers to strings. However, there are conversion functions you can use if the default format isn't right.) Ampersand ("&") concatenates strings, and you might need to add a string with a space in between. Once you get the first one right, you can drag your formula down through all the other cells, or if it's many pages long it might be faster to use the fill/series menu commands again. Once it's complete, export this page to a text file, exporting values, not formulas.
     
  5. beenthere

    Retired Moderator

    Apr 20, 2004
    15,815
    282
    Thank you for the input. The original thread is 2 years old, though, and the OP has long since gone away.
     
Loading...