|
Joined: Nov 2004
Posts: 18
Pikka bird
|
OP
Pikka bird
Joined: Nov 2004
Posts: 18 |
Ok, I have a file that records all of our training. This file has about 50 diffeent people in it, and all of the lines look like the blow. need to take a variable (%blah) with a value of one of our personnel: ADAMS JOEL E 03405 005 QUAL 13 NOV 04
I need to break this variable down into 3 different sections (NAME, STATUS (QUAL), AND DATE. I would use $right and $left to break it down, the only problem is everyone's name is a different length, and some don't even have middle names. Is there a way I can tell mIRC to only account LEFT characters until it meets the 4 or 5 spaces between their name, and their number? I donno
|
|
|
|
Joined: Nov 2003
Posts: 228
Fjord artisan
|
Fjord artisan
Joined: Nov 2003
Posts: 228 |
$gettok(%variable,1-3,32) will return anything between the 1st and 3rd space (32).
So in your example it would return ADAMS JOEL E.
For more info.: /help Token Identifiers
/help $asc
|
|
|
|
Joined: Nov 2004
Posts: 18
Pikka bird
|
OP
Pikka bird
Joined: Nov 2004
Posts: 18 |
Thanks, but my problem still exists with that fix. IF I get a name without a middle name like: ACHORD THOMAS 19908 003 QUAL 23 SEP 05 and I use the $gettok 1-3, then it will return ACHORD THOMAS 19908. I only want the name, not the #'s I need a way to have mIRC just copy from the $left, until it get's to the numbers.
|
|
|
|
Joined: Feb 2004
Posts: 206
Fjord artisan
|
Fjord artisan
Joined: Feb 2004
Posts: 206 |
This file has about 50 diffeent people in it, and all of the lines look like the below. ADAMS JOEL E 03405 005 QUAL 13 NOV 04
I need to break this variable down into 3 different sections (NAME, STATUS (QUAL), AND DATE. If you change the format of the file (e.g.) ADAMS JOEL E.03405 005 QUAL.13 NOV 04 You could use the tokens more efficiently, looking for a "." (ascii 46) instead of a space (ascii 32). Otherwise, you need to count the tokens until the first character is a digit. This requires 1. finding the total number of tokens 2. looping from 1 to (while counter is less than number of tokens or until token is found 2a. check the first character of that particular token (regex) 3. taking tokens 1-(counter-1) as your name. I can't write the corresponding code at the moment, but each step is easily achieved using one or two mIRC scripting commands. Personallly, I think using a different delimiter would be easier. Cheers, DK
Darwin_Koala
Junior Brat, In-no-cent(r)(tm) and original source of DK-itis!
|
|
|
|
Joined: Nov 2004
Posts: 18
Pikka bird
|
OP
Pikka bird
Joined: Nov 2004
Posts: 18 |
There would be no way to redo my text file, that is pulled directly from another system, and it's about 1000 lines long. I am also not advanced enough to perform that while loop that you speak of I know your doing me a huge favor, and beleive me I appreciate it, but can you show me how to do it when you get a chance? AIM - Yomama1319.
|
|
|
|
Joined: Feb 2004
Posts: 2,019
Hoopy frood
|
Hoopy frood
Joined: Feb 2004
Posts: 2,019 |
Yes,
you definitely need to organise your data in a different way, so that it will be easier for you to retrieve the data afterwards.
DK mentioned using another delimiter than a space, which is the way to go. I wouldn't go with a . though, since some people's names might have a dot in it, like John F. Kennedy or something.
Instead use a delimiter which is highly unlikely to be in the data, such as $chr(230) = æ, or perhaps $chr(255) = ÿ, or use a line feed $lf ($chr(10), which can't be in a string anyway.
Suppose we use æ, then it is very easy to get parts from the data. We'd do:
//tokenize 230 <yourdata> | echo -a $1 = name * $2 = status * $3 = data
You get the picture.
Greets
EDIT: You made a new reply when I was previewing mine...seems you can't re-organise your data. Let's see what I can do for you then.
Last edited by FiberOPtics; 14/11/04 12:14 AM.
Gone.
|
|
|
|
Joined: Nov 2004
Posts: 18
Pikka bird
|
OP
Pikka bird
Joined: Nov 2004
Posts: 18 |
Yeah, I wouldn't mind reorganizing my data, but since it's 1000+ lines, and I have to do this once a week or so haha I have to make Mirc deal with it. I wish I could code in C++, I think I'll take a class lol Using mIRC to do non IRC related work is soo getto lol
|
|
|
|
Joined: Feb 2004
Posts: 2,019
Hoopy frood
|
Hoopy frood
Joined: Feb 2004
Posts: 2,019 |
Ok,
it's fairly easy to get the name part, using token identifiers. There's one thing I need to know for sure though.
The way I see it, in both examples you've provided:
ADAMS JOEL E 03405 005 QUAL 13 NOV 04 ACHORD THOMAS 19908 003 QUAL 23 SEP 05
it is always a name, followed by 6 other tokens.
1-3: status: number number QUAL 3-6: date: number month number
Is it always like that? 6 tokens following the name?
If so then you can simply get the name, by using $deltok in this way:
//echo -a $deltok(ACHORD THOMAS 19908 003 QUAL 23 SEP 05,-6-,32) //echo -a $deltok(ADAMS JOEL E 03405 005 QUAL 13 NOV 04,-6-,32)
If not, let me know we'll work it out.
Greets
Gone.
|
|
|
|
Joined: Feb 2004
Posts: 206
Fjord artisan
|
Fjord artisan
Joined: Feb 2004
Posts: 206 |
I could try to start - this is not complete or tested:
/tokenise $read(whatever you read from the file) /var %numtoks = $0 /var %notfound = $true /var %counter = 1
while ( (%notfound) && ( %counter <= %numtoks)) { if (<some regex command to return a digit using $left( [ $ $+ %counter ], 1 ) > ) { %found = $true } inc %counter } dec %counter set %the_name $1- $+ %counter
Cheers,
DK
Darwin_Koala
Junior Brat, In-no-cent(r)(tm) and original source of DK-itis!
|
|
|
|
Joined: Nov 2004
Posts: 18
Pikka bird
|
OP
Pikka bird
Joined: Nov 2004
Posts: 18 |
yes it is always like that, the only reason I have to do this, is that if the line meets certain crytea, I have it sent to another file, and then that file I am inporting into excel. Excel need's a day to determine the difference between the name, and the numbers right next to the name. I need to figure out a way to just have everything line up, right now my output file is looking like this:
LASTNAME FIRSTNAME MANNUMBER SKILL_LEVEL STATUS DUEBY HOWLONG APODACA AMBER L 04549 005 *AWACT 27 JAN 05 3MONTHS ARMSTRONG EARL II 05579 005 *AWACT 27 JAN 05 3MONTHS ARNETT CHARLES D 05738 005 *AWACT 22 JAN 05 3MONTHS AYALA RENE 05877 005 *AWACT 23 JAN 05 3MONTHS
and I need it like Ayala Rene 05877 005 *AWACT 23 JAN 05 3 MONTHS ARNETT CHARLES ETC with a large space inbetween each field so excel can understand it's suppose to be inserted into a different cell.
LOL, guess this form doesn't undestand putting differen twords with large spaces inbetween. I just need each field to have like a TAB worth of space inbetween each one.
Last edited by Bordom; 14/11/04 12:31 AM.
|
|
|
|
Joined: Feb 2004
Posts: 2,019
Hoopy frood
|
Hoopy frood
Joined: Feb 2004
Posts: 2,019 |
The new data that you have posted is different from the earlier data. Now it contains "xmonths" as last token.
Anyway, your solution is definitely $deltok.
$deltok(<data>,-6-,32) if "xmonths" isn't included in the string $deltok(<data>,-7-,32) if "xmonths is included in the string
That's it.
Greets
Gone.
|
|
|
|
Joined: Feb 2004
Posts: 2,019
Hoopy frood
|
Hoopy frood
Joined: Feb 2004
Posts: 2,019 |
Hehe,
it wouldn't have to be that much work, just: alias getname !.echo -q $regex($1-,/(\D+)/g) | return $regml(1)
Greets
Gone.
|
|
|
|
Joined: Nov 2004
Posts: 18
Pikka bird
|
OP
Pikka bird
Joined: Nov 2004
Posts: 18 |
Great works like a charm! Thanks. I have another problem now lol, I am trying to put in the name, then a bunch of spaces $chr(32) then the rest of the info, but it seems like it ignores the $chr(32) and just /writes to the text file normal:
/write c:\nottrained.txt $deltok(%blah,-6-,32) $chr(32) $chr(32) $chr(32) $chr(32) $chr(32) $chr(32) $right(%blah,25)
Hah this is soo furstating, all I want it spaces between the output of the $deltok command, and the rest of the $right
|
|
|
|
Joined: Feb 2004
Posts: 2,019
Hoopy frood
|
Hoopy frood
Joined: Feb 2004
Posts: 2,019 |
Ah yes, the multiple space problem. Well I made you something that will enable you to have a couple of real spaces ($chr(32)) in between the name and the rest of the data. I noticed you are using $right(25) to get the data after the name, I would not use $right, since the numbers in the data may vary in length, which would mean you didn't capture all your data with $right. Instead use $gettok in this way: $gettok($1-,-6-,32) Usage: /writedata <data> alias writedata {
bset -t &a 1 $deltok($1-,-6-,32) æææææ $gettok($1-,-6-,32) $+ $crlf
breplace &a 230 32
bwrite c:\nottrained.txt -1 -1 &a
}
The character æ represents a space in this snippet, so you can add/delete some of em, to meet your needs. I could swear I used to know a shorter way to simply write more spaces in a string to a file, but I only got up half an hour ago, maybe I'll recall it later on. Greets
Last edited by FiberOPtics; 14/11/04 04:23 PM.
|
|
|
|
Joined: Nov 2004
Posts: 18
Pikka bird
|
OP
Pikka bird
Joined: Nov 2004
Posts: 18 |
I figured out if I used $chr(160) it would actually include spaces. My main concern now is how to take every bit from the line, calculate it, so that all data evens out. (Ex: Since some names are longer, hvae middle initials, etc it's difficult to do) I got the NAME out of $gettok, but can't figure out how to pull every other peace out one by one with $gettok If I could pull out every peace of information and assign it a variable I could figure something out - even though I'm at a lost lol
|
|
|
|
Joined: Feb 2004
Posts: 2,019
Hoopy frood
|
Hoopy frood
Joined: Feb 2004
Posts: 2,019 |
Hi, yes you could use $chr(160) instead of $chr(32), but note that it is a hard space, not the same as $chr(32). I don't know if Excell will accept that, only way find out, is to try. Beware, on some fonts $chr(160) will be another character, but since it works for you, it's fine. It looks to me that you ought to read up on mIRC Scripting a bit, especially on token identifiers. In mIRC, type /help token identifiers, or take a look at this tutorial We can all help you with scripting, but in the end, you can help yourself the most, by learning. Greets EDIT: meh, I was bored anyway: alias getname return $deltok($1,-6-,32) alias getdate return $gettok($1,-3-,32) alias getstatus return $gettok($gettok($1,-6-,32),1-3,32)
Last edited by FiberOPtics; 14/11/04 07:20 PM.
|
|
|
|
Joined: Nov 2004
Posts: 18
Pikka bird
|
OP
Pikka bird
Joined: Nov 2004
Posts: 18 |
Thank you everyone for your help. I was reading up on the tutorial, and still don't understand quiet how the $deltok works. If I use $deltok(%blah,-6-,32) on this line:
%blah CARLSON TIA A 01366 004 AWACT NONE
then, mIRC should goto the 6th token (which should be AWACT) and take that token out? Which would leave CARLSON TIA A 01366 004 NONE? What does the - symbol do? Shouldn't I be able to do $deltok(%blah,4-,32) and have that remove everything bu Carlson Tia A?
|
|
|
|
Joined: Feb 2004
Posts: 2,019
Hoopy frood
|
Hoopy frood
Joined: Feb 2004
Posts: 2,019 |
$deltok(string,range,delimiter)
1] Deltok with positive range
1 = this 2 = is 3 = a 4 = test
$deltok(this is a test,1,32) -> range: 1 = this -> result: is a test
$deltok(this is a test,2-3,32) -> range: 2-3 = is a -> result: this test
$deltok(this is a test,3-,32) -> range: 3- = a test -> result: this is
In other words, you can specify a range by using the - sign, which will remove these tokens from the string. If you specify N-, then anything from the token N will be deleted, since we don't specify an end point, just a beginning point.
2] Deltok with negative range
When the range is preceded by a minus sign (-), it means that mIRC will reference to the tokens in backwards order. Meaning -1 = the last token in the string, -2 the one before that, etc.
So:
-1 = test -2 = a -3 = is -4 = this
$deltok(this is a test,-1,32) -> range: -1 = test -> result: this is a
$deltok(this is a test,-3,32) -> range: -3 = is -> result: this a test
$deltok(this is a test,-3-,32) -> range: -3- = is a test -> result: this
What just happened? The range is -3-. This means:
a) Delete the third token, counting from the end of the string. b) Don't only delete the third token, but anything following that.
The result is that "is a test" is deleted from the string.
Regarding your user data, provided in this thread:
ADAMS JOEL E 03405 005 QUAL 13 NOV 04 ACHORD THOMAS 19908 003 QUAL 23 SEP 05
If the name of a person would always be 2 tokens, then we would not need to use $deltok, because we can get that info by using $gettok($1-,1-2,32).
However, the number of tokens which define a name, is variable. In other words, we don't know the range. What we do know, on the other hand, is that there are always 6 tokens following the name, so the solution is at hand. We simply delete the 6 tokens with $deltok, by referencing them in backwards order.
$deltok(ADAMS JOEL E 03405 005 QUAL 13 NOV 04,-6,32) -> result: ADAMS JOEL E 005 QUAL 13 NOV 04 -> the sixth token, counting backwards is "03045", is deleted
$deltok(ADAMS JOEL E 03405 005 QUAL 13 NOV 04,-6-,32) -> result: ADAMS JOEL E -> the sixth token, counting backwards, and everything following it, is deleted
I hope you found this mini-tutorial regarding deltok handy, and that you can create a solution for your problem.
Greets
Gone.
|
|
|
|
|