Jump to content

All my products and services are free. All my costs are met by donations I receive from my users. If you enjoy using any of my products, please donate to support me. My bare hosting costs are currently not met so please consider donating by either clicking this text or the Patreon link on the right.

Patreon

Recommended Posts

Posted

Not a big deal (not even enough to make a glamorous page for it), but I wrote an app for snagging History.dat info while I was practicing writing my own parser. It's simple to use and quick as hell, and it was fun to make (what's a couple hours on a Saturday anyhow?) So...

For the console app (historysearcher.exe):

Example CL: "History Reader.exe" -rom punchout -history "C:\History Reader\DATs\history.dat" -mameinfo "C:\History Reader\DATs\mameinfo.dat"

-rom

-romname

-romfile

The name of the rom to get the info for.

-history

-historypath

-historyfile

The location of your History.dat file. (If you don't specify a path the app will look in the application's root folder).

-mameinfo

-mameinfopath

-mameinfofile

The location of your MameInfo.dat file. (If you don't specify a path the app will look in the application's root folder).

You can just code your program to redirect the standard output if one was so inclined to do so. ;)

Otherwise this is probably useless to ya unless you wanted to look around at your MAME game history...

I also made a GUI for this little bugger and I thought it turned out kinda sexy! (History Searcher GUI.exe):

post-680-0-26418100-1347840778_thumb.png

The GUI has a file browsing option and can save the output to a text file as well.

Not sure what else I can really say about it. Maybe someone might find it useful. I mean, ya just never know! :)

*UPDATED 9/22/12*

  • (Console) Updates to code as per Ben's suggestions
  • (GUI) Likewise. ;)

*UPDATED 9/16/12*

  • (Console) Added MAMEINFO.DAT parsing
  • (GUI) Added options for MAMEINFO.DAT
  • (GUI) Cosmetic updates

History Reader.rar

  • Like 2
Posted

*UPDATED 9/16/12*

  • (Console) Added MAMEINFO.DAT parsing
  • (GUI) Added options for MAMEINFO.DAT
  • (GUI) Cosmetic updates

  • Like 1
Posted

Nice work Adultery. Just a few suggestions (you can take them or leave them).

- Don't use Directory.GetCurrentDirectory() because the current directory isn't necessarily the executable's folder. Use Path.GetDirectoryName(this.GetType().Assembly.Location) instead.

- Rather than creating a folder by appending strings use Path.Combine. Eg. Path.Combine(Path.GetDirectoryName(this.GetType().Assembly.Location, "history.dat"). If you ever run your code using Mono the folder separator for Windows is different on Linux based machines.

- For the same reason use Environment.NewLine instead of "\r\n".

- Rather than use StreamReader consider the helper class File. Eg. File.ReadAllLines().

- Rather than using "goto" you can use "break" to break out of a loop or "continue" to continue a loop (VB.NET equivalents would be Exit For/Exit While/Exit Do and Continue)

Posted

I do love suggestions! Its the only way to learn! In RE:

I actually use Application.StartupPath most times unless its for a process Working Directory, in which case I use Path.GetDirectoryName

Most of the time I do use Path.Combine, but not always. I will now though as you make a great point there.

I usually use vbcrlf for a new line. :)

I used StramReader.ReadLine since I thought it may be faster than parsing the whole file after loading it.

On that note I was using Exit While (Do While SR.Peek() <> -1) to break the loop. :)

Posted

I took most of your suggestions Ben, thanks, :)

*UPDATED 9/22/12*

  • (Console) Updates to code as per Ben's suggestions
  • (GUI) Likewise. ;)

Posted

I do love suggestions! Its the only way to learn! In RE:

I'm glad to hear that, It certainly helps to get into good habits :)

I actually use Application.StartupPath most times unless its for a process Working Directory, in which case I use Path.GetDirectoryName

Yes Application.StartupPath is definately the way to go for a Form based application. For dll's (GX plugins) and console apps the one I mentioned works well.

Most of the time I do use Path.Combine, but not always. I will now though as you make a great point there.

It's a good habit to get into.

I usually use vbcrlf for a new line. :)

That is defined as "\r\n" but on some systems it will be "\n" or "\r". Environment.NewLine maintains compatibily for these systems.

I used StramReader.ReadLine since I thought it may be faster than parsing the whole file after loading it.

It's quicker to read everything into memory and then processing the data. I just like how the File class makes it nice and easy. For creating a text file I use a List<string> textList then textList.Add() to it. You don't even need to add the newline characters. Then just call File.WriteAllLines(textList.ToArray()).

On that note I was using Exit While (Do While SR.Peek() <> -1) to break the loop. :)

That's interesting as .NET Reflector (which I used to peek at your code) converts it to a goto statement. But the Exit While is definately the preferred way despite what it compiles to.

Posted

I think the reason for that is it's implied. I don't use any continue for or goto code at all, maybe the VB environment adds this for me?

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...