mIRC Homepage
Posted By: MTec007 $gettok - 05/12/08 09:55 PM
i am having a hard time getting the file path from a line, a few examples are below. i have no control of the format of the lines
but i need to get the path ie; "C:\Program Files\COMODO\Firewall\".
it gets tricky because of all the spaces, like "C:\Program Files\PSPad editor\" any one have a suggestion for me on this suject?

Code:
0 +fs 1 0 0 C:\Program Files\COMODO\Firewall\cfp.exe 	+fs 0 0 0 344 	+fs 0 0 0 1.71MB
0 +fs 2 0 0 C:\PROGRA~1\Comodo\CBOClean\BOC427.exe 	+fs 0 0 0 368 	+fs 0 0 0 0.34MB
0 +fs 6 0 0 C:\Program Files\Dell\QuickSet\quickset.exe 	+fs 0 0 0 472 	+fs 0 0 0 0.98MB
0 +fs 15 0 0 C:\Program Files\PSPad editor\PSPad.exe 	+fs 0 0 0 1808 	+fs 0 0 0 3.56MB
0 +fs 14 0 0 C:\Firefox\App\firefox\firefox.exe 	+fs 0 0 0 2212 	+fs 0 0 0 0.29MB
0 +fs 12 0 0 C:\mIRC\mirc.exe 	+fs 0 0 0 2516 	+fs 0 0 0 2.68MB
Posted By: Typos Re: $gettok - 05/12/08 10:38 PM
I used the $chr(9) $+ +fs to tell it where to stop so if thats not constant than this isnt a good solution.

I came up with $gettok(LINE,6 $+ - $+ $calc($findtok(LINE,$chr(9) $+ +fs,1,32)

So, to see an example type:
Code:
//var %tmpline 0 +fs 1 0 0 C:\Program Files\COMODO\Firewall\cfp.exe 	+fs 0 0 0 344 	+fs 0 0 0 1.71MB | echo -a $gettok(%tmpline,6 $+ - $+ $calc($findtok(%tmpline,$chr(9) $+ +fs,1,32) - 1),32)


This was just the first solution that popped into my head so let me know if and why it won't work and I will try again if needed.

Good luck.
Posted By: Horstl Re: $gettok - 05/12/08 10:40 PM
As in all your examples the file path start at the 6th space-delimited token [ $chr(32) ], and is part of the first TAB-delimited token [ $chr(9) ], try: $gettok($gettok(LINE,1,9),6-,32)

Code:
var %text = 0 +fs 6 0 0 C:\Program Files\Dell\QuickSet\quickset.exe 	+fs 0 0 0 472 	+fs 0 0 0 0.98MB
echo -a $gettok($gettok(%text,1,9),6-,32)


Edit: sorry I missed it. To get the file path only, use: $nofile(some path\file.ext)
e.g. : $nofile($gettok($gettok(<your line>,1,9),6-,32))
Posted By: MTec007 Re: $gettok - 05/12/08 11:02 PM
thanks, i dont know why i did not think to use two $gettok's.
© mIRC Discussion Forums