Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sorting a QB45 file

Status
Not open for further replies.

Komaru

Programmer
Jul 29, 2010
6
Let me briefly explain: I'm writing a little tool that will help me to create text based adventure games using an engine I wrote a few years back. The problem is, sometimes a line will be printed out of order (because otherwise I would have to plan everything in advance). Here's an example of what I mean:
10 PRINT "One ";
30 PRINT "Three ";
20 PRINT "Two ";
And QBASIC will read this and print "One Three Two ", as opposed to "One Two Three".

So is there any batch file, or QB code that I can use to sort the line numbers of my generated BAS files? I would greatly appreciate the help! Thanks in advance,
~Komaru
 
If all lines are numbered, then just put the line numbers in an array and sort them. There are lots of sort routines around. You could even use the dos sort if thats available on your os. If you use the sorted array approach, once sorted, go back and check the line up to len of the array versus the array and write it to another file or print.

If you are using QuickBasic then be sure to save the original program as a text file.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top