ircmirc

Use $2, $1, etc. in a text file?


First off let me say sorry for the wording on this, I am new to coding in mIRC and don't quite know the terms and/or how to do what I want.

My goal is to use whatever the term for "$1" in a text file, such as this text file with a line containing the following

hello something

I would like for it to then write the following in a new text file.

hello

I know this is a subpar example, but I am sure one of you will be able to help me. Along with a solution, I would appreciate if someone would share where they found this information along with where I can learn more about it.


Solution

  • http://en.wikichip.org/wiki/mirc is a great source.

    But to answer your question:

    For this you would use $read, to read the line from your file.
    $read(file.txt,n,1), this will read line number 1 from the file file.txt.

    You can assign this to a variable, so var %line = $read(file.txt,n,1), this will assign the content from line 1 in file.txt to %line.

    After having the content stored in %file you can use $gettok to retrieve the first word. The delimiter in your case is a space, so you use 32. For other values look here: http://www.asciitable.com/ and select from the dec column. $gettok(%line,1,32) will get you the first word.

    You can, again, store this in a variable if needed and write it in another .txt file.

    Extra:
    Have a look at /tokenize, you can use this instead of $gettok, this will make it easier for you to use $1, $2 etc, after. It will also slightly improve the performance.