mIRC Homepage
Posted By: Frenatic Alphabetic order - 28/03/07 09:24 PM
are there any way to sort the content of a list in alphabetic order?

this is what I got so far:

Code:
on *:TEXT:*:#: { 

  if ($strip($1) == !game ) {
    msg $chan 3URL/games
  } 

  if ($strip($$1) == !addgame) { 
    write C:\..\games.txt  $3- :: added by $nick $+ <br />
    msg $chan 3done
  }
}


and then I got the text file loaded to a .asp file

Code:
<div class="box">
<h2>games</h2>
<!--#include file="games.txt"-->
</div>


what i now want is to sort the content of the 'games.txt'
im not forced to use a .txt file, but I need to be able to load it in a .asp file

anyone got any ideas of how you can do this?
Posted By: Riamus2 Re: Alphabetic order - 28/03/07 09:59 PM
Use /filter. It will allow you to easily sort a text file.

/filter -ffcut 1 32 textfile.txt textfile.txt
Posted By: RusselB Re: Alphabetic order - 28/03/07 10:06 PM
I don't know if the format of a .asp file would prevent this from being able to be used directly, but if it's the same as a text file, or if you can use a text file instead, then I would recommend using /filter

Code:
/filter -ffb c:\..\games.txt c:\..\games.txt *


Note: I haven't used /filter much, so this is based upon what I have read in the help file.
Posted By: RusselB Re: Alphabetic order - 28/03/07 10:11 PM
Since the OP was asking about an alphabetic sort, I have to wonder about the inclusion of the u switch, which, from the help file, is used for a numeric sort.
Also, based on the code the OP presented, it looks like each game is written to a different line in the text file, making the t switch irrelevant, since the sort would be on the full game name, not just the first word of the name.

As I said in my post, I haven't used /filter much, so if I'm mistaken, I would appreciate clarification.
Posted By: Frenatic Re: Alphabetic order - 28/03/07 10:26 PM
thanks, everything works fine now smile
Posted By: Riamus2 Re: Alphabetic order - 28/03/07 10:59 PM
I put "u" because it works with alpha-numeric text. A game can easily start with numbers instead of letters.

As for the "t", I tried without and it didn't want to work. I rarely use /filter either, so I'm probably doing something wrong.
Posted By: RusselB Re: Alphabetic order - 29/03/07 12:01 AM
OK..the help file, as I said, states that that u switch is for a numeric sort...that probably should be updated to read alpha-numeric.
Posted By: Riamus2 Re: Alphabetic order - 29/03/07 01:22 AM
Well, both are alpha-numeric. It's a matter of whether it looks at the full number to sort or just the first digit.

Example:
Originally Posted By: test.txt

4 this
40 is
a
199 test
of
87 the
0 emergency
121 broadcast
9 system


/filter -ffct test.txt test.txt

Result:
Quote:
0 emergency
121 broadcast
199 test
4 this
40 is
87 the
9 system
a
of


/filter -ffcut test.txt test.txt

Result:
Quote:
0 emergency
4 this
9 system
40 is
87 the
121 broadcast
199 test
a
of


Notice that without -u, it will sort per character (121 is before 40 because 1 is before 4). With the -u, the sort will sort based on the actual number (40 is before 121).

I do agree that a better explanation in the help file would be good.
Posted By: Frenatic Re: Alphabetic order - 05/04/07 06:28 PM
I tried to make the script a bit more advanced, but ran into some problem.

im linkin the textfile where I save all the added lines into a webpage, and filtering it with
Code:
 filter -ffcut 1 32 

and it worked great, but then I tried to add links and simple html code to it
Code:
<a href="LINK" target="_blank">TEXT</a><br />


the problem is the filtering starts to filter the link in that scentence, not the text.

and the code im adding into the filtered textdocument are
Code:
 <a href=" $+ $2 $+ " target="_blank"> $+ $3- $+ </a>


so now I wonder if there are some way to start the filtering at the third word ( $3- ), or some other way around the problem
Posted By: Riamus2 Re: Alphabetic order - 06/04/07 05:33 PM
The 1 in the filter command you showed is the word number. Change it to 3 if you want to do the 3rd space-delimited item (i.e. word).
© mIRC Discussion Forums