Thursday, June 12, 2008

BASIC Goodness

I've made good progress on the Gas Calc, so far it is working nicely. There's still some stuff to finish (mileage calculator, unit converter) but it should be done shortly.

Once it's done I'll be making a SourceForge page for it. I'll post the VB Express 2008 source code as well as the program executable along with an installation package.

Since I use Kubuntu as my main desktop OS, I figured I'd also create a Linux/Mac OSX version to go along with the Windows version. I figured I'd have to use KDevelop (which would be a steep learning curve for me as I don't know C++), however doing a quick Google search for "visual basic for linux", the third result is something that I've long dreamed of but never knew existed: a Visual Basic clone for Linux!!

Okay, so the developers don't want people calling it a clone, since it's not exactly the same as VB. Gambas is an acronym that stands for "Gambas Almost Means Basic". It's basically (pun intended) the same thing as Visual Basic, just not quite as full-featured. However every essential feature of Visual Basic 6.0 is included in Gambas, with some features replicated to stunning detail. The major difference of course is that Gambas lets developers create quick-and-easy applications for Linux, in a WYSIWYG development environment. Hats off to the Gambas developers for creating such a cool IDE!

Since I discovered Gambas last night, I've recreated the entire VB Express project in Gambas (imports are not supported as the code isn't 100% compatible, even though it's very similar). Everything works the same as the Windows version, including the About box. Gambas also supports console-based projects, so once I'm done with the GUI versions I'll also create a Linux console version for those who despise GUI's.

All of these projects will be posted on the SourceForge page for anyone to download. I strongly believe in open source software and the Free Software concept, so I feel like I should give back a little bit. I started with mod2avi, a script to convert JVC mod files to AVI files, and figured I might as well open source some of the other projects I'm working on such as Gas Calculator.

Saturday, June 7, 2008

Gas Calculator Algorithms

Here are the algorithms I intend to use for the Gas Calculator. Keep in mind I'm Canadian so I'll be defaulting to liters, however I intend to build in the ability to use either liters or gallons. Also even though we use metric, the car dealerships still advertise Miles Per Gallon (MPG) efficiency so that's what I'll be using.

Input Options:
- Days Per Week (default 5)
- Distance from Home to Work
- Distance from Work to Home (in case someone takes a different route home)
- Miscellaneous distance traveled in a week (recreation, etc)
- Highway distance traveled in a month
- Vehicle MPG (highway mpg as well as city mpg)

Calculations:
- Gallons burned per month = (Total city travel / city MPG) + (Total highway travel / highway MPG)
- Gas cost per month = Liters burned per month * Cost per liter

Conversions:
- 1 mile = 1.6093 kilometers
- 1 kilometer = .06214 miles
- 1 US gallon = 3.7854 liters
- 1 liter = 0.2642 US gallons

I'm also gonna make a separate area/dialog box for unit conversion. Looks like VB Express 2008 is done installing so might as well start programming. :)

Gas Prices and Dishonest People

I feel the need to rant about gas prices, and also about crooks that sell vehicles and lie through their teeth as they sell them to you.

First of all lets start with the latter. I bought a 4x4 SUV from a guy in January, since I've always wanted a 4x4 and lake season was approaching, I figured I'd get a nice little truck that I could take offroading if I want to. I should preface all this with I've learned a HUGE amount from this whole ordeal and will be handling used vehicle purchases quite differently in the future.

When I bought it from him, he insisted there was nothing wrong with it and he's always taken good care of it. He was apparently only selling it because he needed the money, he didn't really want to get rid of the vehicle. So a week after I take possession, a cold snap hits (-45c, ouch). Turns out the vehicle had weak radiator coolant (-18c test) which froze up and caused the vehicle to overheat and in turn cause damage to the radiator.

It ends up costing me a couple hundred bucks, which I'm now suing the guy for since I figure he should have had the vehicle properly winterized since I bought it from him in the middle of winter. Keep in mind this vehicle wasn't sold as is, the seller insisted the vehicle was in tip-top shape (and indeed it looked to be as such, to my untrained eye).

So that's one issue. The other issue is now I'm one of many people seriously thinking about trading my SUV for a much more gas efficient car. After appraising the vehicle, the dealership tells me it's worth about half what I paid for it, due to the vehicle's demand depreciating over high gas prices. Of course, the dealership wants to make some money on it too, so I figure they're lowballing me a little bit.

Besides the rage that I feel towards the asshole that sold me the vehicle, there are some huge lessons learned. I could have learned these lessons beforehand and it would have saved me a lot of trouble, but hey, life is a learning process.

1. Never buy from a private seller. Most of them are full of shit and the rest won't be willing or able to cover any problems you might have. That's the golden rule. But, that doesn't mean every car dealership is honest either, hence:

2. Never take their word for it. I made a mistake and fell into the trap of "this guy's a nice guy". Some people can put on a real good nice person act, and actual nice people like me (that are sometimes admittedly gullible) might fall into that trap. They'll either tell you the truth and filter out everything bad, or they'll throw some small or even large lies in there hoping that you'll bite.

3. Inspect the vehicle for yourself, don't just get someone else to do it. I had a friend look at the vehicle, he simply scanned the computer codes and said everything should be okay. If I had looked more closely at some things for myself, I might have checked the fluids instead of taking the seller's word for it. Then I would have noticed the weak radiator fluid gelling up, and of course not bought the vehicle.

I guess those are the major learning lessons. I will never buy another vehicle from a private seller; I will never simply take someone's word for it; and I will always inspect the vehicles very closely myself. It seems like simple stuff and hey, maybe it is, but now I know first-hand.

So anyways, enough of that schlock. As I mentioned, I'm trading in my SUV for something more efficient since gas prices are crazy. Gasoline here costs $1.36/L. That's $5.15/gallon. My 4x4 SUV gets 15mpg on the highway and 11mpg in the city. I've done some math and figured out buying a Cobalt will almost pay for itself in gas savings, at 43mpg on the highway and 29mpg in the city.

I was doing a whole bunch of math, and that's what made me think of the idea to make a Gas Calculator. I did a quick Google search and there's nothing quite what I'm looking for out there, so I figured since I'm handy with Visual Basic, I'll install VB Express 2008 and whip up a handy calculator. I figure it will be helpful to others, so I'll open source it and post it on this blog as well.

Finally did it

Well, I finally did it. I've created a place online where I can express some of my thoughts. It's not like it's my first webpage though, I've been creating personal websites since the late 90's. I just never really created a 'journal' type page where I can express my thoughts, sorta like people do these days with Facebook (et al). I have a Facebook account but I never really got into it, I kinda like the blog format though so I think that's what I'll stick to.

Just a note on the name of this blog, I figured I'd call it The BWAIN (Blog Without an Interesting Name). I was gonna call it Dylan's BWAIN but thought the address would be too long, plus 'bwain' and 'mybwain' were already taken. So I settle on 'thebwain'. ;)