New URL

This old URL hasn't been updated for a while, but I'm still putting out new stuff! Check out the shiny new domain at http://blog.ascagnel.com/.

Saturday, November 7, 2009

My sordid past

My sordid past isn't what the average person thinks as sordid.  But, it is sordid for a developer.  I've spent two summers working as *gasp* a Visual Basic for Applications programmer.  I hate the language, I hate the developer tools (a knockoff of Visual Studio 5 or 6 embedded in Microsoft Office), and I hate some of the overdone verbosity of the language.  While the language has a good API behind it, and the structure of the language is something along the lines of GTK+'s "just keep typing til you get something you want done" development, it was missing a few critical, common chunks.

One of these chunks is the bog-standard stack.  There's no stack object built into the API, and Microsoft's "here's how to make a stack" guide is a bit complex for everyday use (they go into some weird ByRef memory management stuff, and an item linked from a stack isn't a true stack, per se). 

I rolled my own, but added a few tweaks that are outside the normal stack.  I added a "peek" function that either checks the top of the stack without popping, or can look up a value at a specific index.  Also added was a depth function, to check how big the stack is, and the ability to look up if a value is already in the stack.  I created this block for a project that needed to analyze the full contents of the stack on a repeating basis, and it worked out very well.  There are still a few tweaks that could be made, such as peek returning a null if the index is outside of the scope of the stack head, or maybe adding in more substantial error checking.

Rather than posting the file here, I'll let PasteBin handle the beautification here: http://pastebin.com/f3f11da41