mIRC Home    About    Download    Register    News    Help

Topic Options
#173736 - 28/03/07 10:24 PM Alphabetic order
Frenatic Offline
Ameglian cow

Registered: 10/10/06
Posts: 23
Loc: sweden
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?

Top
#173737 - 28/03/07 10:59 PM Re: Alphabetic order [Re: Frenatic]
Riamus2 Offline
Planetary brain

Registered: 13/10/04
Posts: 8327
Loc: MA, USA
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

Top
#173738 - 28/03/07 11:06 PM Re: Alphabetic order [Re: Frenatic]
RusselB Offline
Planetary brain

Registered: 03/08/04
Posts: 7252
Loc: Ontario, Canada
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.

Top
#173740 - 28/03/07 11:11 PM Re: Alphabetic order [Re: Riamus2]
RusselB Offline
Planetary brain

Registered: 03/08/04
Posts: 7252
Loc: Ontario, Canada
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.

Top
#173742 - 28/03/07 11:26 PM Re: Alphabetic order [Re: Frenatic]
Frenatic Offline
Ameglian cow

Registered: 10/10/06
Posts: 23
Loc: sweden
thanks, everything works fine now smile

Top
#173745 - 28/03/07 11:59 PM Re: Alphabetic order [Re: RusselB]
Riamus2 Offline
Planetary brain

Registered: 13/10/04
Posts: 8327
Loc: MA, USA
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

Top
#173746 - 29/03/07 01:01 AM Re: Alphabetic order [Re: Riamus2]
RusselB Offline
Planetary brain

Registered: 03/08/04
Posts: 7252
Loc: Ontario, Canada
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.

Top
#173747 - 29/03/07 02:22 AM Re: Alphabetic order [Re: RusselB]
Riamus2 Offline
Planetary brain

Registered: 13/10/04
Posts: 8327
Loc: MA, USA
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

Top
#174331 - 05/04/07 07:28 PM Re: Alphabetic order [Re: Riamus2]
Frenatic Offline
Ameglian cow

Registered: 10/10/06
Posts: 23
Loc: sweden
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

Top
#174364 - 06/04/07 06:33 PM Re: Alphabetic order [Re: Frenatic]
Riamus2 Offline
Planetary brain

Registered: 13/10/04
Posts: 8327
Loc: MA, USA
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

Top