Back before QB, when Microsoft Basic was called GWBASIC, you needed to write your programs with line numbers. The line numbers preceeded each statement and had a space before the code. Example:
100 a = 100
200 for x = 1 to 20
There was a utility program that came with GWBASIC for reassigning (renumbering) the line numbers. I can't remember the name.
Anyway, this utility assumed that that the code already had line numbers. Since your code doesn't have any line numbers to start with, it wouldn't do you any good.
Why do you want to put line numbers in your code?
Do you really want a ":" after the line number?
Do you really want the line numbers to be in increments of 1?
Here's a sample program to do it. OLDPROG.BAS is the filename of the original code that you want to put line numbers into. NEWPROG.BAS is the new code with the inserted line numbers. Yes, I already tested it.
Code: Select all
open "OLDPROG.BAS" for input as #1
open "NEWPROG.BAS" for output as #2
linenum=0
do while not eof(1)
line input #1, d$
linenum=linenum+1
newd$=ltrim$(str$(linenum))+":"+d$
print #2,newd$
loop
system
Note: The above is not suppressing any leading blanks that your original code lines might have. If you want to suppress these, then where it has "+d$" change to "+ltrim$(d$).
*****
If you are ahead of me, lead.
If you are behind me, follow.
If you are not doing anything,
Get out of the way.