mIRC Homepage
Posted By: EviL_SmUrF stupid question that i cant figure out - 12/08/04 12:57 AM
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!
Posted By: Mentality Re: stupid question that i cant figure out - 12/08/04 01:11 AM
$chr(32)

Regards,
Posted By: Smay Re: stupid question that i cant figure out - 12/08/04 02:02 AM
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 =)
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

Posted By: theRat Re: stupid question that i cant figure out - 12/08/04 07:41 AM
/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
Posted By: Sigh Re: stupid question that i cant figure out - 12/08/04 07:45 AM
Use $gettok(%line,1,32)
Hi,

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

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
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]
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
© mIRC Discussion Forums