mIRC Home    About    Download    Register    News    Help

Print Thread
Alphabetic order #173736 28/03/07 09:24 PM
Joined: Oct 2006
Posts: 23
F
Frenatic Offline OP
Ameglian cow
OP Offline
Ameglian cow
F
Joined: Oct 2006
Posts: 23
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?

Re: Alphabetic order [Re: Frenatic] #173737 28/03/07 09:59 PM
Joined: Oct 2004
Posts: 8,327
Riamus2 Offline
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,327
Use /filter. It will allow you to easily sort a text file.

/filter -ffcut 1 32 textfile.txt textfile.txt


Invision Support
#Invision on irc.irchighway.net
Re: Alphabetic order [Re: Frenatic] #173738 28/03/07 10:06 PM
Joined: Aug 2004
Posts: 7,252
R
RusselB Offline
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
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.

Re: Alphabetic order [Re: Riamus2] #173740 28/03/07 10:11 PM
Joined: Aug 2004
Posts: 7,252
R
RusselB Offline
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
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.

Re: Alphabetic order [Re: Frenatic] #173742 28/03/07 10:26 PM
Joined: Oct 2006
Posts: 23
F
Frenatic Offline OP
Ameglian cow
OP Offline
Ameglian cow
F
Joined: Oct 2006
Posts: 23
thanks, everything works fine now smile

Re: Alphabetic order [Re: RusselB] #173745 28/03/07 10:59 PM
Joined: Oct 2004
Posts: 8,327
Riamus2 Offline
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,327
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.


Invision Support
#Invision on irc.irchighway.net
Re: Alphabetic order [Re: Riamus2] #173746 29/03/07 12:01 AM
Joined: Aug 2004
Posts: 7,252
R
RusselB Offline
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
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.

Re: Alphabetic order [Re: RusselB] #173747 29/03/07 01:22 AM
Joined: Oct 2004
Posts: 8,327
Riamus2 Offline
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,327
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.


Invision Support
#Invision on irc.irchighway.net
Re: Alphabetic order [Re: Riamus2] #174331 05/04/07 06:28 PM
Joined: Oct 2006
Posts: 23
F
Frenatic Offline OP
Ameglian cow
OP Offline
Ameglian cow
F
Joined: Oct 2006
Posts: 23
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

Re: Alphabetic order [Re: Frenatic] #174364 06/04/07 05:33 PM
Joined: Oct 2004
Posts: 8,327
Riamus2 Offline
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,327
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).


Invision Support
#Invision on irc.irchighway.net