Using QBASIC's indexing would be faster/"better"by (no login)QBASIC has sort very effective indexing methods when working with files open for RANDOM reading & writing. First, you will need to convert the existing text file into a RANDOM access file, which is stored in a special format. Here's how to perform the conversion: OPEN mynewfilename$ for RANDOM AS #2 LEN=1000 'change 1000 to the maximum line width in characters required, or just a big number if you're not sure! OPEN myfilename$ for INPUT AS #1 DO WHILE EOF(1)=0 LINE INPUT #1,theline$ PUT #2,,theline$ numlines=numlines+1 LOOP CLOSE #1 Now that the file is converted, access it in the following way: GET #2,5,gotline$ 'stores the contents of line 5 into gotline$ GET #2,numlines,gotline$ 'stores the contents of the last line into gotline$ savethis$="hello" PUT #2,2,savethis$ 'overwrites line 5 with the string hello numlines=numlines+1 PUT #2,numlines,savethis$ 'add a new line with the string hello The file has been edited, so now it will be saved back into its original format: OPEN mysavefilename$ for OUTPUT AS #1 FOR i=1 to numlines GET #2,i,myline$ PRINT #1,myline$ NEXT CLOSE #1 from IP address 122.104.43.249 |