mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Dec 2002
Posts: 111
E
Vogon poet
OP Offline
Vogon poet
E
Joined: Dec 2002
Posts: 111
Well, actually 2 stupid questions.

1. I am attempting to create a simple script that will read in a text file full of lines, and output only the first word of each line into another text file, with spaces being the obvious delimeters. I have attempted to use $matchtok but that did not work because I do not know the ascii value for a space and cant find it anywhere. I use to be kick-ass at scripting a couple years ago but have sence gotten out of it and its showing now smirk

also,

2. Even if $matchtok isnt the way to go, what is the ascii value for a space just for my future knowledge?

thanks for your help!

Joined: Jun 2003
Posts: 5,024
M
Hoopy frood
Offline
Hoopy frood
M
Joined: Jun 2003
Posts: 5,024
$chr(32)

Regards,


Mentality/Chris
Joined: Aug 2004
Posts: 16
S
Pikka bird
Offline
Pikka bird
S
Joined: Aug 2004
Posts: 16
Also, for future reference, if you need the ascii value for a character, use the $asc identifier. It won't work for a few characters, such as space and ), but for a majority of characters it should work =)


Smay!
Joined: Dec 2002
Posts: 111
E
Vogon poet
OP Offline
Vogon poet
E
Joined: Dec 2002
Posts: 111
hrm well, this is my code and here is the error im getting:

Code:
alias text { 
  set %list $read(list.txt)
  set %echoit $matchtok(%list, 1, $chr(32))
  echo %list
  echo %echoit
}


* Too few parameters: $matchtok (line 3, script.ini)


smirk


Joined: Dec 2002
Posts: 774
T
Hoopy frood
Offline
Hoopy frood
T
Joined: Dec 2002
Posts: 774
/help $matchtok

$matchtok(tokens,string,N,C)
Returns tokens that contain the specified string.

$matchtok(one two three, e, 0, 32) returns 2
$matchtok(one two three, e, 2, 32) returns three

If you specify zero for N, it returns the total number of matching tokens.

Note: $matchtokcs() is the case-sensitive version.

maybe you're looking for $gettok?
/help $gettok


Code:
//if ( khaled isgod ) echo yes | else echo no
Joined: Aug 2003
Posts: 314
S
Fjord artisan
Offline
Fjord artisan
S
Joined: Aug 2003
Posts: 314
Use $gettok(%line,1,32)

Joined: Feb 2004
Posts: 2,019
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
Hi,

Usage: /fwords
Code:
 
alias fwords filter -fk file1.txt fword
alias -l fword write file2.txt $gettok($1,1,32)



Gone.
Joined: Feb 2004
Posts: 2,019
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
Quote:
Also, for future reference, if you need the ascii value for a character, use the $asc identifier. It won't work for a few characters, such as space and ), but for a majority of characters it should work =)


Use a variable like this: //var %a = ) | echo -a $asc(%a)

In case of a soft-space, indeed you'll get no response, resulting in * /echo: insufficient parameters, but it should cover any other character, including the hard space.

Greets


Gone.
Joined: Dec 2002
Posts: 111
E
Vogon poet
OP Offline
Vogon poet
E
Joined: Dec 2002
Posts: 111
heya -


thanks for helping me out with that, but with that code u gave me I get this:

* /-fk: not connected to server (line 1, script.ini)
-

and when i do connect to a server:

-FK Unknown command
-


smirk

my code:

[code]
alias filter -fk list2.txt filter
alias -l filter write listnew.txt $gettok($1,1,32)
{/code]

Joined: Feb 2004
Posts: 2,019
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
Hi,

that is because you incorrectly copied the code, and left out the alias names. That gave you those unrequired results.

Usage: /fwords

alias fwords filter -fk list2.txt fword
alias -l fword write listnew.txt $gettok($1,1,32)

Do you see you left out the red parts? You also somehow put the filter command in the second alias as well, but it should not be there, only in the first alias. Also I just noticed you replaced the calling alias "fword" with filter (in blue)

Note that these 2 aliases go into the remotes (alt+r -> tab Remote), and not the aliases tab.
Just copy paste the aliases like you are seeing them on the board and all will be fine smile
Btw this code will only work on mirc 6.15-6.16, because the k switch is new.

Greets

Last edited by FiberOPtics; 14/08/04 02:31 AM.

Gone.

Link Copied to Clipboard