|
Falan Wanderer
Joined: 17 Aug 2004 Posts: 98 Location: OK, USA
|
Posted: Sun Jan 02, 2005 9:08 am
Info on %grep |
I have a series of names and associated groups which I want to copy from a txt file and parse into stringlists. When I copy & paste (c&p) the info from the file into the "text" portion of this #SHOW:
Code: |
#SH %replace(text,";",%crlf)
|
everything is displayed nice and neat, and I have triggers that properly create the desired stringlists.
The file can contain hundreds of names, so I wondered if I could get the info from the text file without a c&p. I tried using #FILE and %grep, like this:
Code: |
#FILE 1 test.txt
#SH %replace(%grep(1,""),"|",%crlf)
#CLOSE 1
|
It displayed the text exactly the same way as using the above #SH (as far as I could tell), however the triggers didn't fire. Hence, the stringlists weren't created with this method.
I tried the first #SH method again. Everything was displayed exactly the same way again and the triggers fired...
So, my question is, all things appearing to be the same, why didn't the triggers fire for the %grep version? I'm assuming it has something to do with %grep, so any info would be grand.
For now, I'll just use the c&p #SH.
Thanks. |
|
_________________ zMUD 7.05a |
|
|
|
megamog75 Enchanter
Joined: 20 Nov 2002 Posts: 627 Location: USA
|
Posted: Mon Jan 03, 2005 4:22 pm |
%grep is one of my favorites and I have use it alot.
First your sytax is wrong:
Code: |
#sh %replace(%grep(1," "),"|",%crlf) |
and your
Quote: |
#SH %replace(text,";",%crlf) |
Doesn't really make since with the other code.
If you have a list of names like so:
joe;mike;tim;larry;paul;zug;rastlin;strum
and you use the
Code: |
#show %replace(list,";",%crlf) |
Then yes you get this nice list.
If you want that list tobe placed in order I could help you with that, but %grep is not used for that.
%grep is for FINDING a patteren like a trigger.
If you wish to see your text Just use
Code: |
#file 1 test.txt
#show %replace(%grep(1,(*)),"|",%crlf)
#close 1 |
You have to use pattern matching to make it work and it has to be a workable % too.
I also higly recomend converting the file for eaisier use by using this
Code: |
#file 1 test.txt
#lo test_01.txt
#show %replace(%grep(1,(*)),"|",%crlf)
#lo
#close 1 |
Now you will have your list and have it in a more readably order.
and should you need to search it for a name just break out that %grep
and happy triggering you will have |
|
_________________ megamog75
I will do this.Nothing in my life matters except this.No moment in my life exists except this moment.I am born in this moment, and if I fail, I will die in this moment. Raistlin Majere |
|
|
|
Falan Wanderer
Joined: 17 Aug 2004 Posts: 98 Location: OK, USA
|
Posted: Mon Jan 03, 2005 9:48 pm |
Thank you for the reply, megamog75. As usual, I very much enjoy your input. Alas, your suggestions returned the same results. The #SH displays the text properly, but the triggers don't fire with the %grep version.
The file contains info in this format:
Code: |
group -name-
group name -a name- -a different name-
yet another group -name- -etc etc etc-
|
A regular #SHOW with the file's content c&p into it appends the end of each line with a semi-colon (;) according to screen width instead of keeping them on new lines, like so:
Code: |
group -name-;group name -a name- -a different name-;yet
another group -name- -etc etc etc-
|
which my triggers aren't written to match. Hence, the use of %replace so the file contents are shown properly as above, the triggers do there thing, and the stringlists are created properly. Oh, and order is of no concern.
Using #FILE and #SHOW with %grep (using "" or "(*)") grabs the file content and displays it correctly, but the triggers don't trigger on the output. I was trying to parse my triggers on the file contents and create the desired stringlists without having to open the file, copy the info, paste the info into a zMUD command, etc, each time. I'm guessing from the results that either I'm not using #FILE and %grep properly, or they aren't designed to be used this way, or something.
Is there a way to parse info in an external file with triggers and create stringlists with the extracted info? |
|
_________________ zMUD 7.05a |
|
|
|
Falan Wanderer
Joined: 17 Aug 2004 Posts: 98 Location: OK, USA
|
Posted: Mon Jan 03, 2005 10:08 pm |
bleh
It was the "or something". Turns out there are 2 spaces at the end of each line in the file. A plain #SHOW dropped the spaces but a #SHOW with %grep kept them.
I adjusted the pattern in the triggers and my %grep worked fine (and yours too).
Thanks again, megamog75. |
|
_________________ zMUD 7.05a |
|
|
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|