mIRC Home    About    Download    Register    News    Help

Print Thread
E
EviL_SmUrF
EviL_SmUrF
E
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: 4,670
M
Hoopy frood
Offline
Hoopy frood
M
Joined: Jun 2003
Posts: 4,670
$chr(32)

Regards,

S
Smay
Smay
S
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 =)

E
EviL_SmUrF
EviL_SmUrF
E
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


T
theRat
theRat
T
/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

S
Sigh
Sigh
S
Use $gettok(%line,1,32)

Joined: Feb 2004
Posts: 2,013
F
Hoopy frood
Offline
Hoopy frood
F
Joined: Feb 2004
Posts: 2,013
Hi,

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


Joined: Feb 2004
Posts: 2,013
F
Hoopy frood
Offline
Hoopy frood
F
Joined: Feb 2004
Posts: 2,013
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

E
EviL_SmUrF
EviL_SmUrF
E
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,013
F
Hoopy frood
Offline
Hoopy frood
F
Joined: Feb 2004
Posts: 2,013
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.

Link Copied to Clipboard