mIRC Home    About    Download    Register    News    Help

Print Thread
$gettok #207093 05/12/08 09:55 PM
Joined: Feb 2007
Posts: 234
M
MTec007 Offline OP
Fjord artisan
OP Offline
Fjord artisan
M
Joined: Feb 2007
Posts: 234
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

Re: $gettok [Re: MTec007] #207097 05/12/08 10:38 PM
Joined: Jun 2008
Posts: 48
T
Typos Offline
Ameglian cow
Offline
Ameglian cow
T
Joined: Jun 2008
Posts: 48
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.


I've gone to look for myself. If I should return before I get back, please keep me here.
Re: $gettok [Re: MTec007] #207098 05/12/08 10:40 PM
Joined: Nov 2006
Posts: 1,559
H
Horstl Offline
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
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))

Last edited by Horstl; 05/12/08 10:50 PM.
Re: $gettok [Re: Horstl] #207099 05/12/08 11:02 PM
Joined: Feb 2007
Posts: 234
M
MTec007 Offline OP
Fjord artisan
OP Offline
Fjord artisan
M
Joined: Feb 2007
Posts: 234
thanks, i dont know why i did not think to use two $gettok's.