Sign in to follow this  
Followers 0
sutefan

Find text from file.txt and display in MsgBox

6 posts in this topic

I trying to layout what I need to lookup, study, learn so that I can create an app that will open a file, search a specific string of text, extract part of that spring and display it in a MsgBox.

E.g.

[Example Log: C:\Program Files\Novell\ZENWorks\ZWSREG]

Friday, March 18, 2005 14:04:35 -- Login event -- Entering NDSTree::WhoAmI()

Friday, March 18, 2005 14:04:35 -- Login event -- WhoAmI() returning D1234.Workstations.ZEN.london.vca.

Friday, March 18, 2005 14:04:35 -- Login event -- Leaving NDSTree::WhoAmI()

Friday, March 18, 2005 14:04:35 -- Login event -- Adding the following to the request buffer for zenwmLoggedInWorkstation:

Friday, March 18, 2005 14:04:35 -- Login event -- D1234.Workstations.ZEN.london.vca

Friday, March 18, 2005 14:04:35 -- Login event -- Leaving WMHelperSystemEntryEx

From this example log I'm looking to extract the D1234 and display that in a MsgBox. The line could be located anywhere in the file and also the length of the D1234 and .London strings can vary.

Am I on the right track? What I am missing? What should I be looking? Should I change my approach to this?

On a similar note but for personal use I play a game called EverQuestII and it has a log file that I liked to do some searching on particulary for lines and port that to a file (XML?) so that I can view statistics on my performance.

[Example Log: C:\Program Files\Sony\Everquest2\Logs\Runneye\eq2_burt.log]

(1110268040)[Tue Mar 08 07:47:20 2005] You mined a rough malachite from the rustic stone. The rustic stone looks slightly lessened.

(1110268049)[Tue Mar 08 07:47:29 2005] You mined a lead cluster from the rustic stone. The rustic stone looks slightly lessened.

(1110268056)[Tue Mar 08 07:47:36 2005] You mined a rough malachite from the rustic stone. The rustic stone looks slightly lessened.

(1110268071)[Tue Mar 08 07:47:51 2005] You gathered a Snakeroot from the ravaged natural herb garden. The ravaged natural herb garden looks slightly lessened.

(1110268078)[Tue Mar 08 07:47:58 2005] You gathered a Juniper from the ravaged natural herb garden. The ravaged natural herb garden looks slightly lessened.

(1110268084)[Tue Mar 08 07:48:04 2005] You gathered a Milkweed from the ravaged natural herb garden. The ravaged natural herb garden looks slightly lessened.

(1110268100)[Tue Mar 08 07:48:20 2005] You gathered a Juniper from the ravaged natural herb garden. The ravaged natural herb garden looks slightly lessened.

(1110268106)[Tue Mar 08 07:48:26 2005] You gathered a Sassafras from the ravaged natural herb garden. The ravaged natural herb garden looks slightly lessened.

I'd like the data collated and extracted to XML for future use in a webpage, I'd looking at collating:

Number of times mined, gathered etc

Number of times mined, gathered specific object (rough malachite, lead cluster, snakeroot and hundred others)

Other stats to be added at later date.

I've been looking through these forums and help and so far these are things I think I should be looking at:

FileOpen

FileReadLine

String

StringInStr

StringSplit

Not sure about what I else I need to look tbh as without the knowledge it's hard to know what to look for :)

Sutefan

(30 minutes till the weekend!!!)


これは私の署名であり, 私の名前はsutefan である !

Share this post


Link to post
Share on other sites

Yes, you are on the right track and should be able to do all that you described you wanted to do in your post.

If you have troubles once you get started, post your code and your problem, and I will be happy to help :)

Share this post


Link to post
Share on other sites

I trying to layout what I need to lookup, study, learn so that I can create an app that will open a file, search a specific string of text, extract part of that spring and display it in a MsgBox.

E.g.

[Example Log: C:\Program Files\Novell\ZENWorks\ZWSREG]

Friday, March 18, 2005 14:04:35 -- Login event -- Entering NDSTree::WhoAmI()

Friday, March 18, 2005 14:04:35 -- Login event -- WhoAmI() returning D1234.Workstations.ZEN.london.vca.

Friday, March 18, 2005 14:04:35 -- Login event -- Leaving NDSTree::WhoAmI()

Friday, March 18, 2005 14:04:35 -- Login event -- Adding the following to the request buffer for zenwmLoggedInWorkstation:

Friday, March 18, 2005 14:04:35 -- Login event --  D1234.Workstations.ZEN.london.vca

Friday, March 18, 2005 14:04:35 -- Login event -- Leaving WMHelperSystemEntryEx

Sutefan

(30 minutes till the weekend!!!)

<{POST_SNAPBACK}>

I'm assuming that D1234 is the userID and .london. is the specific branch of the Novel tree?

Are all your users set up with similar looking logins? IE an alpha and 4 to 5 numerics.

If that's the case, you could stringsplit each line at the period (.) and then test the array container to see if it begins with your initial login alpha.... You could also get the branch from the same line by counting (in this case) 3 more containers up.

$line = FileReadLine($file)
$tmp = StringInStr($line,"-- Login event -- ")
$line = StringTrimLeft(StringMid($line,$tmp),18); returns from the userID forward.
$aLine = StringSplit($line,"."); returns the array of the line.
For $x = 1 to $aLine[0]
   MsgBox(0,"Array Position: " & $x,$aLine[$x])
Next

Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Yes, you are on the right track and should be able to do all that you described you wanted to do in your post.

If you have troubles once you get started, post your code and your problem, and I will be happy to help  :)

<{POST_SNAPBACK}>

Thanks at least I know I won't be wasting valuable time and limited brain cells on the wrong path!

Sutefan

Edited by sutefan

これは私の署名であり, 私の名前はsutefan である !

Share this post


Link to post
Share on other sites

I'm assuming that D1234 is the userID and .london. is the specific branch of the Novel tree?

Are all your users set up with similar looking logins?  IE an alpha and 4 to 5 numerics.

D1234 is a computer name and your correct about the .london. Yes, all are alpha and 3-4 numerics.

E.g. D1234, D456, N7890, N354

Sutefan


これは私の署名であり, 私の名前はsutefan である !

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

D1234 is a computer name and your correct about the .london.  Yes, all are alpha and 3-4 numerics.

E.g. D1234, D456, N7890, N354

Sutefan

<{POST_SNAPBACK}>

From your prior example, the log appears to always have the folowing format after the words "-- Login Event --"

CompName.workstations.ZEN.branch.twig

That's a simple matter if it always follows this pattern.

Just make sure that the stringsplit is returning an array of the correct size before yanking out the CompName and Branch.

Edited by Blue_Drache

Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0