ghoti - 2009-08-16

Easier said than done but while I'm looking at it consider using the database commands to do this. To access text files as database files you need a file called Schema.ini in the folder you'll have your text db. In it you need a section for each text file you'll want to use. The section looks like this:

[ClanDb.txt]
ColNameHeader = False
Format = CSVDelimited
CharacterSet = ANSI
Col1=ClanNumber short
Col2=ClanName char width 50
Col3=ClanLeader char width 20

Results of select statements run against databases go into arrays. For example:
if you hae a text file ClanDB.txt with:

1,"Circle of Power","Romsek"
2,"The White Rose","Gnoden"
3,"Presence","Ausjos"
5,"Legion of Legends","Wonac"

then
/sqlquery {select * from ClanDB.txt where clannumber >0}{clans}{txt:@sessionpath()}

creates an array called clans with 5 rows of 3 columns.

/loop {1,5,n}_
{/showme {@a(clans,$n,1) @a(clans,$n,2) @a(clans,$n,3)}}

You can create an empty file or delete the contents of an existing one with

/textout {@sesionpath()ClanDB.txt}{ }

An example of an action to fill a text file using db commands would be:

/action {[%0][ %1] %2}
{

/sqlexecute {insert into ClanDB.txt (ClanNumber, ClanName, ClanLeader) values ($0,'@Ltrim($2)','@Ltrim($1)')}
{txt:@sessionpath()}

}_
{clandb}

Of course if you were to do things like this you'd need to manage the action with disablegroup and enable group and clear the array with /unarray clans if you planned on using it repeatedly.