*preface* Do not bother reading this unless you are into long technical geeky stuff like programming.
Man I have a new found appreciation for languages that don't suck...
I just finished* writing a program that will automate a very tedious and mind numbing portion of my job. It took me a very long time to get everything working, not because the program was overly complicated, but because I had to teach myself the language as I went. The language--the dreaded Visual Basic...
I know, I know. Why would I choose to go that route when there are so many more far superior options? Well basically I landed in it on accident. I was working on trying to do some macros in excel by using the record macro option when I ran into a snag and asked Jonathon Miller (the Aurora tech) offhandedly, "don't suppose you know anything about excel macros". I wasn't seriously asking because I didn't think anyone here on station would know how to work with them, but as it turned out he is an excel wizard. So I had him come over and help me with a problem I was having when he revealed to me I could just write the macro instead of using the record option. This was actual code... Holy crap, I just didn't realize that! So many ideas then flooded into the ol noggin. And thus I started my little adventure into the VB world. Jonathon was a big help initially with the first part of what I was trying to do. He was able to show me how to cut my 30 line recorded macro into about 6 lines of actual code. Man that recorder is handy but very inefficient. The other reasoning for sticking with VB is that I needed something that would just work on all of the computers without needing to install anything special. This current prog (macro) can just be dragged into anyone's excel startup folder and simply work.
So here was the problem I was trying to solve. Every weekend I have to go into out networked drive and create new timecards. To do this I have to first open up my computer, navigate to the drive, traverse the folders to get to the timecards. Then I have to open each person's individual timecard folder make a copy of the current timecard and save it to their individual "Old Timecards" folder. Then I have to open up the first timecard that I made a copy of, change the date of the timecard, and also go through and delete all the old entries from that week. Then I save the timecard, then I rename the timecard to match the date I just changed for the following week. Then I do this for every person on station who turns in a timecard. This process is by no means difficult, it's just mind numbing, tedious and a waste of my time. This is something that a program can and should be doing for me. The only question now was how...
I had never seen VB prior to that first realization that an excel macro was actually vb code. So to say the least I had a bit to learn. The program ended up taking me about 48 hours worth of actual time to get to this finished* state. I say finished* because it's functionally complete, but still needs a bunch of polishing yet, such as error handling, modifying it so that any ol person can come up and click a button and have it work, etc. The code that I have written right now, had I known VB prior would have taken me maybe an hour to write. Man it is a painful process trying to learn a new language with limited internet access. The internet was generally down when I would code, which made things very difficult. Microsoft's help is semi-useless.
I broke the problem up into pieces like any good little programmer. I had a bit of code I could open each timecard and use to save a copy to their old timecards spot, change the date and delete the contents. I then worked on a bit of code to traverse the folders of the respective employees. I then worked on a bit of code to change the file date of the new timecard file. This last step consequently caused me to lose 7 hours worth of work and all of my prior code. It was late and I just threw in a function without saving or backing up my work, and it ultimately permanently deleted the file that stored all the macros(my code). I tried a file recovery on it but the file had already been over written by the time I got through the recovery. Thankfully I had an earlier backup that was just missing the 7 hours worth of work. This isn't the first time I've done this either, I remember while in my Computers and Components class deleting 12 hours worth of assembly code, now that is painful. Once I had all these modules working standalone I began adding them together piece by piece until I had a completed little app.
I ran the program on the live server for the first time last night and it barfed, even though it worked perfectly on all the "test" servers! well the problem was a couple of people had their timecards open which caused some major issues. This was sort of a blessing in disguise, after I got over the annoyance of the timecards being open I realized this was a very normal thing that could happen all the time and the code needed to be able to cope with it. So I wrote some error handling for this type of event. And now what once took me I don't know how long, takes a matter of seconds. And now that I have a better loathing-understanding for VB the next item on the todo list should go a bit easier, well in theory anyway...
Is it a bad sign when you get all tingly with excitement when you realize that you can do something with the program? Last night while I was finishing up the code I was going through the earlier mentioned websites I had saved to the drive when I came across something that got me incredibly excited. I could add a function to my code that would check to see if the persons timecard was complete (54 hours or greater) and have the code send out an email to the person letting them know if it wasn't complete! Oh my goodness I was excited. I believe I was saying, "oh, god, oh god this is awesome, oh god oh god". I then immediately emailed myself about this so I would not forget. And an hour later I had forgotten, I noticed an email from myself in the ol inbox and couldn't for the life of me remember what it was for. Then I opened it and got excited all over again. God it feels good to be a nerd! Now the question is do I set it to spam the crap out of their inbox, or send a friendly reminder... Every mailbox has a size limit here, once you reach it you can no longer get any emails, so if I send out a 5K message in a loop of say 1 to 6000 that should fill their inbox completely blocking all incoming and outgoing email traffic, hmm yes then set a filter on my machine to autodelete any message sent with given subject... You know speaking of inboxes that reminds me, I got in "trouble" earlier this year when Tripp was trying to trim down server space and came across my mailbox size. We have a limit of 30MB I think it is, well during the summer as IT I removed my limit, and was sitting at a little over 600MB when he came to me ;} Man I miss being in IT...
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment