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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

sorting lines in a text file 2

Status
Not open for further replies.

coldan

Programmer
Oct 19, 2008
98
AU
I have an ini style text file that I wish to sort entries in alpha order before I display the values of the items on screen.

This will make it more readable and will group like items together eg
Flagname
FlagValue
Log
TestValue

etc

I have filter.txt with the lines in it.

Thanks

Coldan
 
First, copy the file to an array (use FILETOSTR() to copy it to a string, then ALINES() to get the individual lines into the array).

Then use ASORT() to sort the array. Finally, loop through the array, displaying the lines you are interested in.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro tips, advice, training, consultancy
Custom software for your business
 
You can append from to a cursor and use SQL to sort it. ie:

Code:
create cursor myIni (myLine c(254))
append from filter.txt typed sdf
select myLine from myIni order by myLine

Cetin Basoz
MS Foxpro MVP, MCP
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top