Skip to main content

Life Has A Way

Life always has a way of doing whatever it needs to do. There’s nothing wrong with that thought process. It comes and goes without a second thought. We can’t easily figure out why life does this to us, we have to understand something at some point, but if we don’t? Well, no harm no foul. It’s life and we have to continue going forward to see everything that is out there. There’s nothing we can do about it. Life will move foreward without the ability for us to do anything but wonder what this life will eventually be like in the far distant future. Oh what a joy that could bring about. If life has a way, we will be able to get from point a to point b in no time at all. It feels like a circle at times. A = B = C, isn’t that what the crazy future guy in Star Trek: Voyager tried to explain? Yeah, something like that. It’s quite an interesting thought process to be sure. It’s life though, nothing can be done about it. So let life be what it wants to be, there’s nothing wrong with that tho...

Command line Arguments

 Command line arguments are a thing that some programs need to take into consideration. Java allows for arguments to be passed into a program easy enough. But what if you want something more complex? I've found that you have to roll your own.

So, what can we do with regular command line arguments? Well, that's an interesting question now isn't it. I suppose the simplest use of a command line argument is to check for its existence. If it exists, then we do something with that knowledge.

That's fine and dandy if you ask me, but what if we want to do something more with command line arguments? Like if the argument takes a parameter or two, what then? A while ago I found an article on the internet that shows exactly what you can do with such arguments. You would call your program, and pass it a switch like this:


java test.jar -d 47

Now -d could be whatever you want it to be. It can literally represent whatever part of your program you want it to. The 47 being passed in could be whatever you need it to be as well. So, how do we go about doing this? That's a good question.

Here's some psudo code of how we would do that.

  1. Check to see if the argument starts with a dash.
  2. If it doesn't, throw an error and alert the user.
  3. If it does contain a dash, make sure that it's at least 2 characters in length.
  4. If it's not at least 2 characters in length then the user passed in a dash and that's it, then you would throw an error.
  5. Store the dashed argument in a map of some kind, and move onto the following argument. If it doesn't begin with a dash it belongs to your first argument as a parameter for that argument.
  6. Store that value in a list within the map. You can keep building this list up for that specific argument
  7. Repeat as necessary.

I'll have to dig out the code that actually makes all of this work. But for now you get the idea.

Comments

Popular posts from this blog

Schizoaffective Disorder

I want to say it first began in High School when I thought I was trying to beat the devil. Now when I say I was "trying to beat the devil", I mean I actually thought I was hearing the devil speak to me at night and that I had to find some way to overcome him. Looking back I should have sought professional help then. I remember telling a friend about this experience, and he looked at me like I was nuts. Talk about craziness right? Yeah something like that. I believe my first mental break was when I was serving a mission for The Church of Jesus Christ of Latter-Day Saints . I wanted to go home so bad. It could have just been homesickness . But...there was something more to it. About halfway through I was just done with it all. I had had enough of rejection and wanted to go home. But I was afraid that I was unable to because I would simply be told no . I know that sounds silly to people. But that's what happened. I didn't b...

Didn't Sleep

 What's the point of sleep anymore if I can't sleep? I don't think I slept any good last night. I was awake at 3 am wondering to myself, what on earth am I doing awake? Yeah, that happened. It doesn't make any sense. Fortunately, it's the weekend. So, I can catch up on sleep tonight. I don't have to be anywhere tomorrow, so it's a good opportunity to actually sleep for once. Whatever the case, I hope I'll be able to fall asleep and stay asleep. We will see what happens.

ColdFusion

So recently, I decided to include ColdFusion in my Linux setup. I was going to just run Tomcat and install CF that way, but well I decided against that route and installed ColdFusion 9 using the regular methods. It's been running quite smoothly if I do say so myself. I of course don't have the installation instructions anymore. Oops. I suppose I could Google for them again and make a copy or something. But well if my server ever crashes and I have to start all over again, yeah I'll worry aobut it then. FOr now, not so much. So here's my current setup: MySQL PHP Perl ColdFusion 9 Yeah something like that. Not too bad if I do say so myself. Of course what else would I say about it? You know I wouldn't ever say anything bad about my own server setup. Well unless I already have, if that's the case. Oops. Disregard that blog post. So yep, I think I'll have some fun with all of that for sure.